[PATCH 03/12] libmultipath: add two list iteration macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: tang.junhui <tang.junhui@xxxxxxxxxx>

Add two list iteration macros, they are used to iterate list forwards
or backwards from the given begin node to the given end node, which
would be used in merging uevents.

Change-Id: I8bb53fef9276bb62a5e0f4fdac6455086dc03d9b
Signed-off-by: tang.junhui <tang.junhui@xxxxxxxxxx>
---
 libmultipath/list.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/libmultipath/list.h b/libmultipath/list.h
index ceaa381..e728ff0 100644
--- a/libmultipath/list.h
+++ b/libmultipath/list.h
@@ -294,6 +294,18 @@ static inline void list_splice_tail_init(struct list_head *list,
 	     pos = list_entry(pos->member.next, typeof(*pos), member))
 
 /**
+ * list_for_some_entry	-	iterate list of given interval
+ * @pos:	the type * to use as a loop counter.
+ * @from:	the begin node of the iteration.
+ * @to:		the end node of the iteration.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_some_entry(pos, from, to, member)				\
+	for (pos = list_entry((from)->next, typeof(*pos), member);	\
+	     &pos->member != (to);					\
+	     pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
  * list_for_each_entry_reverse - iterate backwards over list of given type.
  * @pos:	the type * to use as a loop counter.
  * @head:	the head for your list.
@@ -305,6 +317,18 @@ static inline void list_splice_tail_init(struct list_head *list,
 	     pos = list_entry(pos->member.prev, typeof(*pos), member))
 
 /**
+ * list_for_some_entry_reverse	-	iterate backwards list of given interval
+ * @pos:	the type * to use as a loop counter.
+ * @from:	the begin node of the iteration.
+ * @to:		the end node of the iteration.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_some_entry_reverse(pos, from, to, member)			\
+	for (pos = list_entry((from)->prev, typeof(*pos), member);	\
+	     &pos->member != (to);					\
+	     pos = list_entry(pos->member.prev, typeof(*pos), member))
+
+/**
  * 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
-- 
2.8.1.windows.1


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel



[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux