aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcrystfel/src/cell-utils.c1
-rw-r--r--libcrystfel/src/datatemplate.c10
-rw-r--r--libcrystfel/src/image-hdf5.c44
-rw-r--r--libcrystfel/src/indexers/dirax.c6
-rw-r--r--libcrystfel/src/indexers/taketwo.c8
-rw-r--r--libcrystfel/src/rational.c10
-rw-r--r--libcrystfel/src/reflist-utils.c1
-rw-r--r--libcrystfel/src/stream.c16
-rw-r--r--libcrystfel/src/thread-pool.c10
-rw-r--r--src/ambigator.c27
-rw-r--r--src/cell_tool.c22
-rw-r--r--src/crystfel_gui.c18
-rw-r--r--src/diffraction-gpu.c13
-rw-r--r--src/gui_backend_slurm.c6
-rw-r--r--src/gui_project.c42
-rw-r--r--src/partialator.c37
-rw-r--r--src/pattern_sim.c26
-rw-r--r--src/process_hkl.c14
-rw-r--r--src/render_hkl.c3
-rw-r--r--src/whirligig.c26
20 files changed, 175 insertions, 165 deletions
diff --git a/libcrystfel/src/cell-utils.c b/libcrystfel/src/cell-utils.c
index cdd4156b..5131fb20 100644
--- a/libcrystfel/src/cell-utils.c
+++ b/libcrystfel/src/cell-utils.c
@@ -982,7 +982,6 @@ UnitCell *load_cell_from_file(const char *filename)
do {
- char line[1024];
int n1;
int i;
char **bits;
diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c
index a2b974a7..48fe4cfa 100644
--- a/libcrystfel/src/datatemplate.c
+++ b/libcrystfel/src/datatemplate.c
@@ -1122,10 +1122,10 @@ DataTemplate *data_template_new_from_string(const char *string_in)
/* Copy the next line from the big string */
const char *nl = strchr(string, '\n');
if ( nl != NULL ) {
- size_t len = nl - string;
- line = strndup(string, nl-string);
- line[len] = '\0';
- string += len+1;
+ size_t nlen = nl - string;
+ line = strndup(string, nlen);
+ line[nlen] = '\0';
+ string += nlen+1;
} else {
line = strdup(string);
done = 1;
@@ -1437,7 +1437,7 @@ DataTemplate *data_template_new_from_string(const char *string_in)
for ( rgci=0; rgci<n_rgc_definitions; rgci++ ) {
- int rgi, n2;
+ int n2;
struct rg_collection *rgcollection = NULL;
rgcollection = find_or_add_rg_coll(dt, rgc_defl[rgci]->name);
diff --git a/libcrystfel/src/image-hdf5.c b/libcrystfel/src/image-hdf5.c
index 494254cc..ec8fc36f 100644
--- a/libcrystfel/src/image-hdf5.c
+++ b/libcrystfel/src/image-hdf5.c
@@ -814,13 +814,13 @@ int image_hdf5_read_header_to_cache(struct image *image, const char *name)
} else if ( class == H5T_STRING ) {
htri_t v;
- hid_t type;
+ hid_t stype;
char *val;
- int r;
+ int rv;
- type = H5Dget_type(dh);
- v = H5Tis_variable_str(type);
- H5Tclose(type);
+ stype = H5Dget_type(dh);
+ v = H5Tis_variable_str(stype);
+ H5Tclose(stype);
if ( v == 0 ) {
val = read_single_fixed_string(dh);
@@ -835,16 +835,16 @@ int image_hdf5_read_header_to_cache(struct image *image, const char *name)
if ( val != NULL ) {
image_cache_header_str(image, name, val);
free(val);
- r = 0;
+ rv = 0;
} else {
ERROR("Failed to read string '%s'\n",
subst_name);
- r = 1;
+ rv = 1;
}
free(subst_name);
close_hdf5(fh);
- return r;
+ return rv;
} else {
/* Should never be reached */
@@ -956,18 +956,18 @@ int image_hdf5_read_header_to_cache(struct image *image, const char *name)
} else if ( class == H5T_STRING ) {
- hid_t type;
+ hid_t stype;
- type = H5Dget_type(dh);
- if ( H5Tis_variable_str(type) ) {
+ stype = H5Dget_type(dh);
+ if ( H5Tis_variable_str(stype) ) {
/* Vlen string from array */
- herr_t r;
+ herr_t rv;
char *val;
- r = H5Dread(dh, type, ms, sh, H5P_DEFAULT, &val);
- if ( r < 0 ) {
+ rv = H5Dread(dh, stype, ms, sh, H5P_DEFAULT, &val);
+ if ( rv < 0 ) {
ERROR("Can't read HDF5 vlen string from array - %s\n",
subst_name);
free(subst_name);
@@ -988,20 +988,20 @@ int image_hdf5_read_header_to_cache(struct image *image, const char *name)
/* Fixed-length string from array */
- herr_t r;
+ herr_t rv;
char *val;
- size_t size;
+ size_t ssize;
- size = H5Tget_size(type);
- val = malloc(size);
+ ssize = H5Tget_size(stype);
+ val = malloc(ssize);
if ( val == NULL ) {
close_hdf5(fh);
free(subst_name);
return 1;
}
- r = H5Dread(dh, type, ms, sh, H5P_DEFAULT, val);
- H5Tclose(type);
- if ( r < 0 ) {
+ rv = H5Dread(dh, stype, ms, sh, H5P_DEFAULT, val);
+ H5Tclose(stype);
+ if ( rv < 0 ) {
ERROR("Couldn't read HDF5 fixed string from array - %s\n",
subst_name);
close_hdf5(fh);
@@ -1009,7 +1009,7 @@ int image_hdf5_read_header_to_cache(struct image *image, const char *name)
return 1;
} else {
- val[size] = '\0';
+ val[ssize] = '\0';
chomp(val);
image_cache_header_str(image, name, val);
free(val);
diff --git a/libcrystfel/src/indexers/dirax.c b/libcrystfel/src/indexers/dirax.c
index ef90a3f7..d1be9e7c 100644
--- a/libcrystfel/src/indexers/dirax.c
+++ b/libcrystfel/src/indexers/dirax.c
@@ -228,10 +228,10 @@ static void dirax_parseline(const char *line, struct image *image,
&d, &d, &d, &d, &d, &d, &di) == 9 ) {
if ( acl_nh > dirax->best_acl_nh ) {
- int i, found = 0;
+ int i_acl, found = 0;
- for ( i=0; i<dirax->n_acls_tried; i++ ) {
- if ( dirax->acls_tried[i] == acl ) found = 1;
+ for ( i_acl=0; i_acl<dirax->n_acls_tried; i_acl++ ) {
+ if ( dirax->acls_tried[i_acl] == acl ) found = 1;
}
if ( !found ) {
diff --git a/libcrystfel/src/indexers/taketwo.c b/libcrystfel/src/indexers/taketwo.c
index 72aa0bad..29598a01 100644
--- a/libcrystfel/src/indexers/taketwo.c
+++ b/libcrystfel/src/indexers/taketwo.c
@@ -1538,15 +1538,15 @@ static int find_seeds(struct TakeTwoCell *cell, struct taketwo_private *tp)
cell->seeds = tmp;
- int i;
- for ( i = 0; i < seed_num; i++)
+ int seed_i;
+ for ( seed_i = 0; seed_i < seed_num; seed_i++)
{
- if (seeds[i].idx1 < 0 || seeds[i].idx2 < 0)
+ if (seeds[seed_i].idx1 < 0 || seeds[seed_i].idx2 < 0)
{
continue;
}
- cell->seeds[cell->seed_count] = seeds[i];
+ cell->seeds[cell->seed_count] = seeds[seed_i];
cell->seed_count++;
}
diff --git a/libcrystfel/src/rational.c b/libcrystfel/src/rational.c
index 76aa7014..db02ee93 100644
--- a/libcrystfel/src/rational.c
+++ b/libcrystfel/src/rational.c
@@ -460,16 +460,16 @@ int transform_fractional_coords_rtnl(const RationalMatrix *P,
rtnl_mtx_get(cm, h, k));
for ( j=0; j<cm->cols; j++ ) {
- Rational t = rtnl_mtx_get(cm, i, j);
+ Rational tcol = rtnl_mtx_get(cm, i, j);
Rational p = rtnl_mul(dval, rtnl_mtx_get(cm, h, j));
- t = rtnl_sub(t, p);
- rtnl_mtx_set(cm, i, j, t);
+ tcol = rtnl_sub(tcol, p);
+ rtnl_mtx_set(cm, i, j, tcol);
}
/* Divide the right hand side as well */
- Rational t = vec[i];
+ Rational trhs = vec[i];
Rational p = rtnl_mul(dval, vec[h]);
- vec[i] = rtnl_sub(t, p);
+ vec[i] = rtnl_sub(trhs, p);
}
h++;
diff --git a/libcrystfel/src/reflist-utils.c b/libcrystfel/src/reflist-utils.c
index 4a284c07..52cf5e61 100644
--- a/libcrystfel/src/reflist-utils.c
+++ b/libcrystfel/src/reflist-utils.c
@@ -411,7 +411,6 @@ static RefList *read_reflections_from_file(FILE *fh, char **sym)
/* We are now in the notes region */
do {
- char line[1024];
rval = fgets(line, 1023, fh);
if ( rval == NULL ) continue;
chomp(line);
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c
index 6c716fda..3dc8abcd 100644
--- a/libcrystfel/src/stream.c
+++ b/libcrystfel/src/stream.c
@@ -240,7 +240,7 @@ static RefList *read_stream_reflections_2_3(Stream *st)
char line[1024];
signed int h, k, l;
float intensity, sigma, fs, ss, pk, bg;
- char pn[32];
+ char pname[32];
int r;
rval = fgets(line, 1023, st->fh);
@@ -252,7 +252,7 @@ static RefList *read_stream_reflections_2_3(Stream *st)
r = sscanf(line, "%i %i %i %f %f %f %f %f %f %s",
&h, &k, &l, &intensity, &sigma, &pk, &bg,
- &fs, &ss, pn);
+ &fs, &ss, pname);
if ( (r != 10) && (!first) ) {
reflist_free(out);
@@ -664,12 +664,12 @@ int stream_write_chunk(Stream *st, const struct image *i,
if ( i->detgeom != NULL ) {
- int j;
+ int pn;
double tclen = 0.0;
- for ( j=0; j<i->detgeom->n_panels; j++ ) {
- tclen += i->detgeom->panels[j].cnz
- * i->detgeom->panels[j].pixel_pitch;
+ for ( pn=0; pn<i->detgeom->n_panels; pn++ ) {
+ tclen += i->detgeom->panels[pn].cnz
+ * i->detgeom->panels[pn].pixel_pitch;
}
fprintf(st->fh, "average_camera_length = %f m\n",
tclen / i->detgeom->n_panels);
@@ -814,8 +814,8 @@ static void read_crystal(Stream *st, struct image *image,
}
if ( strncmp(line, "num_saturated_reflections = ", 28) == 0 ) {
- int n = atoi(line+28);
- crystal_set_num_saturated_reflections(cr, n);
+ int nsat = atoi(line+28);
+ crystal_set_num_saturated_reflections(cr, nsat);
}
if ( sscanf(line, "diffraction_resolution_limit = %f nm^-1",
diff --git a/libcrystfel/src/thread-pool.c b/libcrystfel/src/thread-pool.c
index 7860d698..0951fcc6 100644
--- a/libcrystfel/src/thread-pool.c
+++ b/libcrystfel/src/thread-pool.c
@@ -86,11 +86,11 @@ static void *task_worker(void *pargsv)
{
struct worker_args *w = pargsv;
struct task_queue *q = w->tq;
- int *cookie;
+ int *cookie_slot;
- cookie = malloc(sizeof(int));
- *cookie = w->id;
- pthread_setspecific(status_label_key, cookie);
+ cookie_slot = malloc(sizeof(int));
+ *cookie_slot = w->id;
+ pthread_setspecific(status_label_key, cookie_slot);
free(w);
@@ -129,7 +129,7 @@ static void *task_worker(void *pargsv)
} while ( 1 );
- free(cookie);
+ free(cookie_slot);
return NULL;
}
diff --git a/src/ambigator.c b/src/ambigator.c
index 02252cd7..a7ec0eae 100644
--- a/src/ambigator.c
+++ b/src/ambigator.c
@@ -1056,7 +1056,7 @@ int main(int argc, char *argv[])
int n_dif;
struct flist **crystals;
Stream *st;
- int i;
+ int j;
int *assignments;
int *orig_assignments;
gsl_rng *rng;
@@ -1362,6 +1362,7 @@ int main(int argc, char *argv[])
if ( start_ass_fn != NULL ) {
FILE *fh;
+ int i;
fh = fopen(start_ass_fn, "r");
if ( fh == NULL ) {
ERROR("Failed to open '%s'\n", start_ass_fn);
@@ -1387,13 +1388,14 @@ int main(int argc, char *argv[])
free(start_ass_fn);
} else {
+ int i;
for ( i=0; i<n_crystals; i++ ) {
assignments[i] = (random_flat(rng, 1.0) > 0.5);
}
}
- for ( i=0; i<n_crystals; i++ ) {
- orig_assignments[i] = assignments[i];
+ for ( j=0; j<n_crystals; j++ ) {
+ orig_assignments[j] = assignments[j];
}
if ( fg_graph_fn != NULL ) {
@@ -1415,16 +1417,16 @@ int main(int argc, char *argv[])
}
STATUS("Mean number of correlations per crystal: %.1f\n", mean_nac);
- for ( i=0; i<n_crystals; i++ ) {
- free(crystals[i]->s);
- free(crystals[i]->i);
- free(crystals[i]->s_reidx);
- free(crystals[i]->i_reidx);
- free(crystals[i]);
+ for ( j=0; j<n_crystals; j++ ) {
+ free(crystals[j]->s);
+ free(crystals[j]->i);
+ free(crystals[j]->s_reidx);
+ free(crystals[j]->i_reidx);
+ free(crystals[j]);
}
free(crystals);
- for ( i=0; i<n_iter; i++ ) {
+ for ( j=0; j<n_iter; j++ ) {
detwin(ccs, n_crystals, assignments, fgfh, crystals);
}
@@ -1442,6 +1444,7 @@ int main(int argc, char *argv[])
if ( fh == NULL ) {
ERROR("Failed to open '%s'\n", end_ass_fn);
} else {
+ int i;
for ( i=0; i<n_crystals; i++ ) {
fprintf(fh, "%i\n", assignments[i]);
}
@@ -1450,8 +1453,8 @@ int main(int argc, char *argv[])
}
n_dif = 0;
- for ( i=0; i<n_crystals; i++ ) {
- if ( orig_assignments[i] != assignments[i] ) n_dif++;
+ for ( j=0; j<n_crystals; j++ ) {
+ if ( orig_assignments[j] != assignments[j] ) n_dif++;
}
STATUS("%i assignments are different from their starting values.\n",
n_dif);
diff --git a/src/cell_tool.c b/src/cell_tool.c
index 8ed674f9..dbd3544c 100644
--- a/src/cell_tool.c
+++ b/src/cell_tool.c
@@ -191,7 +191,7 @@ static int all_rings(UnitCell *cell, SymOpList *sym, double mres)
RefList *list;
int i, n;
RefListIterator *iter;
- Reflection *refl;
+ Reflection *ring;
struct sortmerefl *sortus;
cell_get_cartesian(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz);
@@ -235,19 +235,19 @@ static int all_rings(UnitCell *cell, SymOpList *sym, double mres)
sortus = malloc(n*sizeof(struct sortmerefl));
i = 0;
- for ( refl = first_refl(list, &iter);
- refl != NULL;
- refl = next_refl(refl, iter) )
+ for ( ring = first_refl(list, &iter);
+ ring != NULL;
+ ring = next_refl(ring, iter) )
{
- signed int h, k, l;
+ signed int rh, rk, rl;
- get_indices(refl, &h, &k, &l);
+ get_indices(ring, &rh, &rk, &rl);
- sortus[i].h = h;
- sortus[i].k = k;
- sortus[i].l = l;
- sortus[i].resolution = 2.0*resolution(cell, h, k, l); /* one over d */
- sortus[i].multi = get_redundancy(refl);
+ sortus[i].h = rh;
+ sortus[i].k = rk;
+ sortus[i].l = rl;
+ sortus[i].resolution = 2.0*resolution(cell, rh, rk, rl); /* one over d */
+ sortus[i].multi = get_redundancy(ring);
i++;
}
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c
index 159d1bc2..dbf949cd 100644
--- a/src/crystfel_gui.c
+++ b/src/crystfel_gui.c
@@ -1081,7 +1081,7 @@ int main(int argc, char *argv[])
if ( load_result == 0 ) {
DataTemplate *dtempl;
- GtkAction *w;
+ GtkAction *act;
proj.cur_frame = 0;
if ( proj.geom_filename != NULL ) {
@@ -1103,20 +1103,20 @@ int main(int argc, char *argv[])
stream_close(st);
}
- w = gtk_ui_manager_get_action(proj.ui, "/mainwindow/view/centre");
- gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(w),
+ act = gtk_ui_manager_get_action(proj.ui, "/mainwindow/view/centre");
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act),
proj.show_centre);
- w = gtk_ui_manager_get_action(proj.ui, "/mainwindow/view/peaks");
- gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(w),
+ act = gtk_ui_manager_get_action(proj.ui, "/mainwindow/view/peaks");
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act),
proj.show_peaks);
- w = gtk_ui_manager_get_action(proj.ui, "/mainwindow/view/refls");
- gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(w),
+ act = gtk_ui_manager_get_action(proj.ui, "/mainwindow/view/refls");
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act),
proj.show_refls);
- w = gtk_ui_manager_get_action(proj.ui, "/mainwindow/view/labelrefls");
- gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(w),
+ act = gtk_ui_manager_get_action(proj.ui, "/mainwindow/view/labelrefls");
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act),
proj.label_refls);
update_imageview(&proj);
diff --git a/src/diffraction-gpu.c b/src/diffraction-gpu.c
index 7829d9da..97badc36 100644
--- a/src/diffraction-gpu.c
+++ b/src/diffraction-gpu.c
@@ -391,7 +391,7 @@ struct gpu_context *setup_gpu(int no_sfac,
size_t flags_size;
float *flags_ptr;
size_t maxwgsize;
- int i;
+ int iplat;
int have_ctx = 0;
char cflags[512] = "";
char *insert_stuff = NULL;
@@ -409,10 +409,10 @@ struct gpu_context *setup_gpu(int no_sfac,
}
/* Find a GPU platform in the list */
- for ( i=0; i<nplat; i++ ) {
+ for ( iplat=0; iplat<nplat; iplat++ ) {
prop[0] = CL_CONTEXT_PLATFORM;
- prop[1] = (cl_context_properties)platforms[i];
+ prop[1] = (cl_context_properties)platforms[iplat];
prop[2] = 0;
gctx = malloc(sizeof(*gctx));
@@ -430,7 +430,8 @@ struct gpu_context *setup_gpu(int no_sfac,
return NULL;
}
} else {
- STATUS("Using OpenCL platform %i (%i total)\n", i, nplat);
+ STATUS("Using OpenCL platform %i (%i total)\n",
+ iplat, nplat);
have_ctx = 1;
break;
}
@@ -454,10 +455,12 @@ struct gpu_context *setup_gpu(int no_sfac,
intensities_size = IDIM*IDIM*IDIM*sizeof(cl_float);
intensities_ptr = malloc(intensities_size);
if ( intensities != NULL ) {
+ int i;
for ( i=0; i<IDIM*IDIM*IDIM; i++ ) {
intensities_ptr[i] = intensities[i];
}
} else {
+ int i;
for ( i=0; i<IDIM*IDIM*IDIM; i++ ) {
intensities_ptr[i] = 100.0; /* Does nothing */
}
@@ -522,10 +525,12 @@ struct gpu_context *setup_gpu(int no_sfac,
flags_size = IDIM*IDIM*IDIM*sizeof(cl_float);
flags_ptr = malloc(flags_size);
if ( flags != NULL ) {
+ int i;
for ( i=0; i<IDIM*IDIM*IDIM; i++ ) {
flags_ptr[i] = flags[i];
}
} else {
+ int i;
for ( i=0; i<IDIM*IDIM*IDIM; i++ ) {
flags_ptr[i] = 1.0;
}
diff --git a/src/gui_backend_slurm.c b/src/gui_backend_slurm.c
index 801921ea..aeabad3d 100644
--- a/src/gui_backend_slurm.c
+++ b/src/gui_backend_slurm.c
@@ -166,15 +166,15 @@ static double indexing_progress(struct slurm_job *job, int *running)
} else {
- int i;
+ int ijob;
int n_proc = 0;
- for ( i=0; i<job->n_blocks; i++ ) {
+ for ( ijob=0; ijob<job->n_blocks; ijob++ ) {
char tmp[128];
char *stderr_filename;
- snprintf(tmp, 127, "stderr-%i.log", i);
+ snprintf(tmp, 127, "stderr-%i.log", ijob);
stderr_filename = relative_to_cwd(job->workdir, tmp);
n_proc += read_number_processed(stderr_filename);
diff --git a/src/gui_project.c b/src/gui_project.c
index 7141fcb8..952bbbe6 100644
--- a/src/gui_project.c
+++ b/src/gui_project.c
@@ -891,7 +891,7 @@ int load_project(struct crystfelproject *proj)
int save_project(struct crystfelproject *proj)
{
- int i;
+ int ibackend, iresult, iframe;
FILE *fh;
fh = fopen("crystfel.project", "w");
@@ -986,9 +986,9 @@ int save_project(struct crystfelproject *proj)
fprintf(fh, "indexing.backend %s\n",
proj->backends[proj->indexing_backend_selected].name);
- for ( i=0; i<proj->n_backends; i++ ) {
+ for ( ibackend=0; ibackend<proj->n_backends; ibackend++ ) {
struct crystfel_backend *be;
- be = &proj->backends[i];
+ be = &proj->backends[ibackend];
be->write_indexing_opts(be->indexing_opts_priv, fh);
}
@@ -1064,9 +1064,9 @@ int save_project(struct crystfelproject *proj)
}
fprintf(fh, "ambi.backend %s\n",
proj->backends[proj->ambi_backend_selected].name);
- for ( i=0; i<proj->n_backends; i++ ) {
+ for ( ibackend=0; ibackend<proj->n_backends; ibackend++ ) {
struct crystfel_backend *be;
- be = &proj->backends[i];
+ be = &proj->backends[ibackend];
be->write_ambi_opts(be->ambi_opts_priv, fh);
}
if ( proj->ambi_new_job_title != NULL ) {
@@ -1109,9 +1109,9 @@ int save_project(struct crystfelproject *proj)
fprintf(fh, "merging.backend %s\n",
proj->backends[proj->merging_backend_selected].name);
- for ( i=0; i<proj->n_backends; i++ ) {
+ for ( ibackend=0; ibackend<proj->n_backends; ibackend++ ) {
struct crystfel_backend *be;
- be = &proj->backends[i];
+ be = &proj->backends[ibackend];
be->write_merging_opts(be->merging_opts_priv, fh);
}
if ( proj->merging_new_job_title != NULL ) {
@@ -1134,33 +1134,33 @@ int save_project(struct crystfelproject *proj)
fprintf(fh, "label_refls %i\n", proj->label_refls);
fprintf(fh, "-----\n");
- for ( i=0; i<proj->n_results; i++ ) {
+ for ( iresult=0; iresult<proj->n_results; iresult++ ) {
int j;
- fprintf(fh, "Result %s\n", proj->results[i].name);
- for ( j=0; j<proj->results[i].n_streams; j++ ) {
+ fprintf(fh, "Result %s\n", proj->results[iresult].name);
+ for ( j=0; j<proj->results[iresult].n_streams; j++ ) {
fprintf(fh, " Stream %s\n",
- proj->results[i].streams[j]);
+ proj->results[iresult].streams[j]);
}
if ( strcmp(selected_result(proj),
- proj->results[i].name) == 0 )
+ proj->results[iresult].name) == 0 )
{
fprintf(fh, " Selected\n");
}
}
- for ( i=0; i<proj->n_merge_results; i++ ) {
- fprintf(fh, "Result %s\n", proj->merge_results[i].name);
- fprintf(fh, " HKL %s\n", proj->merge_results[i].hkl);
- fprintf(fh, " HKL1 %s\n", proj->merge_results[i].hkl1);
- fprintf(fh, " HKL2 %s\n", proj->merge_results[i].hkl2);
+ for ( iresult=0; iresult<proj->n_merge_results; iresult++ ) {
+ fprintf(fh, "Result %s\n", proj->merge_results[iresult].name);
+ fprintf(fh, " HKL %s\n", proj->merge_results[iresult].hkl);
+ fprintf(fh, " HKL1 %s\n", proj->merge_results[iresult].hkl1);
+ fprintf(fh, " HKL2 %s\n", proj->merge_results[iresult].hkl2);
}
fprintf(fh, "-----\n");
- for ( i=0; i<proj->n_frames; i++ ) {
- if ( proj->events[i] != NULL ) {
+ for ( iframe=0; iframe<proj->n_frames; iframe++ ) {
+ if ( proj->events[iframe] != NULL ) {
fprintf(fh, "%s %s\n",
- proj->filenames[i], proj->events[i]);
+ proj->filenames[iframe], proj->events[iframe]);
} else {
- fprintf(fh, "%s\n", proj->filenames[i]);
+ fprintf(fh, "%s\n", proj->filenames[iframe]);
}
}
diff --git a/src/partialator.c b/src/partialator.c
index 249eda93..ca0249ce 100644
--- a/src/partialator.c
+++ b/src/partialator.c
@@ -1014,7 +1014,7 @@ int main(int argc, char *argv[])
SymOpList *amb;
SymOpList *w_sym;
int nthreads = 1;
- int i;
+ int istream, icmd, icryst, itn;
int n_iter = 10;
RefList *full;
int n_images = 0;
@@ -1104,8 +1104,8 @@ int main(int argc, char *argv[])
};
cmdline[0] = '\0';
- for ( i=1; i<argc; i++ ) {
- strncat(cmdline, argv[i], 1023-strlen(cmdline));
+ for ( icmd=1; icmd<argc; icmd++ ) {
+ strncat(cmdline, argv[icmd], 1023-strlen(cmdline));
strncat(cmdline, " ", 1023-strlen(cmdline));
}
@@ -1471,11 +1471,11 @@ int main(int argc, char *argv[])
}
audit_info = NULL;
- for ( i=0; i<stream_list.n; i++ ) {
+ for ( istream=0; istream<stream_list.n; istream++ ) {
- Stream *st = stream_open_for_read(stream_list.filenames[i]);
+ Stream *st = stream_open_for_read(stream_list.filenames[istream]);
if ( st == NULL ) {
- ERROR("Couldn't open %s\n", stream_list.filenames[i]);
+ ERROR("Couldn't open %s\n", stream_list.filenames[istream]);
return 1;
}
@@ -1605,9 +1605,9 @@ int main(int argc, char *argv[])
if ( sparams_fh != NULL ) fclose(sparams_fh);
STATUS("Initial partiality calculation...\n");
- for ( i=0; i<n_crystals; i++ ) {
+ for ( icryst=0; icryst<n_crystals; icryst++ ) {
- Crystal *cr = crystals[i];
+ Crystal *cr = crystals[icryst];
update_predictions(cr);
/* Polarisation correction requires kpred values */
@@ -1647,13 +1647,13 @@ int main(int argc, char *argv[])
}
/* Iterate */
- for ( i=0; i<n_iter; i++ ) {
+ for ( itn=0; itn<n_iter; itn++ ) {
- STATUS("Scaling and refinement cycle %i of %i\n", i+1, n_iter);
+ STATUS("Scaling and refinement cycle %i of %i\n", itn+1, n_iter);
if ( !no_pr ) {
refine_all(crystals, n_crystals, full, nthreads, pmodel,
- i+1, no_logs, sym, amb, scaleflags);
+ itn+1, no_logs, sym, amb, scaleflags);
}
/* Create new reference if needed */
@@ -1674,13 +1674,13 @@ int main(int argc, char *argv[])
show_all_residuals(crystals, n_crystals, full, no_free);
if ( do_write_logs ) {
- write_pgraph(full, crystals, n_crystals, i+1, "");
+ write_pgraph(full, crystals, n_crystals, itn+1, "");
}
if ( output_everycycle ) {
char tmp[1024];
- snprintf(tmp, 1024, "iter%.2d_%s", i+1, outfile);
+ snprintf(tmp, 1024, "iter%.2d_%s", itn+1, outfile);
/* Output results */
STATUS("Writing overall results to %s\n", tmp);
@@ -1745,6 +1745,7 @@ int main(int argc, char *argv[])
/* Output custom split results */
if ( csplit != NULL ) {
+ int i;
for ( i=0; i<csplit->n_datasets; i++ ) {
write_custom_split(csplit, i, crystals, n_crystals,
pmodel, min_measurements, push_res,
@@ -1754,15 +1755,15 @@ int main(int argc, char *argv[])
/* Clean up */
gsl_rng_free(rng);
- for ( i=0; i<n_crystals; i++ ) {
- struct image *image = crystal_get_image(crystals[i]);
+ for ( icryst=0; icryst<n_crystals; icryst++ ) {
+ struct image *image = crystal_get_image(crystals[icryst]);
spectrum_free(image->spectrum);
- reflist_free(crystal_get_reflections(crystals[i]));
+ reflist_free(crystal_get_reflections(crystals[icryst]));
free(image->filename);
free(image->ev);
free(image);
- cell_free(crystal_get_cell(crystals[i]));
- crystal_free(crystals[i]);
+ cell_free(crystal_get_cell(crystals[icryst]));
+ crystal_free(crystals[icryst]);
}
free_contribs(full);
reflist_free(full);
diff --git a/src/pattern_sim.c b/src/pattern_sim.c
index 7098869d..b6414aa1 100644
--- a/src/pattern_sim.c
+++ b/src/pattern_sim.c
@@ -481,7 +481,7 @@ int main(int argc, char *argv[])
int config_gpu = 0;
int config_random = 0;
char *powder_fn = NULL;
- char *filename = NULL;
+ char *cell_filename = NULL;
char *grad_str = NULL;
char *outfile = NULL;
char *geometry = NULL;
@@ -599,7 +599,7 @@ int main(int argc, char *argv[])
break;
case 'p' :
- filename = strdup(optarg);
+ cell_filename = strdup(optarg);
break;
case 'o' :
@@ -761,8 +761,8 @@ int main(int argc, char *argv[])
return 1;
}
- if ( filename == NULL ) {
- filename = strdup("molecule.pdb");
+ if ( cell_filename == NULL ) {
+ cell_filename = strdup("molecule.pdb");
}
if ( outfile == NULL ) {
@@ -844,7 +844,7 @@ int main(int argc, char *argv[])
free(spectrum_str);
/* Load unit cell */
- input_cell = load_cell_from_file(filename);
+ input_cell = load_cell_from_file(cell_filename);
if ( input_cell == NULL ) {
exit(1);
}
@@ -988,7 +988,7 @@ int main(int argc, char *argv[])
do {
int na, nb, nc;
- double a, b, c, d;
+ double a, b, c, dis;
UnitCell *cell;
int err = 0;
int pi;
@@ -1094,7 +1094,7 @@ int main(int argc, char *argv[])
}
- cell_get_parameters(cell, &a, &b, &c, &d, &d, &d);
+ cell_get_parameters(cell, &a, &b, &c, &dis, &dis, &dis);
STATUS("Particle size = %i x %i x %i"
" ( = %5.2f x %5.2f x %5.2f nm)\n",
na, nb, nc, na*a/1.0e-9, nb*b/1.0e-9, nc*c/1.0e-9);
@@ -1148,22 +1148,22 @@ int main(int argc, char *argv[])
if ( !config_noimages ) {
- char filename[1024];
+ char h5filename[1024];
if ( n_images != 1 ) {
- snprintf(filename, 1023, "%s-%i.h5",
+ snprintf(h5filename, 1023, "%s-%i.h5",
outfile, number);
} else {
- strncpy(filename, outfile, 1023);
+ strncpy(h5filename, outfile, 1023);
}
number++;
/* Write the output file */
- image_write(image, dtempl, filename);
+ image_write(image, dtempl, h5filename);
/* Add some pattern_sim-specific metadata */
- add_metadata(filename, orientation, cell);
+ add_metadata(h5filename, orientation, cell);
}
@@ -1190,7 +1190,7 @@ skip:
cell_free(input_cell);
free(intensities);
free(outfile);
- free(filename);
+ free(cell_filename);
free(sym_str);
free_symoplist(sym);
diff --git a/src/process_hkl.c b/src/process_hkl.c
index b16146e3..be1c95d4 100644
--- a/src/process_hkl.c
+++ b/src/process_hkl.c
@@ -604,7 +604,7 @@ int main(int argc, char *argv[])
.disable = 0};
char *rval;
int min_measurements = 2;
- int r;
+ int merge_r;
int start_after = 0;
int stop_after = 0;
double min_snr = -INFINITY;
@@ -876,13 +876,13 @@ int main(int argc, char *argv[])
if ( config_scale ) twopass = 1;
hist_i = 0;
- r = merge_all(&stream_list, model, NULL, sym,
- &hist_vals, hist_h, hist_k, hist_l,
- &hist_i, polarisation, min_measurements, min_snr,
- max_adu, start_after, stop_after, min_res, push_res,
- min_cc, config_scale, flag_even_odd, stat_output);
+ merge_r = merge_all(&stream_list, model, NULL, sym,
+ &hist_vals, hist_h, hist_k, hist_l,
+ &hist_i, polarisation, min_measurements, min_snr,
+ max_adu, start_after, stop_after, min_res, push_res,
+ min_cc, config_scale, flag_even_odd, stat_output);
fprintf(stderr, "\n");
- if ( r ) {
+ if ( merge_r ) {
ERROR("Error while reading stream.\n");
return 1;
}
diff --git a/src/render_hkl.c b/src/render_hkl.c
index c47a2c4d..00992d71 100644
--- a/src/render_hkl.c
+++ b/src/render_hkl.c
@@ -758,7 +758,6 @@ int main(int argc, char *argv[])
int config_colkey = 0;
int config_zawhinge = 0;
char *cellfile = NULL;
- int r = 0;
double boost = 1.0;
char *sym_str = NULL;
char *sym_str_fromfile = NULL;
@@ -1049,5 +1048,5 @@ int main(int argc, char *argv[])
reflist_free(list);
if ( outfile != NULL ) free(outfile);
- return r;
+ return 0;
}
diff --git a/src/whirligig.c b/src/whirligig.c
index 611825ba..20fcfa40 100644
--- a/src/whirligig.c
+++ b/src/whirligig.c
@@ -485,12 +485,14 @@ static void add_to_window(struct image *cur, struct window *win,
if ( pos >= win->ws ) {
- int sf, i;
+ int sf, iwin;
sf = (pos - win->ws) + 1;
if ( series_fills_window(win) ) {
+ int i;
+
win->ws += sf;
win->img = realloc(win->img,
win->ws*sizeof(struct image));
@@ -513,6 +515,8 @@ static void add_to_window(struct image *cur, struct window *win,
} else {
+ int iser;
+
pos -= sf;
if ( sf > win->join_ptr ) {
@@ -534,29 +538,29 @@ static void add_to_window(struct image *cur, struct window *win,
sf = win->ws;
}
- for ( i=0; i<sf; i++ ) {
- if ( win->img[i].serial != 0 ) {
- free_all_crystals(&win->img[i]);
+ for ( iser=0; iser<sf; iser++ ) {
+ if ( win->img[iser].serial != 0 ) {
+ free_all_crystals(&win->img[iser]);
}
}
memmove(win->img, win->img+sf,
(win->ws-sf)*sizeof(struct image));
- for ( i=0; i<MAX_SER; i++ ) {
- memmove(win->ser[i], win->ser[i]+sf,
+ for ( iser=0; iser<MAX_SER; iser++ ) {
+ memmove(win->ser[iser], win->ser[iser]+sf,
(win->ws-sf)*sizeof(signed int));
- memmove(win->mat[i], win->mat[i]+sf,
+ memmove(win->mat[iser], win->mat[iser]+sf,
(win->ws-sf)*sizeof(IntegerMatrix *));
}
}
- for ( i=0; i<sf; i++ ) {
+ for ( iwin=0; iwin<sf; iwin++ ) {
int j;
- win->img[win->ws-sf+i].serial = 0;
+ win->img[win->ws-sf+iwin].serial = 0;
for ( j=0; j<MAX_SER; j++ ) {
- win->ser[j][win->ws-sf+i] = -1;
- win->mat[j][win->ws-sf+i] = NULL;
+ win->ser[j][win->ws-sf+iwin] = -1;
+ win->mat[j][win->ws-sf+iwin] = NULL;
}
}