From: Alejandro Colomar Date: Sat, 27 May 2023 13:35:13 +0000 (+0200) Subject: realloc(NULL, ...) is equivalent to malloc(...) X-Git-Tag: 4.14.0-rc1~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f2ac1e254044aa7de1bd4b8deb08b8017813f730;p=thirdparty%2Fshadow.git realloc(NULL, ...) is equivalent to malloc(...) Don't have a branch for when the old pointer is NULL. realloc(3) can handle that case just fine. Signed-off-by: Alejandro Colomar --- diff --git a/lib/subordinateio.c b/lib/subordinateio.c index 49356e23a..52d0e33d1 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -315,17 +315,13 @@ static bool have_range(struct commonio_db *db, static bool append_range(struct subid_range **ranges, const struct subordinate_range *new, int n) { - if (!*ranges) { - *ranges = MALLOC(1, struct subid_range); - if (!*ranges) - return false; - } else { - struct subid_range *alloced; - alloced = REALLOC(*ranges, n + 1, struct subid_range); - if (!alloced) - return false; - *ranges = alloced; - } + struct subid_range *alloced; + + alloced = REALLOC(*ranges, n + 1, struct subid_range); + if (!alloced) + return false; + *ranges = alloced; + (*ranges)[n].start = new->start; (*ranges)[n].count = new->count; return true;