diff options
author | Alan Jenkins <alan-jenkins@tuffmail.co.uk> | 2008-09-29 16:01:32 +0100 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-09-29 17:06:00 +0200 |
commit | 659353f5a9a52336c41cf595d933311b8dc48937 (patch) | |
tree | 1a12cc4fd2ec90db52a0f586e08a2f49a6ca8306 /udev/lib | |
parent | 5c0f595d91a21b1fba2b9edd89511a072036d0e8 (diff) |
replace strerror() usage with threadsafe "%m" format string
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@tuffmail.co.uk>
Diffstat (limited to 'udev/lib')
-rw-r--r-- | udev/lib/libudev-ctrl.c | 8 | ||||
-rw-r--r-- | udev/lib/libudev-device.c | 8 | ||||
-rw-r--r-- | udev/lib/libudev-monitor.c | 8 | ||||
-rw-r--r-- | udev/lib/libudev.c | 6 |
4 files changed, 15 insertions, 15 deletions
diff --git a/udev/lib/libudev-ctrl.c b/udev/lib/libudev-ctrl.c index 7d37074fef..268ce2d353 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; } @@ -158,7 +158,7 @@ static int ctrl_send(struct udev_ctrl *uctrl, enum udev_ctrl_msg_type type, int err = sendto(uctrl->sock, &ctrl_msg_wire, sizeof(ctrl_msg_wire), 0, (struct sockaddr *)&uctrl->saddr, uctrl->addrlen); if (err == -1) { - err(uctrl->udev, "error sending message: %s\n", strerror(errno)); + err(uctrl->udev, "error sending message: %m\n"); } return err; } @@ -227,7 +227,7 @@ struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl *uctrl) size = recvmsg(uctrl->sock, &smsg, 0); if (size < 0) { - err(uctrl->udev, "unable to receive user udevd message: %s\n", strerror(errno)); + err(uctrl->udev, "unable to receive user udevd message: %m\n"); goto err; } cmsg = CMSG_FIRSTHDR(&smsg); diff --git a/udev/lib/libudev-device.c b/udev/lib/libudev-device.c index 4d000292f2..4cdc957093 100644 --- a/udev/lib/libudev-device.c +++ b/udev/lib/libudev-device.c @@ -77,7 +77,7 @@ static int device_read_db(struct udev_device *udev_device) syspath_to_db_path(udev_device, filename, sizeof(filename)); if (lstat(filename, &stats) != 0) { - info(udev_device->udev, "no db file to read %s: %s\n", filename, strerror(errno)); + info(udev_device->udev, "no db file to read %s: %m\n", filename); return -1; } if ((stats.st_mode & S_IFMT) == S_IFLNK) { @@ -88,7 +88,7 @@ static int device_read_db(struct udev_device *udev_device) if (target_len > 0) target[target_len] = '\0'; else { - info(udev_device->udev, "error reading db link %s: %s\n", filename, strerror(errno)); + info(udev_device->udev, "error reading db link %s: %m\n", filename); return -1; } if (asprintf(&udev_device->devnode, "%s/%s", udev_get_dev_path(udev_device->udev), target) < 0) @@ -99,7 +99,7 @@ static int device_read_db(struct udev_device *udev_device) f = fopen(filename, "r"); if (f == NULL) { - info(udev_device->udev, "error reading db file %s: %s\n", filename, strerror(errno)); + info(udev_device->udev, "error reading db file %s: %m\n", filename); return -1; } while (fgets(line, sizeof(line), f)) { @@ -653,7 +653,7 @@ const char *udev_device_get_attr_value(struct udev_device *udev_device, const ch util_strlcat(path, attr, sizeof(path)); if (lstat(path, &statbuf) != 0) { - info(udev_device->udev, "stat '%s' failed: %s\n", path, strerror(errno)); + info(udev_device->udev, "stat '%s' failed: %m\n", path); goto out; } diff --git a/udev/lib/libudev-monitor.c b/udev/lib/libudev-monitor.c index 8a1bdaed06..e72b206623 100644 --- a/udev/lib/libudev-monitor.c +++ b/udev/lib/libudev-monitor.c @@ -83,7 +83,7 @@ struct udev_monitor *udev_monitor_new_from_socket(struct udev *udev, const char udev_monitor->sock = socket(AF_LOCAL, SOCK_DGRAM, 0); if (udev_monitor->sock == -1) { - err(udev, "error getting socket: %s\n", strerror(errno)); + err(udev, "error getting socket: %m\n"); free(udev_monitor); return NULL; } @@ -106,7 +106,7 @@ struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev) udev_monitor->sock = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT); if (udev_monitor->sock == -1) { - err(udev, "error getting socket: %s\n", strerror(errno)); + err(udev, "error getting socket: %m\n"); free(udev_monitor); return NULL; } @@ -127,14 +127,14 @@ int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor) if (udev_monitor->snl.nl_family != 0) { err = bind(udev_monitor->sock, (struct sockaddr *)&udev_monitor->snl, sizeof(struct sockaddr_nl)); if (err < 0) { - err(udev_monitor->udev, "bind failed: %s\n", strerror(errno)); + err(udev_monitor->udev, "bind failed: %m\n"); return err; } info(udev_monitor->udev, "monitor %p listening on netlink\n", udev_monitor); } else if (udev_monitor->sun.sun_family != 0) { err = bind(udev_monitor->sock, (struct sockaddr *)&udev_monitor->sun, udev_monitor->addrlen); if (err < 0) { - err(udev_monitor->udev, "bind failed: %s\n", strerror(errno)); + err(udev_monitor->udev, "bind failed: %m\n"); return err; } /* enable receiving of the sender credentials */ diff --git a/udev/lib/libudev.c b/udev/lib/libudev.c index 4fd8196bd9..12220e7a78 100644 --- a/udev/lib/libudev.c +++ b/udev/lib/libudev.c @@ -131,7 +131,7 @@ void udev_selinux_lsetfilecon(struct udev *udev, const char *file, unsigned int return; } if (lsetfilecon(file, scontext) < 0) - err(udev, "setfilecon %s failed: %s\n", file, strerror(errno)); + err(udev, "setfilecon %s failed: %m\n", file); freecon(scontext); } #endif @@ -150,7 +150,7 @@ void udev_selinux_setfscreatecon(struct udev *udev, const char *file, unsigned i return; } if (setfscreatecon(scontext) < 0) - err(udev, "setfscreatecon %s failed: %s\n", file, strerror(errno)); + err(udev, "setfscreatecon %s failed: %m\n", file); freecon(scontext); } #endif @@ -163,7 +163,7 @@ void udev_selinux_resetfscreatecon(struct udev *udev) selinux_init(udev); if (udev->selinux_enabled) { if (setfscreatecon(udev->selinux_prev_scontext) < 0) - err(udev, "setfscreatecon failed: %s\n", strerror(errno)); + err(udev, "setfscreatecon failed: %m\n"); } #endif } |