chiark / gitweb /
core: add log_unit_*_errno() macros
[elogind.git] / src / core / hostname-setup.c
index 8aa1cff1d30f23ad1a42826a487a7e8540a11beb..f81103a8103eb48aa44c1f1c14c97937392d25df 100644 (file)
@@ -64,7 +64,7 @@ int hostname_setup(void) {
                 if (r == -ENOENT)
                         enoent = true;
                 else
-                        log_warning("Failed to read configured hostname: %s", strerror(-r));
+                        log_warning_errno(r, "Failed to read configured hostname: %m");
 
                 hn = NULL;
         } else
@@ -82,7 +82,7 @@ int hostname_setup(void) {
                 hn = "localhost";
         }
 
-        if (sethostname(hn, strlen(hn)) < 0) {
+        if (sethostname_idempotent(hn) < 0) {
                 log_warning("Failed to set hostname to <%s>: %m", hn);
                 return -errno;
         }