]> granicus.if.org Git - nethack/commitdiff
last warning fix
authorPatR <rankin@nethack.org>
Tue, 29 Jan 2019 23:27:22 +0000 (15:27 -0800)
committerPatR <rankin@nethack.org>
Tue, 29 Jan 2019 23:27:22 +0000 (15:27 -0800)
Compiler gave four diagnostics about 'seed' being used uninitialized
if 'no_seed' were false, but two of those were alternate suggestions
for how to suppress them.

sys/unix/unixmain.c

index 1d6500b68cf371fdeac5688ba4a5518ba9fa4c21..c800c49197eeddc1ae9763c3a1a6a81c16f386ff 100644 (file)
@@ -768,18 +768,18 @@ error:
 unsigned long
 sys_random_seed()
 {
-    unsigned long seed;
+    unsigned long seed = 0L;
     unsigned long pid = (unsigned long) getpid();
     boolean no_seed = TRUE;
 #ifdef DEV_RANDOM
-    FILE *fptr = NULL;
+    FILE *fptr;
 
     fptr = fopen(DEV_RANDOM, "r");
     if (fptr) {
-        fread(&seed, sizeof(long), 1, fptr);
+        fread(&seed, sizeof long, 1, fptr);
         has_strong_rngseed = TRUE;  /* decl.c */
         no_seed = FALSE;
-        fclose(fptr);
+        (void) fclose(fptr);
     } else {
         /* leaves clue, doesn't exit */
         paniclog("sys_random_seed", "falling back to weak seed");