From c58bd76a6af673196ad283131cbe3edcf2bf6291 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Fri, 11 Nov 2016 12:58:41 -0500 Subject: tree-wide: make invocations of extract_first_word more uniform (#4627) extract_first_words deals fine with the string being NULL, so drop the upfront check for that. --- src/libsystemd/sd-network/sd-network.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/libsystemd/sd-network/sd-network.c') diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index f8e18f23fd..0d8d99c56d 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -224,13 +224,8 @@ static int network_link_get_ifindexes(int ifindex, const char *key, int **ret) { return -ENODATA; if (r < 0) return r; - if (isempty(s)) { - *ret = NULL; - return 0; - } - x = s; - for (;;) { + for (x = s;;) { _cleanup_free_ char *word = NULL; r = extract_first_word(&x, &word, NULL, 0); @@ -243,15 +238,14 @@ static int network_link_get_ifindexes(int ifindex, const char *key, int **ret) { if (r < 0) return r; - if (!GREEDY_REALLOC(ifis, allocated, c + 1)) + if (!GREEDY_REALLOC(ifis, allocated, c + 2)) return -ENOMEM; ifis[c++] = ifindex; } - if (!GREEDY_REALLOC(ifis, allocated, c + 1)) - return -ENOMEM; - ifis[c] = 0; /* Let's add a 0 ifindex to the end, to be nice*/ + if (ifis) + ifis[c] = 0; /* Let's add a 0 ifindex to the end, to be nice*/ *ret = ifis; ifis = NULL; -- cgit v1.2.3-54-g00ecf