[systemd-devel] [PATCH] Use %m instead of strerror(errno) where appropiate

Cristian Rodríguez crrodriguez at opensuse.org
Fri May 23 21:10:36 PDT 2014


---
 src/journal/sd-journal.c                | 6 ++----
 src/libsystemd-network/sd-dhcp-client.c | 4 ++--
 src/nspawn/nspawn.c                     | 2 +-
 src/shared/label.c                      | 2 +-
 4 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 11de8ef..ca805f8 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -1455,8 +1455,7 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname)
                 de = readdir(d);
                 if (!de && errno != 0) {
                         r = -errno;
-                        log_debug("Failed to read directory %s: %s",
-                                  m->path, strerror(errno));
+                        log_debug("Failed to read directory %s: %m", m->path);
                         return r;
                 }
                 if (!de)
@@ -1546,8 +1545,7 @@ static int add_root_directory(sd_journal *j, const char *p) {
                 de = readdir(d);
                 if (!de && errno != 0) {
                         r = -errno;
-                        log_debug("Failed to read directory %s: %s",
-                                  m->path, strerror(errno));
+                        log_debug("Failed to read directory %s: %m", m->path);
                         return r;
                 }
                 if (!de)
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index 67593c4..0300a6b 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -1200,7 +1200,7 @@ static int client_receive_message_udp(sd_event_source *s, int fd,
         len = read(fd, message, buflen);
         if (len < 0) {
                 log_dhcp_client(client, "could not receive message from UDP "
-                                "socket: %s", strerror(errno));
+                                "socket: %m");
                 return 0;
         } else if ((size_t)len < sizeof(DHCPMessage))
                 return 0;
@@ -1245,7 +1245,7 @@ static int client_receive_message_raw(sd_event_source *s, int fd,
         len = recvmsg(fd, &msg, 0);
         if (len < 0) {
                 log_dhcp_client(client, "could not receive message from raw "
-                                "socket: %s", strerror(errno));
+                                "socket: %m");
                 return 0;
         } else if ((size_t)len < sizeof(DHCPPacket))
                 return 0;
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index eb9c5e0..73158a0 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -657,7 +657,7 @@ static int mount_binds(const char *dest, char **l, unsigned long flags) {
                                 return r;
                         }
                 } else {
-                        log_error("Failed to bind mount %s: %s", *x, strerror(errno));
+                        log_error("Failed to bind mount %s: %m", *x);
                         return -errno;
                 }
                 /* Create the mount point, but be conservative -- refuse to create block
diff --git a/src/shared/label.c b/src/shared/label.c
index 70e5c85..3b7b86e 100644
--- a/src/shared/label.c
+++ b/src/shared/label.c
@@ -79,7 +79,7 @@ static int smack_relabel_in_dev(const char *path) {
 
         r = setxattr(path, "security.SMACK64", label, strlen(label), 0);
         if (r < 0) {
-                log_error("Smack relabeling \"%s\" %s", path, strerror(errno));
+                log_error("Smack relabeling \"%s\" %m", path);
                 return -errno;
         }
 #endif
-- 
1.8.4.5



More information about the systemd-devel mailing list