diff options
author | Tom Gundersen <teg@jklm.no> | 2015-11-11 02:22:11 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-11-11 02:22:11 +0100 |
commit | 8b61781d80ab91e38bd2502a8e1ad612607a29e1 (patch) | |
tree | 41b2de1ee24b87098b9f73bcad0aa38fff256778 /src/network/networkctl.c | |
parent | 6899d2bfb03e7c55d477f0ca5eae43f04db16653 (diff) | |
parent | af40397dea5579b5a3c2b369936281904f05a801 (diff) |
Merge pull request #1655 from ssahani/net
network: port to extract_first_word
Diffstat (limited to 'src/network/networkctl.c')
-rw-r--r-- | src/network/networkctl.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/network/networkctl.c b/src/network/networkctl.c index ba7e3ba74a..446b048ef1 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -910,12 +910,10 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) { _cleanup_netlink_message_unref_ sd_netlink_message *req = NULL, *reply = NULL; _cleanup_netlink_unref_ sd_netlink *rtnl = NULL; _cleanup_free_ LinkInfo *links = NULL; - const char *state, *word; - double ttl = -1; uint32_t capability; int i, r, c, j; - size_t ll; + const char *p; char **s; pager_open_if_enabled(); @@ -956,14 +954,19 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) { return -ENOMEM; STRV_FOREACH(s, l) { - FOREACH_WORD_QUOTED(word, ll, *s, state) { - _cleanup_free_ char *t = NULL, *a = NULL, *b = NULL; - t = strndup(word, ll); - if (!t) - return -ENOMEM; + p = *s; + for (;;) { + _cleanup_free_ char *a = NULL, *b = NULL, *word = NULL; + + r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES); + if (r < 0) + return log_error_errno(r, "Failed to parse LLDP syntax \"%s\": %m", *s); + + if (r == 0) + break; - r = split_pair(t, "=", &a, &b); + r = split_pair(word, "=", &a, &b); if (r < 0) continue; |