aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-07-21 15:22:12 +0200
committerThomas White <taw@physics.org>2021-07-22 11:22:18 +0200
commit13d65b9785d1557e29f5f06871d01bad8e76e44c (patch)
treedfd9c52a80639882695eb63b0c87af06ebcbb29d /libcrystfel
parentd5cf0404a08253f52c6ddf3f6d80e694b9de4e7a (diff)
Clean up shadowed variables
Diffstat (limited to 'libcrystfel')
-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
9 files changed, 52 insertions, 54 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;
}