diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ambigator.c | 7 | ||||
-rw-r--r-- | src/partial_sim.c | 9 | ||||
-rw-r--r-- | src/partialator.c | 5 | ||||
-rw-r--r-- | src/pattern_sim.c | 7 |
4 files changed, 20 insertions, 8 deletions
diff --git a/src/ambigator.c b/src/ambigator.c index f7837721..3df66f3b 100644 --- a/src/ambigator.c +++ b/src/ambigator.c @@ -1254,8 +1254,11 @@ int main(int argc, char *argv[]) return 1; } - fread(&seed, sizeof(seed), 1, fh); - gsl_rng_set(rng, seed); + if ( fread(&seed, sizeof(seed), 1, fh) == 1 ) { + gsl_rng_set(rng, seed); + } else { + ERROR("Failed to seed RNG\n"); + } fclose(fh); } diff --git a/src/partial_sim.c b/src/partial_sim.c index 0482cc91..2f0a0277 100644 --- a/src/partial_sim.c +++ b/src/partial_sim.c @@ -917,10 +917,13 @@ int main(int argc, char *argv[]) for ( i=0; i<n_threads; i++ ) { unsigned long int seed; - - fread(&seed, sizeof(seed), 1, fh); qargs.rngs[i] = gsl_rng_alloc(gsl_rng_mt19937); - gsl_rng_set(qargs.rngs[i], seed); + + if ( fread(&seed, sizeof(seed), 1, fh) == 1 ) { + gsl_rng_set(qargs.rngs[i], seed); + } else { + ERROR("Failed to seed RNG %i\n", i); + } } diff --git a/src/partialator.c b/src/partialator.c index 569145e8..142ca892 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -1018,7 +1018,10 @@ int main(int argc, char *argv[]) ERROR("Failed to open '%s'\n", sparams_fn); return 1; } - fgets(line, 1024, sparams_fh); + if ( fgets(line, 1024, sparams_fh) == NULL ) { + ERROR("Failed to read header from %s\n", sparams_fn); + return 1; + } STATUS("Reading initial scaling factors (G,B) from '%s'\n", sparams_fn); free(sparams_fn); diff --git a/src/pattern_sim.c b/src/pattern_sim.c index fd670c48..a3fea8e3 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -799,9 +799,12 @@ int main(int argc, char *argv[]) FILE *fh; unsigned long int seed; fh = fopen("/dev/urandom", "r"); - fread(&seed, sizeof(seed), 1, fh); + if ( fread(&seed, sizeof(seed), 1, fh) == 1 ) { + gsl_rng_set(rng, seed); + } else { + ERROR("Failed to seed random number generator\n"); + } fclose(fh); - gsl_rng_set(rng, seed); } powder.det = image.det; |