]> granicus.if.org Git - nethack/commitdiff
suppress makedefs.c diagnostic (trunk only)
authornethack.rankin <nethack.rankin>
Thu, 12 Jan 2012 04:01:08 +0000 (04:01 +0000)
committernethack.rankin <nethack.rankin>
Thu, 12 Jan 2012 04:01:08 +0000 (04:01 +0000)
     gcc doesn't complain about using %lx to write out a signed long, but
it does complain about using it to read into a signed long.  Technically
it's right about the latter, so fix this properly rather than just suppress
the message with a cast.

util/makedefs.c

index 602f42d2270e1af76ca472f09b644dec74ac8e3f..e3d652b7e676c3c70eb27a77a98769a25fbf468a 100644 (file)
@@ -1817,7 +1817,16 @@ do_oracles()
 #endif
                if (!(ok = (fpos = ftell(ofp)) >= 0)) break;
                if (!(ok = (fseek(ofp, fpos, SEEK_SET) >= 0))) break;
-               if (!(ok = (fscanf(ofp, "%5lx", &offset) == 1))) break;
+             {
+               /* gcc's format checking issues a warning when using
+                  %lx to read into a signed long, so force unsigned;
+                  casting &offset to unsigned long * works but is iffy */
+               unsigned long uloffset;
+               int itmp = fscanf(ofp, "%5lx", &uloffset);
+
+               offset = (long)uloffset;
+               if (!(ok = (itmp == 1))) break;
+             }
 #ifdef MAC
 # ifdef __MWERKS__
                /*