]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/reply-password/reply-password.c
treewide: use log_*_errno whenever %m is in the format string
[thirdparty/systemd.git] / src / reply-password / reply-password.c
index 2f168985b42f620b02693810a13714a108274857..54528d67ab51e75633553f96f57f3a097c956412 100644 (file)
@@ -52,8 +52,8 @@ static int send_on_socket(int fd, const char *socket_name, const void *packet, s
         strncpy(sa.un.sun_path, socket_name, sizeof(sa.un.sun_path));
 
         if (sendto(fd, packet, size, MSG_NOSIGNAL, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(socket_name)) < 0) {
-                log_error("Failed to send: %m");
-                return -1;
+                log_error_errno(errno, "Failed to send: %m");
+                return -errno;
         }
 
         return 0;
@@ -77,7 +77,7 @@ int main(int argc, char *argv[]) {
 
                 packet[0] = '+';
                 if (!fgets(packet+1, sizeof(packet)-1, stdin)) {
-                        log_error("Failed to read password: %m");
+                        log_error_errno(errno, "Failed to read password: %m");
                         goto finish;
                 }
 
@@ -91,8 +91,9 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
-        if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0)) < 0) {
-                log_error("socket() failed: %m");
+        fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
+        if (fd < 0) {
+                log_error_errno(errno, "socket() failed: %m");
                 goto finish;
         }
 
@@ -102,8 +103,7 @@ int main(int argc, char *argv[]) {
         r = EXIT_SUCCESS;
 
 finish:
-        if (fd >= 0)
-                close_nointr_nofail(fd);
+        safe_close(fd);
 
         return r;
 }