aboutsummaryrefslogtreecommitdiff
path: root/src/pattern_sim.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-10-23 15:53:19 +0200
committerThomas White <taw@physics.org>2017-10-23 16:01:37 +0200
commit45038c42847476ce1aee5b09c47fb330a0108cd6 (patch)
tree3979667c80cacc3bd34d0f59fc905a0d4c0b3d0d /src/pattern_sim.c
parent7b6fa15e761ec0c5ae9010dc21786a1a3dda7076 (diff)
Check return values from fread/fgets
Diffstat (limited to 'src/pattern_sim.c')
-rw-r--r--src/pattern_sim.c7
1 files changed, 5 insertions, 2 deletions
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;