qemu-block
[Top][All Lists]
Advanced

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

Re: [PATCH 1/2] qemu/queue.h: clear linked list pointers on remove


From: Stefan Hajnoczi
Subject: Re: [PATCH 1/2] qemu/queue.h: clear linked list pointers on remove
Date: Tue, 25 Feb 2020 09:01:17 +0000

On Mon, Feb 24, 2020 at 12:51:54PM +0100, Philippe Mathieu-Daudé wrote:
> On 2/24/20 11:34 AM, Stefan Hajnoczi wrote:
> > @@ -304,8 +310,10 @@ struct {                                               
> >                  \
> >   } while (/*CONSTCOND*/0)
> >   #define QSIMPLEQ_REMOVE_HEAD(head, field) do {                          \
> > -    if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL)\
> > +    typeof((head)->sqh_first) elm = (head)->sqh_first;                  \
> > +    if (((head)->sqh_first = elm->field.sqe_next) == NULL)              \
> >           (head)->sqh_last = &(head)->sqh_first;                          \
> 
> Here you check elm for NULL ...
> 
> > +    elm->field.sqe_next = NULL;                                         \
> 
> ... then you assign it.

The sqe_next field is copied into the head.  If this was the last
element in the list then the head's sqh_last needs to be fixed up.

Finally we clear the linked list sqe_next pointer inside the element
itself (which is no longer in the list).

Is there an issue?

Stefan

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]