From: Lennart Poettering Date: Tue, 21 Feb 2017 17:11:12 +0000 (+0100) Subject: Revert "basic/strv: allow NULLs to be inserted into strv" X-Git-Tag: v233.3~41 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=60b25855d3d4720d02e10031d5bbaf17d97524d2;p=elogind.git Revert "basic/strv: allow NULLs to be inserted into strv" This reverts commit 18f71a3c8174774c5386c4aba94d54f3b5c36a84. According to @keszybz we don't need this anymore, hence drop it: https://github.com/elogind/elogind/pull/5131/commits/18f71a3c8174774c5386c4aba94d54f3b5c36a84#r102232368 --- diff --git a/src/basic/strv.c b/src/basic/strv.c index 4d3cce826..c98e956fd 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -572,6 +572,9 @@ int strv_extend_front(char ***l, const char *value) { /* Like strv_extend(), but prepends rather than appends the new entry */ + if (!value) + return 0; + n = strv_length(*l); /* Increase and overflow check. */ @@ -579,12 +582,9 @@ int strv_extend_front(char ***l, const char *value) { if (m < n) return -ENOMEM; - if (value) { - v = strdup(value); - if (!v) - return -ENOMEM; - } else - v = NULL; + v = strdup(value); + if (!v) + return -ENOMEM; c = realloc_multiply(*l, sizeof(char*), m); if (!c) {