Re: [PATCH 02/13] ptrlist: when possible use the real type of the list

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

 



On Tue, Jun 12, 2018 at 04:00:37PM +0100, Ramsay Jones wrote:
> 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
> > @@ -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; ?

Mmmm, yes, but only because head could have some side effects
(but normally it's not the case).

Thanks for noticing that.

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