Merge pull request #1739 from ssahani/word-machine
machine: : port to extract_first_word
This commit is contained in:
commit
6b61ae72fa
|
@ -42,6 +42,7 @@
|
||||||
#include "terminal-util.h"
|
#include "terminal-util.h"
|
||||||
#include "unit-name.h"
|
#include "unit-name.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "extract-word.h"
|
||||||
|
|
||||||
Machine* machine_new(Manager *manager, MachineClass class, const char *name) {
|
Machine* machine_new(Manager *manager, MachineClass class, const char *name) {
|
||||||
Machine *m;
|
Machine *m;
|
||||||
|
@ -312,17 +313,23 @@ int machine_load(Machine *m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (netif) {
|
if (netif) {
|
||||||
size_t l, allocated = 0, nr = 0;
|
size_t allocated = 0, nr = 0;
|
||||||
const char *word, *state;
|
const char *p;
|
||||||
int *ni = NULL;
|
int *ni = NULL;
|
||||||
|
|
||||||
FOREACH_WORD(word, l, netif, state) {
|
p = netif;
|
||||||
char buf[l+1];
|
for(;;) {
|
||||||
|
_cleanup_free_ char *word = NULL;
|
||||||
int ifi;
|
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;
|
continue;
|
||||||
if (ifi <= 0)
|
if (ifi <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue