]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
machine: : port to extract_first_word 1739/head
authorSusant Sahani <ssahani@gmail.com>
Sat, 31 Oct 2015 22:06:07 +0000 (03:36 +0530)
committerSusant Sahani <ssahani@gmail.com>
Sat, 31 Oct 2015 22:06:27 +0000 (03:36 +0530)
src/machine/machine.c

index fa6b70f788cb46c135ad9777b244b1783be7723c..df8391c996c1a3ff9e70cbabd81469b0a1d301b7 100644 (file)
@@ -42,6 +42,7 @@
 #include "terminal-util.h"
 #include "unit-name.h"
 #include "util.h"
+#include "extract-word.h"
 
 Machine* machine_new(Manager *manager, MachineClass class, const char *name) {
         Machine *m;
@@ -312,17 +313,23 @@ int machine_load(Machine *m) {
         }
 
         if (netif) {
-                size_t l, allocated = 0, nr = 0;
-                const char *word, *state;
+                size_t allocated = 0, nr = 0;
+                const char *p;
                 int *ni = NULL;
 
-                FOREACH_WORD(word, l, netif, state) {
-                        char buf[l+1];
+                p = netif;
+                for(;;) {
+                        _cleanup_free_ char *word = NULL;
                         int ifi;
 
-                        *(char*) (mempcpy(buf, word, l)) = 0;
+                        r = extract_first_word(&p, &word, NULL, 0);
+                        if (r < 0)
+                                return log_error_errno(r, "Failed to parse NETIF: %s", netif);
 
-                        if (safe_atoi(buf, &ifi) < 0)
+                        if (r == 0)
+                                break;
+
+                        if (safe_atoi(word, &ifi) < 0)
                                 continue;
                         if (ifi <= 0)
                                 continue;