tech-userlevel archive

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

Re: "%m" formatting code and "syslog like"



On 31/08/2018 13:29, Martin Husemann wrote:
On Fri, Aug 31, 2018 at 01:23:51PM +0100, Roy Marples wrote:
This allows dhcpcd to be compiled with full warnings, but I've disabled the
check for specific functions. This is actually self defeating as it's just
the kind of function the warnings are for, but as best I can tell it's
impossible to have your own logging function unless you either live with the
warnings or disable them - neither is a good solution really.

Why would this not work?

You do your own logging function and mark it __printflike, then avoid
all (non portable) %m format strings by replacing them with %s and
strerror().

None of the calls use %m or any non portable printf extensions.
It is my own logging function.

The function is currently marked as __printflike.
If I re-enable the warning gcc warns me that it should be marked as __sysloglike .... because it calls syslog. If I change it to __sysloglike then it warns me that it should be __printflike because it also uses vfprintf.

Feel free to write a patch or fix gcc. I've spent more time on this than I care already, so just happy to disbable the check.

Roy


Home | Main Index | Thread Index | Old Index