hw/nubus/nubus-virtio-mmio: Fix missing ERRP_GUARD() in nubus_virtio_mmio_realize()
PATCH v2 1/1 hw/nubus/nubus-virtio-mmio: Fix missing ERRP_GUARD() in nubus_virtio_mmio_realize()
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.
---
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(+)
hw/nubus/nubus-virtio-mmio.c +1 -0
@@ -23,6 +23,7 @@ static void nubus_virtio_mmio_set_input_irq(void *opaque, int n, int level)static void nubus_virtio_mmio_realize (DeviceState *dev,Error **errp) { +ERRP_GUARD ();NubusVirtioMMIODeviceClass *nvmdc =NUBUS_VIRTIO_MMIO_GET_CLASS (dev);NubusVirtioMMIO *s =NUBUS_VIRTIO_MMIO (dev);NubusDevice *nd =NUBUS_DEVICE (dev);
Signature · 1 line
2.34.1
Quoted 24 lines · Zhao Liu
According to the comment in
qapi/error.h, dereferencing @errp requiresERRP_GUARD():* = Why, when and how to use
ERRP_GUARD()=
*
* WithoutERRP_GUARD(), use of the @errp parameter is restricted:
* - It must not be dereferenced, because it may be null.
...
*ERRP_GUARD()lifts these restrictions.
*
* To useERRP_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 withoutERRP_GUARD().Although
nubus_virtio_mmio_realize()- as aDeviceClass.realize()method - is never passed a null @errp argument, it should follow the rules on @errp usage. Add theERRP_GUARD()there.
Quoted 7 lines
Reviewed-by Markus Armbruster <[email protected]>Signed-off-by Zhao Liu <[email protected]>---
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!
Quoted 33 lines · Philippe Mathieu-Daudé
Quoted 24 lines · Zhao Liu
According to the comment in
qapi/error.h, dereferencing @errp requiresERRP_GUARD():* = Why, when and how to use
ERRP_GUARD()=
*
* WithoutERRP_GUARD(), use of the @errp parameter is restricted:
* - It must not be dereferenced, because it may be null.
...
*ERRP_GUARD()lifts these restrictions.
*
* To useERRP_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 withoutERRP_GUARD().Although
nubus_virtio_mmio_realize()- as aDeviceClass.realize()method - is never passed a null @errp argument, it should follow the rules on @errp usage. Add theERRP_GUARD()there.Quoted 7 lines
Reviewed-by Markus Armbruster <[email protected]>Signed-off-by Zhao Liu <[email protected]>---
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(+)
Quoted 1 line
Patch queued, thanks!
Squashing:
-- >8 --
hw/nubus/nubus-virtio-mmio.c +1 -1
@@ -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.