Skip to content
Snippets Groups Projects
Commit eea0bd93 authored by Nikolay Shirokovskiy's avatar Nikolay Shirokovskiy Committed by Vladimir Davydov
Browse files

stailq: add non empty list assertion to stailq_shift

stailq_shift expects list to be non empty. Let's add assertion.

This patch addresses coverity complains 1526815 and 1526816 (dup).
https://scan7.scan.coverity.com/reports.htm#v43693/p13437/fileInstanceId=129122176&defectInstanceId=18601010&mergedDefectId=1526815

Closes #7913

NO_DOC=code health
NO_CHANGELOG=code health
NO_TEST=code health
parent 044c1e19
No related branches found
No related tags found
No related merge requests found
......@@ -79,6 +79,15 @@ stailq_create(struct stailq *head)
head->last = &head->first;
}
/**
* return TRUE if list is empty
*/
static inline int
stailq_empty(struct stailq *head)
{
return head->first.value == NULL;
}
/**
* Add an item to list head
*/
......@@ -97,6 +106,7 @@ stailq_add(struct stailq *head, struct stailq_entry *item)
inline static struct stailq_entry *
stailq_shift(struct stailq *head)
{
assert(!stailq_empty(head));
struct stailq_entry_ptr shift = head->first;
head->first = head->first.value->next;
if (head->first.value == NULL)
......@@ -156,15 +166,6 @@ stailq_next(struct stailq_entry *item)
return item->next.value;
}
/**
* return TRUE if list is empty
*/
inline static int
stailq_empty(struct stailq *head)
{
return head->first.value == NULL;
}
/*
* Singly-linked Tail queue functions.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment