29 Sep 16:58
[PATCH] replace strerror() usage with threadsafe "%m" format string
From: Alan Jenkins <alan-jenkins <at> tuffmail.co.uk>
Subject: [PATCH] replace strerror() usage with threadsafe "%m" format string
Newsgroups: gmane.linux.hotplug.devel
Date: 2008-09-29 15:01:32 GMT
Subject: [PATCH] replace strerror() usage with threadsafe "%m" format string
Newsgroups: gmane.linux.hotplug.devel
Date: 2008-09-29 15:01:32 GMT
strerror() is not threadsafe. It uses a buffer to build messages of the form
"Unknown error 387689".
syslog() provides a %m format which is equivalent to strerror(errno).
As a GNU extension, this is also accepted by printf and friends.
At least in the current implementation, it is correctly threadsafe.
Signed-off-by: Alan Jenkins <alan-jenkins <at> tuffmail.co.uk>
diff --git a/udev/lib/libudev-ctrl.c b/udev/lib/libudev-ctrl.c
index 7d37074..268ce2d 100644
--- a/udev/lib/libudev-ctrl.c
+++ b/udev/lib/libudev-ctrl.c
@@ -79,7 +79,7 @@ struct udev_ctrl *udev_ctrl_new_from_socket(struct udev *udev, const char *socke
uctrl->sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
if (uctrl->sock < 0) {
- err(udev, "error getting socket: %s\n", strerror(errno));
+ err(udev, "error getting socket: %m\n");
udev_ctrl_unref(uctrl);
return NULL;
}
@@ -101,7 +101,7 @@ int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl)
err= bind(uctrl->sock, (struct sockaddr *)&uctrl->saddr, uctrl->addrlen);
if (err < 0) {
- err(uctrl->udev, "bind failed: %s\n", strerror(errno));
+ err(uctrl->udev, "bind failed: %m\n");
return err;
}
(Continue reading)
RSS Feed