Thread (9 messages) flat view 9 messages, 5 authors, 2015-12-10
STALE3918d

[PATCH 1/4] list: introduce list_is_first()

From: Geliang Tang <hidden>
Date: 2015-12-10 14:21:28
Also in: lkml, netfilter-devel
Subsystem: the rest · Maintainer: Linus Torvalds

We already have list_is_last(), it makes sense to also add
list_is_first() for consistency. This list utility function
to check for first element in a list.

Signed-off-by: Geliang Tang <redacted>
---
 include/linux/list.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff --git a/include/linux/list.h b/include/linux/list.h
index 5356f4d..2c43ef4 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -170,6 +170,17 @@ static inline void list_move_tail(struct list_head *list,
 }
 
 /**
+ * list_is_first - tests whether @list is the first entry in list @head
+ * @list: the entry to test
+ * @head: the head of the list
+ */
+static inline int list_is_first(const struct list_head *list,
+				const struct list_head *head)
+{
+	return list->prev == head;
+}
+
+/**
  * list_is_last - tests whether @list is the last entry in list @head
  * @list: the entry to test
  * @head: the head of the list
-- 
2.5.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help