[systemd-commits] 4 commits - configure.ac src/cgroup.c src/cgroup-util.c src/cryptsetup.c src/load-fragment.c src/manager.c src/pam-module.c src/swap.c src/sysctl.c src/systemctl.c src/tmpfiles.c src/util.c TODO

Lennart Poettering lennart at kemper.freedesktop.org
Fri Jan 21 17:19:24 PST 2011


 TODO                |    3 +++
 configure.ac        |    2 +-
 src/cgroup-util.c   |    8 ++++----
 src/cgroup.c        |    5 ++---
 src/cryptsetup.c    |    1 +
 src/load-fragment.c |   34 ++++++++++++++--------------------
 src/manager.c       |    3 +--
 src/pam-module.c    |    4 ++++
 src/swap.c          |    2 +-
 src/sysctl.c        |    1 +
 src/systemctl.c     |    6 ++++--
 src/tmpfiles.c      |   28 ++++++++++++++--------------
 src/util.c          |    2 +-
 13 files changed, 51 insertions(+), 48 deletions(-)

New commits:
commit bd40a2d830265cdd36eb19576bdbe8e41dd527ee
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jan 22 02:18:59 2011 +0100

    clang: fix some issues found with clang-analyzer

diff --git a/src/cgroup.c b/src/cgroup.c
index 64082d0..392736f 100644
--- a/src/cgroup.c
+++ b/src/cgroup.c
@@ -404,17 +404,16 @@ char *cgroup_bonding_to_string(CGroupBonding *b) {
 pid_t cgroup_bonding_search_main_pid(CGroupBonding *b) {
         FILE *f;
         pid_t pid = 0, npid;
-        int r;
 
         assert(b);
 
         if (!b->ours)
                 return 0;
 
-        if ((r = cg_enumerate_processes(b->controller, b->path, &f)) < 0)
+        if (cg_enumerate_processes(b->controller, b->path, &f) < 0)
                 return 0;
 
-        while ((r = cg_read_pid(f, &npid)) > 0)  {
+        while (cg_read_pid(f, &npid) > 0)  {
 
                 if (npid == pid)
                         continue;
diff --git a/src/cryptsetup.c b/src/cryptsetup.c
index f543a05..c80572a 100644
--- a/src/cryptsetup.c
+++ b/src/cryptsetup.c
@@ -386,6 +386,7 @@ int main(int argc, char *argv[]) {
                 if (try >= opt_tries) {
                         log_error("Too many attempts.");
                         r = EXIT_FAILURE;
+                        goto finish;
                 }
 
         } else if (streq(argv[1], "detach")) {
diff --git a/src/load-fragment.c b/src/load-fragment.c
index 44b2cf0..acceb9b 100644
--- a/src/load-fragment.c
+++ b/src/load-fragment.c
@@ -191,7 +191,6 @@ static int config_parse_listen(
                 void *data,
                 void *userdata) {
 
-        int r;
         SocketPort *p;
         Socket *s;
 
@@ -217,7 +216,7 @@ static int config_parse_listen(
         } else {
                 p->type = SOCKET_SOCKET;
 
-                if ((r = socket_address_parse(&p->address, rvalue)) < 0) {
+                if (socket_address_parse(&p->address, rvalue) < 0) {
                         log_error("[%s:%u] Failed to parse address value, ignoring: %s", filename, line, rvalue);
                         free(p);
                         return 0;
@@ -289,14 +288,14 @@ static int config_parse_nice(
                 void *userdata) {
 
         ExecContext *c = data;
-        int priority, r;
+        int priority;
 
         assert(filename);
         assert(lvalue);
         assert(rvalue);
         assert(data);
 
-        if ((r = safe_atoi(rvalue, &priority)) < 0) {
+        if (safe_atoi(rvalue, &priority) < 0) {
                 log_error("[%s:%u] Failed to parse nice priority, ignoring: %s. ", filename, line, rvalue);
                 return 0;
         }
@@ -322,14 +321,14 @@ static int config_parse_oom_score_adjust(
                 void *userdata) {
 
         ExecContext *c = data;
-        int oa, r;
+        int oa;
 
         assert(filename);
         assert(lvalue);
         assert(rvalue);
         assert(data);
 
-        if ((r = safe_atoi(rvalue, &oa)) < 0) {
+        if (safe_atoi(rvalue, &oa) < 0) {
                 log_error("[%s:%u] Failed to parse the OOM score adjust value, ignoring: %s", filename, line, rvalue);
                 return 0;
         }
@@ -506,14 +505,13 @@ static int config_parse_usec(
                 void *userdata) {
 
         usec_t *usec = data;
-        int r;
 
         assert(filename);
         assert(lvalue);
         assert(rvalue);
         assert(data);
 
-        if ((r = parse_usec(rvalue, usec)) < 0) {
+        if (parse_usec(rvalue, usec) < 0) {
                 log_error("[%s:%u] Failed to parse time value, ignoring: %s", filename, line, rvalue);
                 return 0;
         }
@@ -893,14 +891,13 @@ static int config_parse_timer_slack_nsec(
 
         ExecContext *c = data;
         unsigned long u;
-        int r;
 
         assert(filename);
         assert(lvalue);
         assert(rvalue);
         assert(data);
 
-        if ((r = safe_atolu(rvalue, &u)) < 0) {
+        if (safe_atolu(rvalue, &u) < 0) {
                 log_error("[%s:%u] Failed to parse time slack value, ignoring: %s", filename, line, rvalue);
                 return 0;
         }
@@ -928,7 +925,7 @@ static int config_parse_limit(
         assert(rvalue);
         assert(data);
 
-        if ((r = safe_atollu(rvalue, &u)) < 0) {
+        if (safe_atollu(rvalue, &u) < 0) {
                 log_error("[%s:%u] Failed to parse resource value, ignoring: %s", filename, line, rvalue);
                 return 0;
         }
@@ -985,14 +982,14 @@ static int config_parse_sysv_priority(
                 void *userdata) {
 
         int *priority = data;
-        int r, i;
+        int i;
 
         assert(filename);
         assert(lvalue);
         assert(rvalue);
         assert(data);
 
-        if ((r = safe_atoi(rvalue, &i)) < 0 || i < 0) {
+        if (safe_atoi(rvalue, &i) < 0 || i < 0) {
                 log_error("[%s:%u] Failed to parse SysV start priority, ignoring: %s", filename, line, rvalue);
                 return 0;
         }
@@ -1012,14 +1009,14 @@ static int config_parse_fsck_passno(
                 void *userdata) {
 
         int *passno = data;
-        int r, i;
+        int i;
 
         assert(filename);
         assert(lvalue);
         assert(rvalue);
         assert(data);
 
-        if ((r = safe_atoi(rvalue, &i)) < 0 || i < 0) {
+        if (safe_atoi(rvalue, &i) || i < 0) {
                 log_error("[%s:%u] Failed to parse fsck pass number, ignoring: %s", filename, line, rvalue);
                 return 0;
         }
@@ -1104,7 +1101,6 @@ static int config_parse_timer(
 
         Timer *t = data;
         usec_t u;
-        int r;
         TimerValue *v;
         TimerBase b;
 
@@ -1118,7 +1114,7 @@ static int config_parse_timer(
                 return 0;
         }
 
-        if ((r = parse_usec(rvalue, &u)) < 0) {
+        if (parse_usec(rvalue, &u) < 0) {
                 log_error("[%s:%u] Failed to parse timer value, ignoring: %s", filename, line, rvalue);
                 return 0;
         }
@@ -1379,7 +1375,6 @@ static int config_parse_env_file(
                         if (feof(f))
                                 break;
 
-                        r = -errno;
                         log_error("[%s:%u] Failed to read environment file '%s', ignoring: %m", filename, line, rvalue);
                         r = 0;
                         goto finish;
@@ -1431,7 +1426,6 @@ static int config_parse_ip_tos(
                 void *userdata) {
 
         int *ip_tos = data, x;
-        int r;
 
         assert(filename);
         assert(lvalue);
@@ -1439,7 +1433,7 @@ static int config_parse_ip_tos(
         assert(data);
 
         if ((x = ip_tos_from_string(rvalue)) < 0)
-                if ((r = safe_atoi(rvalue, &x)) < 0) {
+                if (safe_atoi(rvalue, &x) < 0) {
                         log_error("[%s:%u] Failed to parse IP TOS value, ignoring: %s", filename, line, rvalue);
                         return 0;
                 }
diff --git a/src/manager.c b/src/manager.c
index 013b26b..2714df1 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -2428,7 +2428,6 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
         union sockaddr_union sa;
         int n = 0;
         char *message = NULL;
-        ssize_t r;
 
         /* Don't generate plymouth events if the service was already
          * started and we're just deserializing */
@@ -2472,7 +2471,7 @@ void manager_send_unit_plymouth(Manager *m, Unit *u) {
         }
 
         errno = 0;
-        if ((r = write(fd, message, n + 1)) != n + 1) {
+        if (write(fd, message, n + 1) != n + 1) {
 
                 if (errno != EPIPE &&
                     errno != EAGAIN &&
diff --git a/src/pam-module.c b/src/pam-module.c
index 52507a4..fc3aac1 100644
--- a/src/pam-module.c
+++ b/src/pam-module.c
@@ -46,7 +46,9 @@ static int parse_argv(pam_handle_t *handle,
                       char ***controllers) {
 
         unsigned i;
+#if 0
         bool controller_set = false;
+#endif
 
         assert(argc >= 0);
         assert(argc == 0 || argv);
@@ -104,7 +106,9 @@ static int parse_argv(pam_handle_t *handle,
                                 *controllers = l;
                         }
 
+#if 0
                         controller_set = true;
+#endif
 
                 } else {
                         pam_syslog(handle, LOG_ERR, "Unknown parameter '%s'.", argv[i]);
diff --git a/src/swap.c b/src/swap.c
index 23a98dd..9a253be 100644
--- a/src/swap.c
+++ b/src/swap.c
@@ -1090,7 +1090,7 @@ int swap_fd_event(Manager *m, int events) {
         assert(m);
         assert(events & EPOLLPRI);
 
-        if ((r == swap_load_proc_swaps(m, true)) < 0) {
+        if ((r = swap_load_proc_swaps(m, true)) < 0) {
                 log_error("Failed to reread /proc/swaps: %s", strerror(-r));
 
                 /* Reset flags, just in case, for late calls */
diff --git a/src/sysctl.c b/src/sysctl.c
index 38ea2d1..a8a9422 100644
--- a/src/sysctl.c
+++ b/src/sysctl.c
@@ -43,6 +43,7 @@ static void apply_sysctl(const char *property, const char *value) {
         if (!(p = new(char, sizeof(PROC_SYS_PREFIX) + strlen(property)))) {
                 log_error("Out of memory");
                 exit_code = -ENOMEM;
+                return;
         }
 
         n = stpcpy(p, PROC_SYS_PREFIX);
diff --git a/src/systemctl.c b/src/systemctl.c
index fb34300..8cdc01a 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -502,8 +502,10 @@ static int list_units(DBusConnection *bus, char **args, unsigned n) {
                 c++;
         }
 
-        qsort(unit_infos, c, sizeof(struct unit_info), compare_unit_info);
-        output_units_list(unit_infos, c);
+        if (c > 0) {
+                qsort(unit_infos, c, sizeof(struct unit_info), compare_unit_info);
+                output_units_list(unit_infos, c);
+        }
 
         r = 0;
 
diff --git a/src/tmpfiles.c b/src/tmpfiles.c
index 984eaf0..d242dac 100644
--- a/src/tmpfiles.c
+++ b/src/tmpfiles.c
@@ -474,7 +474,7 @@ static void item_free(Item *i) {
 static int parse_line(const char *fname, unsigned line, const char *buffer, const char *prefix) {
         Item *i;
         char *mode = NULL, *user = NULL, *group = NULL, *age = NULL;
-        int r, n;
+        int r;
 
         assert(fname);
         assert(line >= 1);
@@ -485,19 +485,19 @@ static int parse_line(const char *fname, unsigned line, const char *buffer, cons
                 return -ENOMEM;
         }
 
-        if ((n = sscanf(buffer,
-                        "%c "
-                        "%ms "
-                        "%ms "
-                        "%ms "
-                        "%ms "
-                        "%ms",
-                        &i->type,
-                        &i->path,
-                        &mode,
-                        &user,
-                        &group,
-                        &age)) < 2) {
+        if (sscanf(buffer,
+                   "%c "
+                   "%ms "
+                   "%ms "
+                   "%ms "
+                   "%ms "
+                   "%ms",
+                   &i->type,
+                   &i->path,
+                   &mode,
+                   &user,
+                   &group,
+                   &age) < 2) {
                 log_error("[%s:%u] Syntax error.", fname, line);
                 r = -EIO;
                 goto finish;

commit 0b1724894fb85aa1c07b2619e9269cfafd736956
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jan 22 01:47:37 2011 +0100

    gcc: make gcc shut up

diff --git a/src/cgroup-util.c b/src/cgroup-util.c
index 4cf184a..b68b9ad 100644
--- a/src/cgroup-util.c
+++ b/src/cgroup-util.c
@@ -188,7 +188,7 @@ int cg_kill(const char *controller, const char *path, int sig, bool ignore_self,
         my_pid = getpid();
 
         do {
-                pid_t pid;
+                pid_t pid = 0;
                 done = true;
 
                 if ((r = cg_enumerate_processes(controller, path, &f)) < 0) {
@@ -362,7 +362,7 @@ int cg_migrate(const char *controller, const char *from, const char *to, bool ig
         my_pid = getpid();
 
         do {
-                pid_t pid;
+                pid_t pid = 0;
                 done = true;
 
                 if ((r = cg_enumerate_tasks(controller, from, &f)) < 0) {
@@ -782,9 +782,9 @@ finish:
 }
 
 int cg_is_empty(const char *controller, const char *path, bool ignore_self) {
-        pid_t pid;
+        pid_t pid = 0;
         int r;
-        FILE *f;
+        FILE *f = NULL;
         bool found = false;
 
         assert(controller);
diff --git a/src/util.c b/src/util.c
index d3876de..ef37d05 100644
--- a/src/util.c
+++ b/src/util.c
@@ -250,7 +250,7 @@ int parse_boolean(const char *v) {
 }
 
 int parse_pid(const char *s, pid_t* ret_pid) {
-        unsigned long ul;
+        unsigned long ul = 0;
         pid_t pid;
         int r;
 

commit 1b2700a155eb006d2af720f266bd090784943567
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jan 22 01:44:35 2011 +0100

    build-sys: prep v17

diff --git a/configure.ac b/configure.ac
index 1c44ea6..1879dd9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,7 @@
 
 AC_PREREQ(2.63)
 
-AC_INIT([systemd],[16],[systemd-devel at lists.freedesktop.org])
+AC_INIT([systemd],[17],[systemd-devel at lists.freedesktop.org])
 AC_CONFIG_SRCDIR([src/main.c])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_HEADERS([config.h])

commit 26ea64c786e2996b6c10c71ad332cf0a444311d0
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Jan 22 01:26:17 2011 +0100

    update TODO

diff --git a/TODO b/TODO
index 9ba7221..13a68e8 100644
--- a/TODO
+++ b/TODO
@@ -6,9 +6,12 @@ Bugs:
 * isolate multi-user.target doesn't start a getty at tty1 if we run it from graphical.target
 
 * when plymouth is disabled the console password entry stuff seems to be borked
+  https://bugzilla.redhat.com/show_bug.cgi?id=655538
 
 Features:
 
+* PID heuristik bei Type=forking ausmachbar machen
+
 * maybe introduce ExecRestartPre=
 
 * reload PID file after reload, allow dynamically changing main PIDs



More information about the systemd-commits mailing list