Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: HEADS UP: new %m check for printf-alike functions



On 23/10/2015 09:09, Thomas Klausner wrote:
> There is a format string modifier "%m" (printing strerror(errno))
> that's supported by syslog(), and some versions of *printf(), e.g. in
> glibc.
> 
> Compiling on -current now warns when it finds this modifier in string
> passed to a function that's not known to support this.
> 
> If you stumble over this, do something similar to:
> 
> printf("%m");
> 
> ->
> 
> printf("%s", strerror(errno));

The warning is only for compiling with gcc from -current, not clang or
gcc from pkgsrc.

Also, any program that compiles with gcc from -current and the
-Wmissing-format-attribute will be warned that they should use the new
syslog format attribute. This is all well and good, but when changed to
actually use the new syslog atttribute we are then warned that we should
use the printf attribute instead! Which is a nice infinite warning loop
which should be addressed - this is true for the logger function in
dhcpcd:common.c at least.

I know -Wmissing-format-attribute isn't in our current WARNS? CFLAGS but
I feel that if we want to promote good %m usage the gcc warnings our
change should at least work correctly. If the warnings cannot easily be
fixed, we can always move %m from syslog() to printf() which will reduce
libc codesize and complexity (same is true for other programs which wrap
syslog()).

Roy


Home | Main Index | Thread Index | Old Index