[PATCH v2 09/17] ptrlist: simplify DO_NEXT

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

 



The body of this macros is quite complicated, more so than needed.

Simplify it.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 ptrlist.h | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/ptrlist.h b/ptrlist.h
index 185ba4499..3c8c17d09 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -117,18 +117,14 @@ static inline void *last_ptr_list(struct ptr_list *list)
 
 #define DO_NEXT(ptr, __head, __list, __nr, PTR_ENTRY)					\
 		if (ptr) {								\
-			if (++__nr < __list->nr) {					\
-				ptr = PTR_ENTRY(__list,__nr);				\
-			} else {							\
-				__list = __list->next;					\
-				ptr = NULL;						\
-				while (__list->nr == 0 && __list != __head)		\
-					__list = __list->next;				\
-				if (__list != __head) {					\
-					__nr = 0;					\
-					ptr = PTR_ENTRY(__list,0);			\
+			do {								\
+				if (++__nr < __list->nr) {				\
+					ptr = PTR_ENTRY(__list,__nr);			\
+					break;						\
 				}							\
-			}								\
+				ptr = NULL;						\
+				__nr = -1;						\
+			} while ((__list = __list->next) != __head);			\
 		}
 
 #define DO_RESET(ptr, __head, __list, __nr, PTR_ENTRY)					\
-- 
2.17.1

--
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