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.
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;
}
/**
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;
}