[PATCH 18/34] ptrlist: use iterator for FOR_EACH_PTR_REVERSE()

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

 



---
 ptrlist.h | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/ptrlist.h b/ptrlist.h
index d8b96304f..c3538a260 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -175,30 +175,19 @@ static inline void ptr_cur_init(struct ptr_cur *cur, struct ptr_list *head)
 #define DO_FOR_EACH_REVERSE(head, ptr, __cur, CUR_ENTRY) do {				\
 	struct ptr_cur __cur;								\
 	CHECK_TYPE(head,ptr);								\
-	DO_INIT(__cur, head);								\
-	if (!__cur.h) break;								\
-	do {										\
-		__cur.l = __cur.l->prev;						\
-		__cur.n = __cur.l->nr;							\
-		while (--__cur.n >= 0) {						\
-			ptr = CUR_ENTRY(&__cur);					\
-
+	if (!head) break;								\
+	ptr_cur_end(&__cur, (struct ptr_list *)head);					\
+	while (ptr_cur_prev(&__cur)) {							\
+		ptr = CUR_ENTRY(&__cur);
 
 #define DO_END_FOR_EACH_REVERSE(ptr, __cur)						\
-		}									\
-	} while (__cur.l != __cur.h);							\
+	}										\
 } while (0)
 
 #define DO_REVERSE(ptr, __cur, new, __newcur, CUR_ENTRY) do {				\
 	struct ptr_cur __newcur = __cur;						\
-	new = ptr;									\
-	goto __inside##new;								\
-	do {										\
-		__newcur.l = __newcur.l->prev;						\
-		__newcur.n = __newcur.l->nr;						\
-	__inside##new:									\
-		while (--__newcur.n >= 0) {						\
-			new = CUR_ENTRY(&__newcur);					\
+	while (ptr_cur_prev(&__newcur)) {						\
+		new = CUR_ENTRY(&__newcur);
 
 #define RECURSE_PTR_REVERSE(ptr, new)							\
 	DO_REVERSE(ptr, __cur##ptr,							\
-- 
2.13.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux