[PATCH 13/16] qemuMonitorAddObject: Use g_clear_pointer for a free and reset operation
Peter Krempa
pkrempa at redhat.com
Fri Dec 3 14:57:40 UTC 2021
Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
src/qemu/qemu_monitor.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index d752b299ab..6beb23e9f7 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2956,10 +2956,9 @@ qemuMonitorAddObject(qemuMonitor *mon,
ignore_value(virJSONValueObjectRemoveKey(*props, "qom-type", &typeobj));
ignore_value(virJSONValueObjectRemoveKey(*props, "id", &idobj));
- if (!virJSONValueObjectGetKey(*props, 0)) {
- virJSONValueFree(*props);
- *props = NULL;
- }
+ /* avoid empty 'props' member */
+ if (!virJSONValueObjectGetKey(*props, 0))
+ g_clear_pointer(props, virJSONValueFree);
if (virJSONValueObjectAdd(&pr,
"s:qom-type", type,
--
2.31.1
More information about the libvir-list
mailing list