The name PTR_ENTRY is used for two closely related things: 1) as a macro which dereference an entry from a list *and* take care to strip any tag from this entry 2) a parameter name in a lot of internal prtlist macros which will correspond to either PTR_ENTRY_NOTAG() or .. PTR_ENTRY() This can be quite confusing Lift the confusion by rename the macro PTR_ENTRY() to PTR_ENTRY_UNTAG() so that the two uses have now a different name and which self-document the effect of this macro. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- ptrlist.h | 18 +++++++++--------- sort.c | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ptrlist.h b/ptrlist.h index e6e2e6169..60e43e553 100644 --- a/ptrlist.h +++ b/ptrlist.h @@ -63,7 +63,7 @@ extern int linearize_ptr_list(struct ptr_list *, void **, int); #define PTR_UNTAG(p) ((void*)(~3UL & (unsigned long)(p))) #define PTR_ENTRY_NOTAG(h,i) ((h)->list[i]) -#define PTR_ENTRY(h,i) PTR_UNTAG((h)->list[i]) +#define PTR_ENTRY_UNTAG(h,i) PTR_UNTAG((h)->list[i]) static inline void *first_ptr_list(struct ptr_list *list) { @@ -77,7 +77,7 @@ static inline void *first_ptr_list(struct ptr_list *list) if (list == head) return NULL; } - return PTR_ENTRY(list, 0); + return PTR_ENTRY_UNTAG(list, 0); } static inline void *last_ptr_list(struct ptr_list *list) @@ -92,7 +92,7 @@ static inline void *last_ptr_list(struct ptr_list *list) return NULL; list = list->prev; } - return PTR_ENTRY(list, list->nr-1); + return PTR_ENTRY_UNTAG(list, list->nr-1); } #define PTR_DEREF(__head, idx, PTR_ENTRY) ({ \ @@ -141,13 +141,13 @@ static inline void *last_ptr_list(struct ptr_list *list) } while (0) #define PREPARE_PTR_LIST(head, ptr) \ - DO_PREPARE(head, ptr, __head##ptr, __list##ptr, __nr##ptr, PTR_ENTRY) + DO_PREPARE(head, ptr, __head##ptr, __list##ptr, __nr##ptr, PTR_ENTRY_UNTAG) #define NEXT_PTR_LIST(ptr) \ - DO_NEXT(ptr, __head##ptr, __list##ptr, __nr##ptr, PTR_ENTRY) + DO_NEXT(ptr, __head##ptr, __list##ptr, __nr##ptr, PTR_ENTRY_UNTAG) #define RESET_PTR_LIST(ptr) \ - DO_RESET(ptr, __head##ptr, __list##ptr, __nr##ptr, PTR_ENTRY) + DO_RESET(ptr, __head##ptr, __list##ptr, __nr##ptr, PTR_ENTRY_UNTAG) #define FINISH_PTR_LIST(ptr) \ DO_FINISH(ptr, __head##ptr, __list##ptr, __nr##ptr) @@ -216,13 +216,13 @@ static inline void *last_ptr_list(struct ptr_list *list) #define RECURSE_PTR_REVERSE(ptr, new) \ DO_REVERSE(ptr, __head##ptr, __list##ptr, __nr##ptr, \ - new, __head##new, __list##new, __nr##new, PTR_ENTRY) + new, __head##new, __list##new, __nr##new, PTR_ENTRY_UNTAG) #define DO_THIS_ADDRESS(ptr, __head, __list, __nr) \ ((__typeof__(&(ptr))) (__list->list + __nr)) #define FOR_EACH_PTR(head, ptr) \ - DO_FOR_EACH(head, ptr, __head##ptr, __list##ptr, __nr##ptr, PTR_ENTRY) + DO_FOR_EACH(head, ptr, __head##ptr, __list##ptr, __nr##ptr, PTR_ENTRY_UNTAG) #define END_FOR_EACH_PTR(ptr) \ DO_END_FOR_EACH(ptr, __head##ptr, __list##ptr, __nr##ptr) @@ -233,7 +233,7 @@ static inline void *last_ptr_list(struct ptr_list *list) #define END_FOR_EACH_PTR_NOTAG(ptr) END_FOR_EACH_PTR(ptr) #define FOR_EACH_PTR_REVERSE(head, ptr) \ - DO_FOR_EACH_REVERSE(head, ptr, __head##ptr, __list##ptr, __nr##ptr, PTR_ENTRY) + DO_FOR_EACH_REVERSE(head, ptr, __head##ptr, __list##ptr, __nr##ptr, PTR_ENTRY_UNTAG) #define END_FOR_EACH_PTR_REVERSE(ptr) \ DO_END_FOR_EACH_REVERSE(ptr, __head##ptr, __list##ptr, __nr##ptr) diff --git a/sort.c b/sort.c index 430ba4478..987199eb3 100644 --- a/sort.c +++ b/sort.c @@ -138,7 +138,7 @@ merge_block_seqs (struct ptr_list *b1, int n, // Do a quick skip in case entire blocks from b1 are // already less than smallest element in b2. while (b1->nr == 0 || - cmp (PTR_ENTRY(b1, b1->nr - 1), PTR_ENTRY(b2,0)) < 0) { + cmp (PTR_ENTRY_UNTAG(b1, b1->nr - 1), PTR_ENTRY_UNTAG(b2,0)) < 0) { // printf ("Skipping whole block.\n"); BEEN_THERE('H'); b1 = b1->next; @@ -149,8 +149,8 @@ merge_block_seqs (struct ptr_list *b1, int n, } while (1) { - const void *d1 = PTR_ENTRY(b1,i1); - const void *d2 = PTR_ENTRY(b2,i2); + const void *d1 = PTR_ENTRY_UNTAG(b1,i1); + const void *d2 = PTR_ENTRY_UNTAG(b2,i2); assert (i1 >= 0 && i1 < b1->nr); assert (i2 >= 0 && i2 < b2->nr); -- 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