fix hotspot build failures with -D_FORTIFY_SOURCE=2 and -Wformat=1
Kelly O'Hair
Kelly.Ohair at Sun.COM
Tue Dec 2 17:21:18 PST 2008
David Holmes - Sun Microsystems wrote:
> Hi Matthias,
>
> Can't we get rid of all the dummy variables here:
>
> count = sscanf(s,"%c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu",
> - &idummy, &idummy, &idummy, &idummy, &idummy, &idummy,
> + &cdummy, &idummy, &idummy, &idummy, &idummy, &idummy,
> &ldummy, &ldummy, &ldummy, &ldummy, &ldummy,
> &user_time, &sys_time);
>
> by using the %*d %*c format specifiers to parse but not store the value.
>
> And here:
>
> - ::write(defaultStream::output_fd(), s, (int)strlen(s));
> + ssize_t rv = ::write(defaultStream::output_fd(), s, (int)strlen(s));
>
> if we are ignoring the return value anyway (which might be the real
> error here!) wouldn't a cast to void be a cleaner fix?
I tend to agree on the (void) cast, and seems like we run the risk of a
'local variable assigned to but not used' warning... or do any C/C++ compilers do that?
-kto
>
> Just a thought.
>
> David Holmes
>
> Matthias Klose said the following on 12/03/08 03:12:
>> These options are the default in IntrepidIbex (Ubuntu 8.10). Find
>> attached two
>> patches to fix these warnings, plus one patch to turn off the
>> -Wformat=1 warnings.
>>
>> Matthias
>>
More information about the distro-pkg-dev
mailing list