summaryrefslogtreecommitdiff
path: root/src/machine
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2015-11-02 11:21:18 +0100
committerDaniel Mack <github@zonque.org>2015-11-02 11:21:18 +0100
commit6b61ae72fae00a94ebd36bee402c5a84c6aba14b (patch)
treea93b642ac38ce6907dbfc8bba0d2db378da45829 /src/machine
parent86b4428a58739a3899f0d2cee5bf78ba861d16b7 (diff)
parent75a8fd6ac8a5c7c2e8b8d9eb066ccd477b2e1eb5 (diff)
Merge pull request #1739 from ssahani/word-machine
machine: : port to extract_first_word
Diffstat (limited to 'src/machine')
-rw-r--r--src/machine/machine.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/machine/machine.c b/src/machine/machine.c
index fa6b70f788..df8391c996 100644
--- a/src/machine/machine.c
+++ b/src/machine/machine.c
@@ -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;