chiark / gitweb /
treewide: more log_*_errno() conversions, multiline calls
[elogind.git] / src / activate / activate.c
index 8c582739976a2e4116b99cb1721c95083575db1c..874b8836177f542908de1c09ccc2e5d93b2fca6a 100644 (file)
@@ -27,7 +27,7 @@
 #include <sys/wait.h>
 #include <getopt.h>
 
-#include <systemd/sd-daemon.h>
+#include "systemd/sd-daemon.h"
 
 #include "socket-util.h"
 #include "build.h"
@@ -66,8 +66,7 @@ static int open_sockets(int *epoll_fd, bool accept) {
 
         n = sd_listen_fds(true);
         if (n < 0) {
-                log_error("Failed to read listening file descriptors from environment: %s",
-                          strerror(-n));
+                log_error_errno(n, "Failed to read listening file descriptors from environment: %m");
                 return n;
         }
         if (n > 0) {
@@ -103,7 +102,7 @@ static int open_sockets(int *epoll_fd, bool accept) {
                 fd = make_socket_fd(LOG_DEBUG, *address, SOCK_STREAM | (arg_accept*SOCK_CLOEXEC));
                 if (fd < 0) {
                         log_open();
-                        log_error("Failed to open '%s': %s", *address, strerror(-fd));
+                        log_error_errno(fd, "Failed to open '%s': %m", *address);
                         return fd;
                 }
 
@@ -242,7 +241,7 @@ static int launch1(const char* child, char** argv, char **env, int fd) {
 
 static int do_accept(const char* name, char **argv, char **envp, int fd) {
         _cleanup_free_ char *local = NULL, *peer = NULL;
-        int fd2;
+        _cleanup_close_ int fd2 = -1;
 
         fd2 = accept(fd, NULL, NULL);
         if (fd2 < 0) {
@@ -279,7 +278,7 @@ static int install_chld_handler(void) {
         return r;
 }
 
-static int help(void) {
+static void help(void) {
         printf("%s [OPTIONS...]\n\n"
                "Listen on sockets and launch child on connection.\n\n"
                "Options:\n"
@@ -290,10 +289,7 @@ static int help(void) {
                "  --version                Print version string and exit\n"
                "\n"
                "Note: file descriptors from sd_listen_fds() will be passed through.\n"
-               , program_invocation_short_name
-               );
-
-        return 0;
+               , program_invocation_short_name);
 }
 
 static int parse_argv(int argc, char *argv[]) {
@@ -319,7 +315,8 @@ static int parse_argv(int argc, char *argv[]) {
         while ((c = getopt_long(argc, argv, "+hl:aE:", options, NULL)) >= 0)
                 switch(c) {
                 case 'h':
-                        return help();
+                        help();
+                        return 0;
 
                 case ARG_VERSION:
                         puts(PACKAGE_STRING);
@@ -354,7 +351,7 @@ static int parse_argv(int argc, char *argv[]) {
                 }
 
         if (optind == argc) {
-                log_error("Usage: %s [OPTION...] PROGRAM [OPTION...]",
+                log_error("%s: command to execute is missing.",
                           program_invocation_short_name);
                 return -EINVAL;
         }