[systemd-commits] src/core src/initctl src/journal src/udev TODO

David Strauss straussd at kemper.freedesktop.org
Tue Nov 26 03:07:56 PST 2013


 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(-)

New commits:
commit f5f6d0e25574dd63fb605b81fa7767dd71c454db
Author: Daniel Buch <boogiewasthere at gmail.com>
Date:   Tue Nov 26 09:38:02 2013 +0100

    tree-wide usage of %m specifier instead of strerror(errno)
    
    Also for log_error() except where a specific error is specified
    
    e.g. errno ? strerror(errno) : "Some user specified message"

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 0000d6c..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 = -errno;
-                log_error("Failed to create epoll object: %s", strerror(errno));
+                log_error("Failed to create epoll object: %m");
                 goto fail;
         }
 
@@ -305,8 +305,7 @@ static int server_init(Server *s, unsigned n_sockets) {
                 f = new0(Fifo, 1);
                 if (!f) {
                         r = -ENOMEM;
-                        log_error("Failed to create fifo object: %s",
-                                  strerror(errno));
+                        log_error("Failed to create fifo object: %m");
                         goto fail;
                 }
 
@@ -318,8 +317,7 @@ static int server_init(Server *s, unsigned n_sockets) {
                 if (epoll_ctl(s->epoll_fd, EPOLL_CTL_ADD, fd, &ev) < 0) {
                         r = -errno;
                         fifo_free(f);
-                        log_error("Failed to add fifo fd to epoll object: %s",
-                                  strerror(errno));
+                        log_error("Failed to add fifo fd to epoll object: %m");
                         goto fail;
                 }
 
@@ -416,7 +414,7 @@ int main(int argc, char *argv[]) {
                         if (errno == EINTR)
                                 continue;
 
-                        log_error("epoll_wait() failed: %s", strerror(errno));
+                        log_error("epoll_wait() failed: %m");
                         goto fail;
                 }
 
diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c
index bcfee46..ec65ff5 100644
--- a/src/journal/coredumpctl.c
+++ b/src/journal/coredumpctl.c
@@ -479,7 +479,7 @@ static int run_gdb(sd_journal *j) {
 
         sz = write(fd, data, len);
         if (sz < 0) {
-                log_error("Failed to write temporary file: %s", strerror(errno));
+                log_error("Failed to write temporary file: %m");
                 r = -errno;
                 goto finish;
         }
diff --git a/src/journal/journald-console.c b/src/journal/journald-console.c
index 1ee3afe..04c4424 100644
--- a/src/journal/journald-console.c
+++ b/src/journal/journald-console.c
@@ -100,12 +100,12 @@ void server_forward_console(
 
         fd = open_terminal(tty, O_WRONLY|O_NOCTTY|O_CLOEXEC);
         if (fd < 0) {
-                log_debug("Failed to open %s for logging: %s", tty, strerror(errno));
+                log_debug("Failed to open %s for logging: %m", tty);
                 goto finish;
         }
 
         if (writev(fd, iovec, n) < 0)
-                log_debug("Failed to write to %s for logging: %s", tty, strerror(errno));
+                log_debug("Failed to write to %s for logging: %m", tty);
 
         close_nointr_nofail(fd);
 
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
index 21649d0..af49d85 100644
--- a/src/journal/journald-kmsg.c
+++ b/src/journal/journald-kmsg.c
@@ -88,7 +88,7 @@ void server_forward_kmsg(
         IOVEC_SET_STRING(iovec[n++], "\n");
 
         if (writev(s->dev_kmsg_fd, iovec, n) < 0)
-                log_debug("Failed to write to /dev/kmsg for logging: %s", strerror(errno));
+                log_debug("Failed to write to /dev/kmsg for logging: %m");
 
         free(ident_buf);
 }
diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c
index 1346f27..2bbbcd7 100644
--- a/src/udev/collect/collect.c
+++ b/src/udev/collect/collect.c
@@ -97,7 +97,7 @@ static int prepare(char *dir, char *filename)
 
         fd = open(buf,O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
         if (fd < 0)
-                fprintf(stderr, "Cannot open %s: %s\n", buf, strerror(errno));
+                fprintf(stderr, "Cannot open %s: %m\n", buf);
 
         if (lockf(fd,F_TLOCK,0) < 0) {
                 if (debug)
@@ -109,7 +109,7 @@ static int prepare(char *dir, char *filename)
                                 fprintf(stderr, "Acquired lock on %s\n", buf);
                 } else {
                         if (debug)
-                                fprintf(stderr, "Could not get lock on %s: %s\n", buf, strerror(errno));
+                                fprintf(stderr, "Could not get lock on %s: %m\n", buf);
                 }
         }
 
@@ -404,7 +404,7 @@ int main(int argc, char **argv)
         us = argv[argi++];
 
         if (signal(SIGALRM, sig_alrm) == SIG_ERR) {
-                fprintf(stderr, "Cannot set SIGALRM: %s\n", strerror(errno));
+                fprintf(stderr, "Cannot set SIGALRM: %m\n");
                 ret = 2;
                 goto exit;
         }
diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c
index ab7c54c..c2cc2ea 100644
--- a/src/udev/scsi_id/scsi_id.c
+++ b/src/udev/scsi_id/scsi_id.c
@@ -185,7 +185,7 @@ static int get_file_options(struct udev *udev,
                 if (errno == ENOENT) {
                         return 1;
                 } else {
-                        log_error("can't open %s: %s\n", config_file, strerror(errno));
+                        log_error("can't open %s: %m\n", config_file);
                         return -1;
                 }
         }
diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c
index d522a23..4b0711b 100644
--- a/src/udev/scsi_id/scsi_serial.c
+++ b/src/udev/scsi_id/scsi_serial.c
@@ -362,7 +362,7 @@ resend:
                         dev_scsi->use_sg = 3;
                         goto resend;
                 }
-                log_debug("%s: ioctl failed: %s\n", dev_scsi->kernel, strerror(errno));
+                log_debug("%s: ioctl failed: %m\n", dev_scsi->kernel);
                 goto error;
         }
 
@@ -820,14 +820,12 @@ int scsi_std_inquiry(struct udev *udev,
 
         fd = open(devname, O_RDONLY | O_NONBLOCK);
         if (fd < 0) {
-                log_debug("scsi_id: cannot open %s: %s\n",
-                     devname, strerror(errno));
+                log_debug("scsi_id: cannot open %s: %m\n", devname);
                 return 1;
         }
 
         if (fstat(fd, &statbuf) < 0) {
-                log_debug("scsi_id: cannot stat %s: %s\n",
-                     devname, strerror(errno));
+                log_debug("scsi_id: cannot stat %s: %m\n", devname);
                 err = 2;
                 goto out;
         }
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 320f004..9154700 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -2595,7 +2595,7 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules)
                                         strscpyl(tag_symlink, sizeof(tag_symlink), tags_dir, unescaped_filename, NULL);
                                         r = symlink(device_node, tag_symlink);
                                         if (r < 0 && errno != EEXIST) {
-                                                log_error("failed to create symlink %s -> %s: %s\n", tag_symlink, device_node, strerror(errno));
+                                                log_error("failed to create symlink %s -> %s: %m\n", tag_symlink, device_node);
                                                 return -errno;
                                         } else
                                                 r = 0;



More information about the systemd-commits mailing list