mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-14 08:35:15 +00:00
qemu: capabilities: Use g_auto(GStrv) instead of virStringListFreeCount
All the capability getters which return a string list do in fact return a NULL-terminated list so we can use g_auto(GStrv) to free it. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
d30548aa48
commit
651f77f898
@ -2557,7 +2557,7 @@ static int
|
|||||||
virQEMUCapsProbeQMPCommands(virQEMUCaps *qemuCaps,
|
virQEMUCapsProbeQMPCommands(virQEMUCaps *qemuCaps,
|
||||||
qemuMonitor *mon)
|
qemuMonitor *mon)
|
||||||
{
|
{
|
||||||
char **commands = NULL;
|
g_auto(GStrv) commands = NULL;
|
||||||
int ncommands;
|
int ncommands;
|
||||||
|
|
||||||
if ((ncommands = qemuMonitorGetCommands(mon, &commands)) < 0)
|
if ((ncommands = qemuMonitorGetCommands(mon, &commands)) < 0)
|
||||||
@ -2567,7 +2567,6 @@ virQEMUCapsProbeQMPCommands(virQEMUCaps *qemuCaps,
|
|||||||
G_N_ELEMENTS(virQEMUCapsCommands),
|
G_N_ELEMENTS(virQEMUCapsCommands),
|
||||||
virQEMUCapsCommands,
|
virQEMUCapsCommands,
|
||||||
ncommands, commands);
|
ncommands, commands);
|
||||||
virStringListFreeCount(commands, ncommands);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2577,8 +2576,8 @@ static int
|
|||||||
virQEMUCapsProbeQMPObjectTypes(virQEMUCaps *qemuCaps,
|
virQEMUCapsProbeQMPObjectTypes(virQEMUCaps *qemuCaps,
|
||||||
qemuMonitor *mon)
|
qemuMonitor *mon)
|
||||||
{
|
{
|
||||||
|
g_auto(GStrv) values = NULL;
|
||||||
int nvalues;
|
int nvalues;
|
||||||
char **values;
|
|
||||||
|
|
||||||
if ((nvalues = qemuMonitorGetObjectTypes(mon, &values)) < 0)
|
if ((nvalues = qemuMonitorGetObjectTypes(mon, &values)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -2586,7 +2585,6 @@ virQEMUCapsProbeQMPObjectTypes(virQEMUCaps *qemuCaps,
|
|||||||
G_N_ELEMENTS(virQEMUCapsObjectTypes),
|
G_N_ELEMENTS(virQEMUCapsObjectTypes),
|
||||||
virQEMUCapsObjectTypes,
|
virQEMUCapsObjectTypes,
|
||||||
nvalues, values);
|
nvalues, values);
|
||||||
virStringListFreeCount(values, nvalues);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2856,8 +2854,6 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCaps *qemuCaps,
|
|||||||
virDomainVirtType virtType,
|
virDomainVirtType virtType,
|
||||||
qemuMonitor *mon)
|
qemuMonitor *mon)
|
||||||
{
|
{
|
||||||
char **values;
|
|
||||||
int nvalues;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QOM_LIST_PROPERTIES))
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QOM_LIST_PROPERTIES))
|
||||||
@ -2867,6 +2863,8 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCaps *qemuCaps,
|
|||||||
virQEMUCapsObjectTypeProps props = virQEMUCapsMachineProps[i];
|
virQEMUCapsObjectTypeProps props = virQEMUCapsMachineProps[i];
|
||||||
const char *canon = virQEMUCapsGetCanonicalMachine(qemuCaps, virtType, props.type);
|
const char *canon = virQEMUCapsGetCanonicalMachine(qemuCaps, virtType, props.type);
|
||||||
g_autofree char *type = NULL;
|
g_autofree char *type = NULL;
|
||||||
|
g_auto(GStrv) values = NULL;
|
||||||
|
int nvalues;
|
||||||
|
|
||||||
if (STRNEQ(canon, "none") &&
|
if (STRNEQ(canon, "none") &&
|
||||||
!virQEMUCapsIsMachineSupported(qemuCaps, virtType, canon)) {
|
!virQEMUCapsIsMachineSupported(qemuCaps, virtType, canon)) {
|
||||||
@ -2884,8 +2882,6 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCaps *qemuCaps,
|
|||||||
props.nprops,
|
props.nprops,
|
||||||
props.props,
|
props.props,
|
||||||
nvalues, values);
|
nvalues, values);
|
||||||
|
|
||||||
virStringListFreeCount(values, nvalues);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -3302,7 +3298,7 @@ static int
|
|||||||
virQEMUCapsProbeQMPMigrationCapabilities(virQEMUCaps *qemuCaps,
|
virQEMUCapsProbeQMPMigrationCapabilities(virQEMUCaps *qemuCaps,
|
||||||
qemuMonitor *mon)
|
qemuMonitor *mon)
|
||||||
{
|
{
|
||||||
char **caps = NULL;
|
g_auto(GStrv) caps = NULL;
|
||||||
int ncaps;
|
int ncaps;
|
||||||
|
|
||||||
if ((ncaps = qemuMonitorGetMigrationCapabilities(mon, &caps)) < 0)
|
if ((ncaps = qemuMonitorGetMigrationCapabilities(mon, &caps)) < 0)
|
||||||
@ -3312,7 +3308,6 @@ virQEMUCapsProbeQMPMigrationCapabilities(virQEMUCaps *qemuCaps,
|
|||||||
G_N_ELEMENTS(virQEMUCapsMigration),
|
G_N_ELEMENTS(virQEMUCapsMigration),
|
||||||
virQEMUCapsMigration,
|
virQEMUCapsMigration,
|
||||||
ncaps, caps);
|
ncaps, caps);
|
||||||
virStringListFreeCount(caps, ncaps);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user