--- ptrlist.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ptrlist.h b/ptrlist.h index 0d17237f5..91019e7c5 100644 --- a/ptrlist.h +++ b/ptrlist.h @@ -111,13 +111,21 @@ static inline void *last_ptr_list(struct ptr_list *list) return __PTR_STRIP_TAG(ptr_cur_entry(&cur)); } +static inline void ptr_cur_init(struct ptr_cur *cur, struct ptr_list *head) +{ + cur->h = head; + cur->l = head; + cur->n = 0; +} + +#define DO_INIT(cur, head) \ + ptr_cur_init(&cur, (struct ptr_list *) head) + #define DO_PREPARE(head, ptr, __cur, PTR_ENTRY) \ do { \ struct ptr_cur __cur; \ - __cur.h = (struct ptr_list *) (head); \ - __cur.l = __cur.h; \ - __cur.n = 0; \ CHECK_TYPE(head,ptr); \ + DO_INIT(__cur, head); \ if (__cur.h) ptr = PTR_ENTRY(__cur.h, 0); \ else ptr = NULL @@ -162,9 +170,8 @@ static inline void *last_ptr_list(struct ptr_list *list) #define DO_FOR_EACH(head, ptr, __cur, PTR_ENTRY) do { \ struct ptr_cur __cur; \ - __cur.h = (struct ptr_list *) (head); \ - __cur.l = __cur.h; \ CHECK_TYPE(head,ptr); \ + DO_INIT(__cur, head); \ if (!__cur.h) break; \ do { \ for (__cur.n = 0; __cur.n < __cur.l->nr; __cur.n++) { \ @@ -177,9 +184,8 @@ static inline void *last_ptr_list(struct ptr_list *list) #define DO_FOR_EACH_REVERSE(head, ptr, __cur, PTR_ENTRY) do { \ struct ptr_cur __cur; \ - __cur.h = (struct ptr_list *) (head); \ - __cur.l = __cur.h; \ CHECK_TYPE(head,ptr); \ + DO_INIT(__cur, head); \ if (!__cur.h) break; \ do { \ __cur.l = __cur.l->prev; \ -- 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