Build portability: enable or disable warnings
David Holmes
David.Holmes at oracle.com
Mon May 16 08:19:45 UTC 2011
Fredrik Öhrström said the following on 05/16/11 17:39:
> 2011-05-13 15:20, Andrew Haley skrev:
>> A recent patch (of mine, as it happens) broke builds on Debian and
>> Gentoo. It was caused by a scanf call:
>>
>> if (sscanf(chars, "%lx-%*lx", &x) == 1)
>>
>> which looks pretty innocuous, but it triggers a warning if -Wformat is
>> turned on:
>
>> There are two ways to fix this: either force -Wformat and
>> -Wformat-security on when building HotSpot or force them off. Either
>> would work, but my vote goes to the former.
>
> I think it is better to fix the underlying complaint of the compiler.
> Thus change the sscanf string to "%lx-%*x"
>
> The compiler is complaining that you over specify the second scanned
> parameter that is going to be thrown away anyway.
This particular issue has already been fixed.
I assumed Andrew was more generally questioning whether to force Wformat
on or off rather than potentially have it vary depending on the compiler
version.
David
More information about the build-dev
mailing list