]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: small cleanups in get_controllers()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 11 Oct 2016 18:41:30 +0000 (14:41 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 11 Oct 2016 20:46:58 +0000 (16:46 -0400)
- check for oom after strdup
- no need to truncate the line since we're only extracting one field anyway
- use STR_IN_SET

src/nspawn/nspawn-mount.c

index 0be06c8c0953edddd8324fc67916a4639aad5d69..02dc94cfe1bac31c5c8cf226259339bac381424e 100644 (file)
@@ -637,8 +637,6 @@ static int get_controllers(Set *subsystems) {
                 int r;
                 char *e, *l, *p;
 
-                truncate_nl(line);
-
                 l = strchr(line, ':');
                 if (!l)
                         continue;
@@ -650,10 +648,13 @@ static int get_controllers(Set *subsystems) {
 
                 *e = 0;
 
-                if (streq(l, "") || streq(l, "name=systemd"))
+                if (STR_IN_SET(l, "", "name=systemd"))
                         continue;
 
                 p = strdup(l);
+                if (!p)
+                        return -ENOMEM;
+
                 r = set_consume(subsystems, p);
                 if (r < 0)
                         return r;