util: Add list_is_singular() helper function

Returns whether the list has exactly one element.

Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
Eduardo Lima Mitev 2015-10-23 16:31:41 +02:00
parent 94ff35204d
commit fb3b5669ce

View file

@ -99,6 +99,14 @@ static inline bool list_empty(struct list_head *list)
return list->next == list;
}
/**
* Returns whether the list has exactly one element.
*/
static inline bool list_is_singular(const struct list_head *list)
{
return list->next != NULL && list->next->next == list;
}
static inline unsigned list_length(struct list_head *list)
{
struct list_head *node;