All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Thomas Huth" <thuth@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH] softmmu/physmem: Hint notifier is not NULL in as_translate_for_iotlb()
Date: Sun, 17 Jan 2021 17:07:54 +0100	[thread overview]
Message-ID: <20210117160754.4086411-1-f4bug@amsat.org> (raw)

When using GCC 10.2 configured with --extra-cflags=-Os, we get:

  softmmu/physmem.c: In function ‘address_space_translate_for_iotlb’:
  softmmu/physmem.c:643:26: error: ‘notifier’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    643 |         notifier->active = true;
        |                          ^
  softmmu/physmem.c:608:23: note: ‘notifier’ was declared here
    608 |     TCGIOMMUNotifier *notifier;
        |                       ^~~~~~~~

Insert assertions as hint to the compiler that 'notifier' can
not be NULL there.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
Yet another hole in our CI.
---
 softmmu/physmem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 6301f4f0a5c..65602ed548e 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -605,7 +605,7 @@ static void tcg_register_iommu_notifier(CPUState *cpu,
      * when the IOMMU tells us the mappings we've cached have changed.
      */
     MemoryRegion *mr = MEMORY_REGION(iommu_mr);
-    TCGIOMMUNotifier *notifier;
+    TCGIOMMUNotifier *notifier = NULL;
     int i;
 
     for (i = 0; i < cpu->iommu_notifiers->len; i++) {
@@ -638,6 +638,7 @@ static void tcg_register_iommu_notifier(CPUState *cpu,
         memory_region_register_iommu_notifier(notifier->mr, &notifier->n,
                                               &error_fatal);
     }
+    assert(notifier != NULL);
 
     if (!notifier->active) {
         notifier->active = true;
-- 
2.26.2



             reply	other threads:[~2021-01-17 16:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-17 16:07 Philippe Mathieu-Daudé [this message]
2021-01-17 16:47 ` [PATCH] softmmu/physmem: Hint notifier is not NULL in as_translate_for_iotlb() Peter Maydell
2021-01-17 16:58   ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210117160754.4086411-1-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=alex.bennee@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.