[systemd-devel] [PATCH 4/5] everywhere: stop using strerror()

Michal Sekletar msekleta at redhat.com
Mon Feb 24 06:59:30 PST 2014


---
 src/hostname/hostnamed.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index 064d9d2..d8938a4 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -409,8 +409,8 @@ static int method_set_hostname(sd_bus *bus, sd_bus_message *m, void *userdata, s
 
         r = context_write_data_hostname(c);
         if (r < 0) {
-                log_error("Failed to set host name: %s", strerror(-r));
-                return sd_bus_error_set_errnof(error, r, "Failed to set hostname: %s", strerror(-r));
+                log_error("Failed to set host name: %m");
+                return sd_bus_error_set_errnof(error, r, "Failed to set hostname: %m");
         }
 
         log_info("Changed host name to '%s'", strna(c->data[PROP_HOSTNAME]));
@@ -461,8 +461,8 @@ static int method_set_static_hostname(sd_bus *bus, sd_bus_message *m, void *user
 
         r = context_write_data_static_hostname(c);
         if (r < 0) {
-                log_error("Failed to write static host name: %s", strerror(-r));
-                return sd_bus_error_set_errnof(error, r, "Failed to set static hostname: %s", strerror(-r));
+                log_error("Failed to write static host name: %m");
+                return sd_bus_error_set_errnof(error, r, "Failed to set static hostname: %m");
         }
 
         log_info("Changed static host name to '%s'", strna(c->data[PROP_STATIC_HOSTNAME]));
@@ -530,8 +530,8 @@ static int set_machine_info(Context *c, sd_bus *bus, sd_bus_message *m, int prop
 
         r = context_write_data_other(c);
         if (r < 0) {
-                log_error("Failed to write machine info: %s", strerror(-r));
-                return sd_bus_error_set_errnof(error, r, "Failed to write machine info: %s", strerror(-r));
+                log_error("Failed to write machine info: %m");
+                return sd_bus_error_set_errnof(error, r, "Failed to write machine info: %m");
         }
 
         log_info("Changed %s to '%s'",
@@ -582,25 +582,25 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
 
         r = sd_bus_default_system(&bus);
         if (r < 0) {
-                log_error("Failed to get system bus connection: %s", strerror(-r));
+                log_error("Failed to get system bus connection: %m");
                 return r;
         }
 
         r = sd_bus_add_object_vtable(bus, "/org/freedesktop/hostname1", "org.freedesktop.hostname1", hostname_vtable, c);
         if (r < 0) {
-                log_error("Failed to register object: %s", strerror(-r));
+                log_error("Failed to register object: %m");
                 return r;
         }
 
         r = sd_bus_request_name(bus, "org.freedesktop.hostname1", 0);
         if (r < 0) {
-                log_error("Failed to register name: %s", strerror(-r));
+                log_error("Failed to register name: %m");
                 return r;
         }
 
         r = sd_bus_attach_event(bus, event, 0);
         if (r < 0) {
-                log_error("Failed to attach bus to event loop: %s", strerror(-r));
+                log_error("Failed to attach bus to event loop: %m");
                 return r;
         }
 
@@ -707,7 +707,7 @@ int main(int argc, char *argv[]) {
 
         r = sd_event_default(&event);
         if (r < 0) {
-                log_error("Failed to allocate event loop: %s", strerror(-r));
+                log_error("Failed to allocate event loop: %m");
                 goto finish;
         }
 
@@ -719,7 +719,7 @@ int main(int argc, char *argv[]) {
 
         r = context_read_data(&context);
         if (r < 0) {
-                log_error("Failed to read hostname and machine information: %s", strerror(-r));
+                log_error("Failed to read hostname and machine information: %m");
                 goto finish;
         }
 
@@ -729,7 +729,7 @@ int main(int argc, char *argv[]) {
 
         r = bus_event_loop_with_idle(event, bus, "org.freedesktop.hostname1", DEFAULT_EXIT_USEC, NULL, NULL);
         if (r < 0) {
-                log_error("Failed to run event loop: %s", strerror(-r));
+                log_error("Failed to run event loop: %m");
                 goto finish;
         }
 
-- 
1.8.4.2



More information about the systemd-devel mailing list