procd: Add %m to several functions that return errno.
[project/procd.git] / inittab.c
index 21172f7..55554b9 100644 (file)
--- a/inittab.c
+++ b/inittab.c
@@ -104,7 +104,7 @@ static void fork_worker(struct init_action *a)
                tcsetpgrp(STDIN_FILENO, p);
 
                execvp(a->argv[0], a->argv);
-               ERROR("Failed to execute %s\n", a->argv[0]);
+               ERROR("Failed to execute %s: %m\n", a->argv[0]);
                exit(-1);
        }
 
@@ -278,14 +278,13 @@ void procd_inittab(void)
        char *line;
 
        if (!fp) {
-               ERROR("Failed to open %s\n", tab);
+               ERROR("Failed to open %s: %m\n", tab);
                return;
        }
 
        regcomp(&pat_inittab, "([a-zA-Z0-9]*):([a-zA-Z0-9]*):([a-zA-Z0-9]*):(.*)", REG_EXTENDED);
        line = malloc(LINE_LEN);
-       a = malloc(sizeof(struct init_action));
-       memset(a, 0, sizeof(struct init_action));
+       a = calloc(1, sizeof(struct init_action));
 
        while (fgets(line, LINE_LEN, fp)) {
                char *tags[TAG_PROCESS + 1];
@@ -322,8 +321,7 @@ void procd_inittab(void)
                if (add_action(a, tags[TAG_ACTION]))
                        continue;
                line = malloc(LINE_LEN);
-               a = malloc(sizeof(struct init_action));
-               memset(a, 0, sizeof(struct init_action));
+               a = calloc(1, sizeof(struct init_action));
        }
 
        fclose(fp);