mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: More qemu_monitor_json cleanups
Recent adjustments to the code produced a litany of coverity false positives, but only because the "standard" procedure of setting a variable to NULL after it was assigned to something else and keeping the *Free/*FREE call in the cleanup path wasn't kept. So this patch makes those adjustments (assign variable to NULL and remove the if 'ret < 0' condition to clean it up). Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
a1efc9428b
commit
52760707bc
@ -4863,9 +4863,10 @@ int qemuMonitorJSONGetMachines(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
ret = n;
|
ret = n;
|
||||||
*machines = infolist;
|
*machines = infolist;
|
||||||
|
infolist = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0 && infolist) {
|
if (infolist) {
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
qemuMonitorMachineInfoFree(infolist[i]);
|
qemuMonitorMachineInfoFree(infolist[i]);
|
||||||
VIR_FREE(infolist);
|
VIR_FREE(infolist);
|
||||||
@ -4939,10 +4940,10 @@ int qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
ret = n;
|
ret = n;
|
||||||
*cpus = cpulist;
|
*cpus = cpulist;
|
||||||
|
cpulist = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0)
|
virStringFreeList(cpulist);
|
||||||
virStringFreeList(cpulist);
|
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
virJSONValueFree(reply);
|
virJSONValueFree(reply);
|
||||||
return ret;
|
return ret;
|
||||||
@ -5003,10 +5004,11 @@ int qemuMonitorJSONGetCommands(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
ret = n;
|
ret = n;
|
||||||
*commands = commandlist;
|
*commands = commandlist;
|
||||||
|
commandlist = NULL;
|
||||||
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0)
|
virStringFreeList(commandlist);
|
||||||
virStringFreeList(commandlist);
|
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
virJSONValueFree(reply);
|
virJSONValueFree(reply);
|
||||||
return ret;
|
return ret;
|
||||||
@ -5072,10 +5074,10 @@ int qemuMonitorJSONGetEvents(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
ret = n;
|
ret = n;
|
||||||
*events = eventlist;
|
*events = eventlist;
|
||||||
|
eventlist = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0)
|
virStringFreeList(eventlist);
|
||||||
virStringFreeList(eventlist);
|
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
virJSONValueFree(reply);
|
virJSONValueFree(reply);
|
||||||
return ret;
|
return ret;
|
||||||
@ -5189,6 +5191,7 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
ret = n;
|
ret = n;
|
||||||
*params = paramlist;
|
*params = paramlist;
|
||||||
|
paramlist = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
/* If we failed before getting the JSON array of options, we (try)
|
/* If we failed before getting the JSON array of options, we (try)
|
||||||
@ -5196,8 +5199,7 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
|||||||
if (!qemuMonitorGetOptions(mon))
|
if (!qemuMonitorGetOptions(mon))
|
||||||
qemuMonitorSetOptions(mon, virJSONValueNewArray());
|
qemuMonitorSetOptions(mon, virJSONValueNewArray());
|
||||||
|
|
||||||
if (ret < 0)
|
virStringFreeList(paramlist);
|
||||||
virStringFreeList(paramlist);
|
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
virJSONValueFree(reply);
|
virJSONValueFree(reply);
|
||||||
return ret;
|
return ret;
|
||||||
@ -5306,10 +5308,10 @@ int qemuMonitorJSONGetObjectTypes(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
ret = n;
|
ret = n;
|
||||||
*types = typelist;
|
*types = typelist;
|
||||||
|
typelist = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0)
|
virStringFreeList(typelist);
|
||||||
virStringFreeList(typelist);
|
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
virJSONValueFree(reply);
|
virJSONValueFree(reply);
|
||||||
return ret;
|
return ret;
|
||||||
@ -5389,9 +5391,10 @@ int qemuMonitorJSONGetObjectListPaths(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
ret = n;
|
ret = n;
|
||||||
*paths = pathlist;
|
*paths = pathlist;
|
||||||
|
pathlist = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0 && pathlist) {
|
if (pathlist) {
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
qemuMonitorJSONListPathFree(pathlist[i]);
|
qemuMonitorJSONListPathFree(pathlist[i]);
|
||||||
VIR_FREE(pathlist);
|
VIR_FREE(pathlist);
|
||||||
@ -5616,10 +5619,10 @@ int qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
ret = n;
|
ret = n;
|
||||||
*props = proplist;
|
*props = proplist;
|
||||||
|
proplist = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0)
|
virStringFreeList(proplist);
|
||||||
virStringFreeList(proplist);
|
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
virJSONValueFree(reply);
|
virJSONValueFree(reply);
|
||||||
return ret;
|
return ret;
|
||||||
@ -5726,10 +5729,10 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
ret = n;
|
ret = n;
|
||||||
*capabilities = list;
|
*capabilities = list;
|
||||||
|
list = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0)
|
virStringFreeList(list);
|
||||||
virStringFreeList(list);
|
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
virJSONValueFree(reply);
|
virJSONValueFree(reply);
|
||||||
return ret;
|
return ret;
|
||||||
@ -5911,10 +5914,10 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
ret = n;
|
ret = n;
|
||||||
*capabilities = list;
|
*capabilities = list;
|
||||||
|
list = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0)
|
VIR_FREE(list);
|
||||||
VIR_FREE(list);
|
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
virJSONValueFree(reply);
|
virJSONValueFree(reply);
|
||||||
|
|
||||||
@ -6125,10 +6128,10 @@ qemuMonitorJSONGetStringArray(qemuMonitorPtr mon, const char *qmpCmd,
|
|||||||
|
|
||||||
ret = n;
|
ret = n;
|
||||||
*array = list;
|
*array = list;
|
||||||
|
list = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0)
|
virStringFreeList(list);
|
||||||
virStringFreeList(list);
|
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
virJSONValueFree(reply);
|
virJSONValueFree(reply);
|
||||||
return ret;
|
return ret;
|
||||||
@ -6668,9 +6671,10 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
ret = n;
|
ret = n;
|
||||||
*iothreads = infolist;
|
*iothreads = infolist;
|
||||||
|
infolist = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0 && infolist) {
|
if (infolist) {
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
VIR_FREE(infolist[i]);
|
VIR_FREE(infolist[i]);
|
||||||
VIR_FREE(infolist);
|
VIR_FREE(infolist);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user