summaryrefslogtreecommitdiff
path: root/lib/linklist.c
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2018-06-29 13:28:28 -0400
committerGitHub <noreply@github.com>2018-06-29 13:28:28 -0400
commit11f13d233314c44a639ec610a7c2fee39e62d4f9 (patch)
tree3120a421f5eeba809370f9521173bae786ec1047 /lib/linklist.c
parent33bce3794733f7458700468265f9b283d4c7688f (diff)
parent0866cdaf3e9f0ac0d779a14da69262c1fe8d54d9 (diff)
Merge pull request #2578 from pacovn/Coverity_1453455_Dereference_null_return_value
bgpd: null check (Coverity 1453455)
Diffstat (limited to 'lib/linklist.c')
-rw-r--r--lib/linklist.c22
1 files changed, 3 insertions, 19 deletions
diff --git a/lib/linklist.c b/lib/linklist.c
index 2cfa3e7482..86649dd495 100644
--- a/lib/linklist.c
+++ b/lib/linklist.c
@@ -186,26 +186,10 @@ void listnode_move_to_tail(struct list *l, struct listnode *n)
void listnode_delete(struct list *list, void *val)
{
- struct listnode *node;
+ struct listnode *node = listnode_lookup(list, val);
- assert(list);
- for (node = list->head; node; node = node->next) {
- if (node->data == val) {
- if (node->prev)
- node->prev->next = node->next;
- else
- list->head = node->next;
-
- if (node->next)
- node->next->prev = node->prev;
- else
- list->tail = node->prev;
-
- list->count--;
- listnode_free(node);
- return;
- }
- }
+ if (node)
+ list_delete_node(list, node);
}
void *listnode_head(struct list *list)