From 5506be3b911843a59fa3dda1cd6d9c96ab7f5fc4 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Thu, 12 Jan 2012 04:01:08 +0000 Subject: [PATCH] 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. --- util/makedefs.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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__ /*