qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Zhao Liu <zhao1.liu@intel.com>,
	Laurent Vivier <laurent@vivier.eu>,
	Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH v2] hw/nubus/nubus-virtio-mmio: Fix missing ERRP_GUARD() in nubus_virtio_mmio_realize()
Date: Tue, 23 Jul 2024 20:26:08 +0200	[thread overview]
Message-ID: <bc14cdd1-35ca-4fc8-b67b-57856c49b7d4@linaro.org> (raw)
In-Reply-To: <de954795-ecec-435e-8166-989296c56bfd@linaro.org>

On 23/7/24 18:10, Philippe Mathieu-Daudé wrote:
> On 23/7/24 18:18, Zhao Liu wrote:
>> According to the comment in qapi/error.h, dereferencing @errp requires
>> ERRP_GUARD():
>>
>> * = Why, when and how to use ERRP_GUARD() =
>> *
>> * Without ERRP_GUARD(), use of the @errp parameter is restricted:
>> * - It must not be dereferenced, because it may be null.
>> ...
>> * ERRP_GUARD() lifts these restrictions.
>> *
>> * To use ERRP_GUARD(), add it right at the beginning of the function.
>> * @errp can then be used without worrying about the argument being
>> * NULL or &error_fatal.
>> *
>> * Using it when it's not needed is safe, but please avoid cluttering
>> * the source with useless code.
>>
>> In nubus_virtio_mmio_realize(), @errp is dereferenced without
>> ERRP_GUARD().
>>
>> Although nubus_virtio_mmio_realize() - as a DeviceClass.realize()
>> method - is never passed a null @errp argument, it should follow the
>> rules on @errp usage.  Add the ERRP_GUARD() there.
>>
>> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
>> ---
>> v2: Used Markus' words in commit message and added his r/b tag.
>> ---
>>   hw/nubus/nubus-virtio-mmio.c | 1 +
>>   1 file changed, 1 insertion(+)
> 
> Patch queued, thanks!

Squashing:

-- >8 --
diff --git a/hw/nubus/nubus-virtio-mmio.c b/hw/nubus/nubus-virtio-mmio.c
index a5558d3ec28..7a98731c451 100644
--- a/hw/nubus/nubus-virtio-mmio.c
+++ b/hw/nubus/nubus-virtio-mmio.c
@@ -7,6 +7,7 @@
   */

  #include "qemu/osdep.h"
+#include "qapi/error.h"
  #include "hw/nubus/nubus-virtio-mmio.h"

---

to avoid:

../hw/nubus/nubus-virtio-mmio.c:26:5: error: call to undeclared function 
'ERRP_GUARD'; ISO C99 and later do not support implicit function 
declarations [-Wimplicit-function-declaration]
     ERRP_GUARD();
     ^
1 error generated.

Better to test your patches ;)

Regards,

Phil.


      reply	other threads:[~2024-07-23 18:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-23 16:18 [PATCH v2] hw/nubus/nubus-virtio-mmio: Fix missing ERRP_GUARD() in nubus_virtio_mmio_realize() Zhao Liu
2024-07-23 16:10 ` Philippe Mathieu-Daudé
2024-07-23 18:26   ` Philippe Mathieu-Daudé [this message]

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=bc14cdd1-35ca-4fc8-b67b-57856c49b7d4@linaro.org \
    --to=philmd@linaro.org \
    --cc=armbru@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=zhao1.liu@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).