After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 761262 - BSD libc doesn't support %m outside of syslog
BSD libc doesn't support %m outside of syslog
Status: RESOLVED FIXED
Product: gnome-online-accounts
Classification: Core
Component: general
unspecified
Other NetBSD
: Normal normal
: ---
Assigned To: GNOME Online Accounts maintainer(s)
GNOME Online Accounts maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2016-01-28 17:02 UTC by coypu
Modified: 2016-03-14 18:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch that fixes my build error (925 bytes, patch)
2016-01-28 17:02 UTC, coypu
needs-work Details | Review
Updated patch as requested (1.72 KB, patch)
2016-02-12 17:06 UTC, coypu
needs-work Details | Review
alarm, daemon: Avoid using %m for errors (1.95 KB, patch)
2016-03-14 18:52 UTC, Debarshi Ray
committed Details | Review

Description coypu 2016-01-28 17:02:20 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.
Comment 1 coypu 2016-01-28 17:15:02 UTC
I've been informed that without using -Wall, this doesn't cause build problems, but will silently fail to function properly.
Comment 2 n54@gmx.com 2016-01-28 17:59:50 UTC
%m is GNU extension and it's fatal for NetBSD (unless in syslog(3)).

I confirm the portability issue.
Comment 3 Debarshi Ray 2016-02-12 13:56:34 UTC
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.
Comment 4 coypu 2016-02-12 17:06:42 UTC
Created attachment 321008 [details] [review]
Updated patch as requested
Comment 5 coypu 2016-02-12 17:08:01 UTC
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.
Comment 6 Debarshi Ray 2016-03-14 18:51:49 UTC
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.
Comment 7 Debarshi Ray 2016-03-14 18:52:47 UTC
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.