diff mbox series

[4/6] block-helpers: use local_err in case errp is NULL

Message ID 20200619120157.2422429-4-stefanha@redhat.com
State New
Headers show
Series None | expand

Commit Message

Stefan Hajnoczi June 19, 2020, 12:01 p.m. UTC
If we use errp then we won't know when check_block_size() fails when
errp is NULL.

The purpose of local_err is to detect an error has occurred even if the
caller doesn't care about the specific error and has passed a NULL errp.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/core/qdev-properties.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 28a6d8b2ee..0a651c7d32 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -800,8 +800,9 @@  static void set_blocksize(Object *obj, Visitor *v, const char *name,
         error_propagate(errp, local_err);
         return;
     }
-    check_block_size(dev->id ? : "", name, value, errp);
-    if (errp) {
+    check_block_size(dev->id ? : "", name, value, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
         return;
     }
     *ptr = value;