virQEMUBuildCommandLineJSONIterate: Simplify logic

With automatic memory freeing we can simplify the function to avoid two
almost-identical calls to virQEMUBuildCommandLineJSONRecurse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-09-25 09:01:52 +02:00
parent fbc088ab82
commit 5204578993

View File

@ -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);
}
}