Skip to contentSkip to conversation

backport 2.6 changes to 2.4

PATCH Applied Amir Noam 1 participant 1 message Jul 30, 2003

Subsystems (2)
lore
Share & tools
lore

Amir Noam

author
#0 lore raw

PATCH 1/5 backport 2.6 changes to 2.4

Add list_for_each_entry_safe()

Amir

include/linux/list.h +13 -0
diff -Nuarp linux-2.4.22-pre9/include/linux/list.h linux-2.4.22-pre9-devel/include/linux/list.h
@@ -227,6 +227,19 @@ static inline void list_splice_init(stru
 	     pos = list_entry(pos->member.next, typeof(*pos), member),	\
 		     prefetch(pos->member.next))
 
+/**
+ * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @pos:	the type * to use as a loop counter.
+ * @n:		another type * to use as temporary storage
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_safe(pos, n, head, member)			\
+	for (pos = list_entry((head)->next, typeof(*pos), member),	\
+		n = list_entry(pos->member.next, typeof(*pos), member);	\
+	     &pos->member != (head); 					\
+	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
 #endif /* __KERNEL__ || _LVM_H_INCLUDE */
 
 #endif