[systemd-devel] [PATCH] tree-wide usage of %m specifier instead of strerror(errno)

2013-11-26 Thread Daniel Buch
Also for log_error() except where a specific error is specified

e.g. errno ? strerror(errno) : Some user specified message
---
 TODO   |  2 --
 src/core/automount.c   |  2 +-
 src/core/main.c|  2 +-
 src/core/manager.c |  2 +-
 src/core/mount-setup.c |  2 +-
 src/core/service.c |  4 ++--
 src/initctl/initctl.c  | 12 +---
 src/journal/coredumpctl.c  |  2 +-
 src/journal/journald-console.c |  4 ++--
 src/journal/journald-kmsg.c|  2 +-
 src/udev/collect/collect.c |  6 +++---
 src/udev/scsi_id/scsi_id.c |  2 +-
 src/udev/scsi_id/scsi_serial.c |  8 +++-
 src/udev/udev-rules.c  |  2 +-
 14 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/TODO b/TODO
index d63e13e..653258a 100644
--- a/TODO
+++ b/TODO
@@ -824,8 +824,6 @@ Regularly:
 
 * Use PR_SET_PROCTITLE_AREA if it becomes available in the kernel
 
-* %m in printf() instead of strerror(errno);
-
 * pahole
 
 * set_put(), hashmap_put() return values check. i.e. == 0 doesn't free()!
diff --git a/src/core/automount.c b/src/core/automount.c
index 49a64b1..66e3d78 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -304,7 +304,7 @@ static int open_dev_autofs(Manager *m) {
 
 m-dev_autofs_fd = open(/dev/autofs, O_CLOEXEC|O_RDONLY);
 if (m-dev_autofs_fd  0) {
-log_error(Failed to open /dev/autofs: %s, strerror(errno));
+log_error(Failed to open /dev/autofs: %m);
 return -errno;
 }
 
diff --git a/src/core/main.c b/src/core/main.c
index dbc98db..69d3a43 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -131,7 +131,7 @@ _noreturn_ static void crash(int sig) {
 
 pid = fork();
 if (pid  0)
-log_error(Caught %s, cannot fork for core dump: 
%s, signal_to_string(sig), strerror(errno));
+log_error(Caught %s, cannot fork for core dump: 
%m, signal_to_string(sig));
 
 else if (pid == 0) {
 struct rlimit rl = {};
diff --git a/src/core/manager.c b/src/core/manager.c
index aa4baaa..65cb73c 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -307,7 +307,7 @@ static int enable_special_signals(Manager *m) {
 } else {
 /* Enable that we get SIGWINCH on kbrequest */
 if (ioctl(fd, KDSIGACCEPT, SIGWINCH)  0)
-log_warning(Failed to enable kbrequest handling: %s, 
strerror(errno));
+log_warning(Failed to enable kbrequest handling: %m);
 }
 
 return 0;
diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
index 73c2698..c601c97 100644
--- a/src/core/mount-setup.c
+++ b/src/core/mount-setup.c
@@ -188,7 +188,7 @@ static int mount_one(const MountPoint *p, bool relabel) {
   p-type,
   p-flags,
   p-options)  0) {
-log_full((p-mode  MNT_FATAL) ? LOG_ERR : LOG_DEBUG, Failed 
to mount %s: %s, p-where, strerror(errno));
+log_full((p-mode  MNT_FATAL) ? LOG_ERR : LOG_DEBUG, Failed 
to mount %s: %m, p-where);
 return (p-mode  MNT_FATAL) ? -errno : 0;
 }
 
diff --git a/src/core/service.c b/src/core/service.c
index 28b1465..7c5d5d8 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -3507,7 +3507,7 @@ static int service_enumerate(Manager *m) {
 d = opendir(path);
 if (!d) {
 if (errno != ENOENT)
-log_warning(opendir(%s) failed: %s, 
path, strerror(errno));
+log_warning(opendir(%s) failed: %m, 
path);
 
 continue;
 }
@@ -3540,7 +3540,7 @@ static int service_enumerate(Manager *m) {
 if (access(fpath, X_OK)  0) {
 
 if (errno != ENOENT)
-log_warning(access() failed 
on %s: %s, fpath, strerror(errno));
+log_warning(access() failed 
on %s: %m, fpath);
 
 continue;
 }
diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c
index d6c..284319f 100644
--- a/src/initctl/initctl.c
+++ b/src/initctl/initctl.c
@@ -217,7 +217,7 @@ static int fifo_process(Fifo *f) {
 if (errno == EAGAIN)
 return 0;
 
-log_warning(Failed to read from fifo: %s, strerror(errno));
+log_warning(Failed to read from fifo: %m);
 return -1;
 }
 
@@ -278,7 +278,7 @@ static int server_init(Server *s, unsigned n_sockets) {
 s-epoll_fd = epoll_create1(EPOLL_CLOEXEC);
 if (s-epoll_fd  0) {
 r = 

Re: [systemd-devel] [PATCH] tree-wide usage of %m specifier instead of strerror(errno)

2013-11-26 Thread David Timothy Strauss
Thanks. Applied.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel