On 11/06/18 02:51, Luc Van Oostenryck wrote: > The macros doing the list walking used to be done, not on the declared > list's type but on the concrete & generic type 'struct ptr_list'. > This incurs casting between the real and the generic type. > > Now that the declared type matches ... these casts are not needed > anymore and the real declared type can be used instead. > > Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> > --- > ptrlist.h | 26 +++++++++++++------------- > 1 file changed, 13 insertions(+), 13 deletions(-) > > diff --git a/ptrlist.h b/ptrlist.h > index 6cec720e0..4e985d45b 100644 > --- a/ptrlist.h > +++ b/ptrlist.h > @@ -98,7 +98,7 @@ static inline void *last_ptr_list(struct ptr_list *list) > } > > #define PTR_DEREF(__head, idx, PTR_ENTRY) ({ \ > - struct ptr_list *__list = __head; \ > + __typeof__(__head) __list = __head; \ > while (__list && __list->nr == 0) { \ > __list = __list->next; \ > if (__list == __head) \ > @@ -109,8 +109,8 @@ static inline void *last_ptr_list(struct ptr_list *list) > > #define DO_PREPARE(head, ptr, __head, __list, __nr, PTR_ENTRY) \ > do { \ > - struct ptr_list *__head = (struct ptr_list *) (head); \ > - struct ptr_list *__list = __head; \ > + __typeof__(head) __head = head; \ > + __typeof__(head) __list = head; \ Hmm, shouldn't this be: __typeof__(head) __list = __head; ? > int __nr = 0; \ > CHECK_TYPE(head,ptr); \ > ptr = PTR_DEREF(__head, 0, PTR_ENTRY); \ > @@ -155,8 +155,8 @@ static inline void *last_ptr_list(struct ptr_list *list) > DO_FINISH(ptr, __head##ptr, __list##ptr, __nr##ptr) > > #define DO_FOR_EACH(head, ptr, __head, __list, __nr, PTR_ENTRY) do { \ > - struct ptr_list *__head = (struct ptr_list *) (head); \ > - struct ptr_list *__list = __head; \ > + __typeof__(head) __head = head; \ > + __typeof__(head) __list = head; \ ditto. > CHECK_TYPE(head,ptr); \ > if (__head) { \ > do { int __nr; \ > @@ -176,8 +176,8 @@ static inline void *last_ptr_list(struct ptr_list *list) > } while (0) > > #define DO_FOR_EACH_REVERSE(head, ptr, __head, __list, __nr, PTR_ENTRY) do { \ > - struct ptr_list *__head = (struct ptr_list *) (head); \ > - struct ptr_list *__list = __head; \ > + __typeof__(head) __head = head; \ > + __typeof__(head) __list = head; \ ditto. [because of the long lines, these are somewhat hard to read!] ATB, Ramsay -- 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