On 2/12/21 6:55 PM, Peter Krempa wrote:
The parent array takes ownership of the inserted value once all checks pass. Don't make the callers second-guess when that happens and modify the function to take a double pointer so that it can be cleared once the ownership is taken. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/locking/lock_daemon.c | 3 +-- src/logging/log_handler.c | 3 +-- src/network/leaseshelper.c | 3 +-- src/node_device/node_device_driver.c | 2 +- src/qemu/qemu_agent.c | 7 ++----- src/qemu/qemu_block.c | 16 ++++------------ src/qemu/qemu_command.c | 3 +-- src/qemu/qemu_firmware.c | 4 +--- src/qemu/qemu_migration_params.c | 4 +--- src/qemu/qemu_monitor_json.c | 11 +++-------- src/rpc/virnetserver.c | 6 ++---- src/rpc/virnetserverservice.c | 3 +-- src/util/virjson.c | 12 +++++------- src/util/virjson.h | 3 ++- src/util/virlease.c | 2 +- src/util/virlockspace.c | 6 ++---- src/util/virmacmap.c | 6 ++---- tests/testutilsqemuschema.c | 3 +-- 18 files changed, 32 insertions(+), 65 deletions(-)
I think the following should be squashed in: diff --git i/src/qemu/qemu_monitor_json.c w/src/qemu/qemu_monitor_json.c index 924e03b4da..2e040a2bc1 100644 --- i/src/qemu/qemu_monitor_json.c +++ w/src/qemu/qemu_monitor_json.c @@ -7580,7 +7580,6 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID, cleanup: VIR_FREE(tlsalias); - virJSONValueFree(addr); virJSONValueFree(data); virJSONValueFree(backend); return ret; diff --git i/src/util/virjson.c w/src/util/virjson.c index 5b3aa49a7f..69b3c3c63f 100644 --- i/src/util/virjson.c +++ w/src/util/virjson.c @@ -298,8 +298,7 @@ virJSONValueObjectAddVArgs(virJSONValuePtr obj, return -1; } - if ((rc = virJSONValueObjectAppend(obj, key, val)) == 0) - *val = NULL; + rc = virJSONValueObjectAppend(obj, key, val); } break; case 'M': @@ -2088,8 +2087,6 @@ virJSONValueObjectDeflattenWorker(const char *key, if (virJSONValueObjectAppend(retobj, key, &newval) < 0) return -1; - newval = NULL; - return 0; } Michal