diff mbox

[16/34] ptrlist: use iterator API for RESET_PTR_LIST()

Message ID 20170707134002.49500-17-luc.vanoostenryck@gmail.com (mailing list archive)
State Rejected, archived
Headers show

Commit Message

Luc Van Oostenryck July 7, 2017, 1:39 p.m. UTC
---
 ptrlist.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/ptrlist.h b/ptrlist.h
index 32773b378..728f29593 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -140,11 +140,9 @@  static inline void ptr_cur_init(struct ptr_cur *cur, struct ptr_list *head)
 	}
 
 #define DO_RESET(ptr, __cur, CUR_ENTRY)						\
-	do {										\
-		__cur.n = 0;								\
-		__cur.l = __cur.h;							\
-		if (__cur.h) ptr = CUR_ENTRY(&__cur);					\
-	} while (0)
+	if (!ptr_cur_beg(&__cur, (struct ptr_list *)head) ||				\
+	    !ptr_cur_next(&__cur)) ptr = NULL;						\
+	else ptr = CUR_ENTRY(&__cur);
 
 #define DO_FINISH(ptr, __cur)								\
 		(void)(__cur.n); /* Sanity-check nesting */				\