From: nethack.rankin Date: Thu, 12 Jan 2012 04:01:08 +0000 (+0000) Subject: suppress makedefs.c diagnostic (trunk only) X-Git-Tag: MOVE2GIT~90 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5506be3b911843a59fa3dda1cd6d9c96ab7f5fc4;p=nethack suppress makedefs.c diagnostic (trunk only) 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. --- diff --git a/util/makedefs.c b/util/makedefs.c index 602f42d22..e3d652b7e 100644 --- a/util/makedefs.c +++ b/util/makedefs.c @@ -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__ /*