With automatic memory freeing we can simplify the function to avoid two almost-identical calls to virQEMUBuildCommandLineJSONRecurse. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/util/virqemu.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/util/virqemu.c b/src/util/virqemu.c index e31451dff4..3e9311e3c7 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -158,23 +158,17 @@ virQEMUBuildCommandLineJSONIterate(const char *key, void *opaque) { struct virQEMUCommandLineJSONIteratorData *data = opaque; + g_autofree char *tmpkey = NULL; if (STREQ_NULLABLE(key, data->skipKey)) return 0; - if (data->prefix) { - g_autofree char *tmpkey = NULL; + if (data->prefix) + key = tmpkey = g_strdup_printf("%s.%s", data->prefix, key); - tmpkey = g_strdup_printf("%s.%s", data->prefix, key); - - return virQEMUBuildCommandLineJSONRecurse(tmpkey, value, data->buf, - data->skipKey, - data->arrayFunc, false); - } else { - return virQEMUBuildCommandLineJSONRecurse(key, value, data->buf, - data->skipKey, - data->arrayFunc, false); - } + return virQEMUBuildCommandLineJSONRecurse(key, value, data->buf, + data->skipKey, + data->arrayFunc, false); } -- 2.31.1