From: Vincent Bernat Date: Sun, 21 Mar 2021 12:56:19 +0000 (+0100) Subject: client: make it easier for Coverity to understand commands_new() X-Git-Tag: 1.0.9~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=61979752198d60d37c453c45c197e9f506ef8e51;p=thirdparty%2Flldpd.git client: make it easier for Coverity to understand commands_new() Never returning NULL is not enough to make Coverity understands we don't leak anything. Remove the branch in commands_new() as it must never happen, except for the root node. --- diff --git a/src/client/commands.c b/src/client/commands.c index 7e35ecb1..82317679 100644 --- a/src/client/commands.c +++ b/src/client/commands.c @@ -99,7 +99,10 @@ struct cmd_node { struct cmd_node* commands_root(void) { - return commands_new(NULL, NULL, NULL, NULL, NULL, NULL); + struct cmd_node *new = calloc(1, sizeof(struct cmd_node)); + if (new == NULL) fatalx("lldpctl", "out of memory"); + TAILQ_INIT(&new->subentries); + return new; } /** @@ -175,8 +178,7 @@ commands_new(struct cmd_node *root, new->execute = execute; new->arg = arg; TAILQ_INIT(&new->subentries); - if (root != NULL) - TAILQ_INSERT_TAIL(&root->subentries, new, next); + TAILQ_INSERT_TAIL(&root->subentries, new, next); return new; }