[Qemu-devel] [PATCH] queue: fix QTAILQ_FOREACH_REVERSE_SAFE

Paolo Bonzini posted 1 patch 5 years, 2 months ago
Test docker-mingw@fedora passed
Test asan passed
Test checkpatch passed
Test docker-clang@ubuntu passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1549294992-46543-1-git-send-email-pbonzini@redhat.com
include/qemu/queue.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[Qemu-devel] [PATCH] queue: fix QTAILQ_FOREACH_REVERSE_SAFE
Posted by Paolo Bonzini 5 years, 2 months ago
The iteration was stopping as soon as prev_var was set to NULL, and
therefore it skipped the first element.  Fortunately, or unfortunately,
we have only one use of QTAILQ_FOREACH_REVERSE_SAFE.  Thus this only
showed up as incorrect register preferences on the very first translation
block that was compiled.

Reported-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu/queue.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/qemu/queue.h b/include/qemu/queue.h
index 1f8e219..0379bd8 100644
--- a/include/qemu/queue.h
+++ b/include/qemu/queue.h
@@ -439,7 +439,7 @@ union {                                                                 \
 
 #define QTAILQ_FOREACH_REVERSE_SAFE(var, head, field, prev_var)         \
         for ((var) = QTAILQ_LAST(head);                                 \
-             (var) && ((prev_var) = QTAILQ_PREV(var, field));           \
+             (var) && ((prev_var) = QTAILQ_PREV(var, field), 1);        \
              (var) = (prev_var))
 
 /*
-- 
1.8.3.1


Re: [Qemu-devel] [PATCH] queue: fix QTAILQ_FOREACH_REVERSE_SAFE
Posted by Emilio G. Cota 5 years, 2 months ago
On Mon, Feb 04, 2019 at 16:43:12 +0100, Paolo Bonzini wrote:
> The iteration was stopping as soon as prev_var was set to NULL, and
> therefore it skipped the first element.  Fortunately, or unfortunately,
> we have only one use of QTAILQ_FOREACH_REVERSE_SAFE.  Thus this only
> showed up as incorrect register preferences on the very first translation
> block that was compiled.
> 
> Reported-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Emilio G. Cota <cota@braap.org>

		E.

Re: [Qemu-devel] [PATCH] queue: fix QTAILQ_FOREACH_REVERSE_SAFE
Posted by Richard Henderson 5 years, 2 months ago
On 2/4/19 3:43 PM, Paolo Bonzini wrote:
> The iteration was stopping as soon as prev_var was set to NULL, and
> therefore it skipped the first element.  Fortunately, or unfortunately,
> we have only one use of QTAILQ_FOREACH_REVERSE_SAFE.  Thus this only
> showed up as incorrect register preferences on the very first translation
> block that was compiled.
> 
> Reported-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  include/qemu/queue.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~