GNOME Bugzilla – Bug 761262
BSD libc doesn't support %m outside of syslog
Last modified: 2016-03-14 18:53:29 UTC
Created attachment 319956 [details] [review] Patch that fixes my build error In building this package from pkgsrc on NetBSD/amd64 7.99.25 I've encountered the following error: goadaemon.c:251:7: error: %m is only allowed in syslog(3) like functions [-Werror=format=] g_warning ("Error creating directory %s: %m", path); Open-, Net- and Free- BSD all do not have %m in printf(3), though I can only testify for build problems on NetBSD. it is specific to glibc. The attached patch (slightly different location in the code) allowed me to compile it.
I've been informed that without using -Wall, this doesn't cause build problems, but will silently fail to function properly.
%m is GNU extension and it's fatal for NetBSD (unless in syslog(3)). I confirm the portability issue.
Review of attachment 319956 [details] [review]: Thanks for the patch. Unless you have privacy concerns, it would be nice to have your full name in the author field. ::: src/daemon/goadaemon.c @@ +19,2 @@ #include "config.h" +#include <errno.h> Isn't strerror supposed to be in <string.h>? @@ +262,3 @@ if (g_mkdir_with_parents (path, 0755) != 0) { + g_warning ("Error creating directory %s: %s", path, strerror(errno)); There are two instances of "%m" in src/goaidentity/goaalarm.c too. Might be good to fix those too.
Created attachment 321008 [details] [review] Updated patch as requested
You are correct regarding <string.h>. I don't know why I didn't see any build problems regarding goaalarm.c, I forgot to search for more such instances. Thank you for responding.
Review of attachment 321008 [details] [review]: Thanks for the new patch. Does it for you? I doesn't for me. See below: ::: src/daemon/goadaemon.c @@ +19,2 @@ #include "config.h" +#include <string.h> We still need to #include errno.h for the externally defined errno variable. @@ +262,3 @@ if (g_mkdir_with_parents (path, 0755) != 0) { + g_warning ("Error creating directory %s: %s", path, strerror(errno)); Nitpick: missing space between function name and opening parenthesis. ::: src/goaidentity/goaalarm.c @@ +325,3 @@ if (fd < 0) { + g_debug ("GoaAlarm: could not create timer fd: %s", strerror(errno)); Ditto.
Created attachment 323907 [details] [review] alarm, daemon: Avoid using %m for errors I took the liberty to fix the above issues and pushed. Please let me know if it fixed your problems.