[Bug libc/17089] New: error.c triggers -Wformat-extra-args
dmacks at netspace dot org
sourceware-bugzilla@sourceware.org
Wed Jun 25 18:58:00 GMT 2014
https://sourceware.org/bugzilla/show_bug.cgi?id=17089
Bug ID: 17089
Summary: error.c triggers -Wformat-extra-args
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
Assignee: unassigned at sourceware dot org
Reporter: dmacks at netspace dot org
CC: drepper.fsp at gmail dot com
Building gettext-0.19.1 (which embeds copies of gnulib, which has error.c with
code from libc), on OS X 10.8, which uses the clang compiler (via XCode-5.1),
gives:
clang -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I.. -I../intl -I../intl
-DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1 -I/sw/include -Os -c -o
error.o error.c
error.c:381:12: warning: data argument not used by format string
[-Wformat-extra-args]
file_name, line_number);
The same construct is still present in misc/error.c in glibc git at line 306
[1]:
#if _LIBC
__fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ",
file_name, line_number);
#else
fprintf (stderr, file_name != NULL ? "%s:%d: " : " ",
file_name, line_number);
#endif
In the case where file_name==NULL, the format-string is " " but file_name and
line_number are still passed. This may not be a functional error [2], but it's
an easy-to-clear warning. Just have whole alternative fprintf() with
appropriate parameters in a conditional if/else block rather than just
conditional on the format-string. Something like:
if (file_name != NULL)
fprintf (stderr, "%s:%d: ", file_name, line_number)
else
fprintf (stderr, " ");
[1]
http://sourceware.org/git/?p=glibc.git;a=blob;f=misc/error.c;h=63bd309f22b7782474b72239ffa70e11a2b4b531;hb=HEAD
[2]
http://stackoverflow.com/questions/3578970/passing-too-many-arguments-to-printf
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Glibc-bugs
mailing list