tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: "%m" formatting code and "syslog like"
Hi Ian
On 30/08/2018 19:11, Ian Bruene wrote:
I am one of the developers on NTPsec and we are getting warnings on
NetBSD 8.0 in the form:
../../ntpd/ntp_io.c:1962:14: warning: %m is only allowed in syslog(3)
like functions [-Wformat=]
This feature appears to have been added here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67956
From googling I have been able to find the flag that is set for this
warning to be suppressed, but we have not been able to find any
documentation on how to properly identify a function as "syslog like"
I have a similar problem with dhcpcd where I have a custom logging
function. Here's the comment and workaround I have.
/*
* NetBSD's gcc has been modified to check for the non standard %m in
printf
* like functions and warn noisily about it that they should be marked as
* syslog like instead.
* This is all well and good, but our logger also goes via vfprintf and
* when marked as a sysloglike funcion, gcc will then warn us that the
* function should be printflike instead!
* This creates an infinte loop of gcc warnings.
* Until NetBSD solves this issue, we have to disable a gcc diagnostic
* for our fully standards compliant code in the logger function.
*/
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 &&
__GNUC_MINOR__ > 5))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-format-attribute"
#endif
__printflike(2, 0) static void
vlogmessage(int pri, const char *fmt, va_list args)
{
...
}
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.
Roy
Home |
Main Index |
Thread Index |
Old Index