Created attachment 36503 [details] patch According to TOG (http://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html), %m is not a legal formatting character for printf(3) like functions. Some implementations (glibc) accept this formatting character as an extension and expand it to the error string via strerror(3) that errno currently points to. Most other c library implementations do not expand %m. Attached is a patch that makes printf warn when %m is present and adds a "syslog" attribute that accepts %m. I recognize that this is an incompatible change, and I welcome suggestions how to do this in a less intrusive way. I tried to mininize the size of the patch; there are better ways to do this, but require more refactoring.
*** Bug 67957 has been marked as a duplicate of this bug. ***
something is wrong with the bug tracking system, when posting a bug with an attachment as the first post; this is how the dup got created.
The gnu_printf format attribute is specifically supposed to accept %m; you can use -pedantic to disallow it. Targets can override what the printf attribute maps to; see config/i386/msformat-c.c for example; other OSes should do likewise so the correct set of formats for each target is accepted. The desire for a syslog format is bug 15338.
I believe that -pedantic enables other "pedantic" warnings which I don't belive I want. I can add a specific printf format that does not accept %m, but I would still need to add a syslog format that does (and annotate the syslog functions with that instead of printf). Perhaps it is possible to have a separate -W switch that will enable this behavior (warn for %m in printf formats), and add a syslog format that allows %m. I think that we want to encourage people to write portable code, and using %m in printf isn't. My goal is to differentiate between syslog-like functions that support %m and printf-like functions that don't. Is adding a separate -W flag to enable warnings for %m in printf and a syslog format acceptable? I think that non-glibc systems will benefit from that.
There has been some discussion recently of adding -Wformat-pedantic (see bug 67479), which would seem reasonable to me. A syslog format also seems reasonable (but we already have bug 15338 tracking that idea). A special-case option for only this single case of non-portable formats seems more dubious to me.
great, thank you. since this is tracked already you can close it if you want.
Nothing to do here.