[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] rng: switch request queue to QSIMPLEQ
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH] rng: switch request queue to QSIMPLEQ |
Date: |
Fri, 4 Mar 2016 10:12:19 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 |
On 04/03/2016 09:04, Ladi Prosek wrote:
>>> >> + QSIMPLEQ_INIT(&s->requests);
>>> >> }
>> >
>> > This init here isn't necessary, the accessors for the queue will take
>> > care of this.
> We are basically purging the queue here and we want to leave it in a
> consistent state. Without the QSIMPLEQ_INIT the queue head would
> become a pair of dangling pointers. Let me know if I misunderstood
> your comment.
It wouldn't, check out QSIMPLEQ_REMOVE_HEAD:
#define QSIMPLEQ_REMOVE_HEAD(head, field) do {
if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL)
(head)->sqh_last = &(head)->sqh_first;
} while (/*CONSTCOND*/0)
The queue would become { NULL, &s->requests.sqh_first }. So the
QSIMPLEQ_INIT is indeed redundant.
Paolo
Re: [Qemu-devel] [PATCH] rng: switch request queue to QSIMPLEQ, Amit Shah, 2016/03/04