mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-05 13:17:51 +03:00
util: Clean up consumers of virJSONValueArraySize
Rather than have virJSONValueArraySize return a -1 when the input is not an array and then splat an error message, let's check for an array before calling and then change the return to be a size_t instead of ssize_t. That means using the helper virJSONValueIsArray as well as using a more generic error message such as "Malformed <something> array". In some cases we can remove stack variables and when we cannot, those variables should be size_t not ssize_t. Alter a few references of if (!value) to be if (value == 0) instead as well. Some callers can already assume an array is being worked on based on the previous call, so there's less to do. Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
91234b0573
commit
4a3d6ed5ee
@ -248,7 +248,6 @@ virLockDaemonNewPostExecRestart(virJSONValuePtr object, bool privileged)
|
|||||||
virJSONValuePtr child;
|
virJSONValuePtr child;
|
||||||
virJSONValuePtr lockspaces;
|
virJSONValuePtr lockspaces;
|
||||||
size_t i;
|
size_t i;
|
||||||
ssize_t n;
|
|
||||||
const char *serverNames[] = { "virtlockd" };
|
const char *serverNames[] = { "virtlockd" };
|
||||||
|
|
||||||
if (VIR_ALLOC(lockd) < 0)
|
if (VIR_ALLOC(lockd) < 0)
|
||||||
@ -281,13 +280,13 @@ virLockDaemonNewPostExecRestart(virJSONValuePtr object, bool privileged)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((n = virJSONValueArraySize(lockspaces)) < 0) {
|
if (!virJSONValueIsArray(lockspaces)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Malformed lockspaces data from JSON file"));
|
_("Malformed lockspaces array"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < virJSONValueArraySize(lockspaces); i++) {
|
||||||
virLockSpacePtr lockspace;
|
virLockSpacePtr lockspace;
|
||||||
|
|
||||||
child = virJSONValueArrayGet(lockspaces, i);
|
child = virJSONValueArrayGet(lockspaces, i);
|
||||||
|
@ -292,7 +292,6 @@ virLogHandlerNewPostExecRestart(virJSONValuePtr object,
|
|||||||
{
|
{
|
||||||
virLogHandlerPtr handler;
|
virLogHandlerPtr handler;
|
||||||
virJSONValuePtr files;
|
virJSONValuePtr files;
|
||||||
ssize_t n;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!(handler = virLogHandlerNew(privileged,
|
if (!(handler = virLogHandlerNew(privileged,
|
||||||
@ -308,13 +307,13 @@ virLogHandlerNewPostExecRestart(virJSONValuePtr object,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((n = virJSONValueArraySize(files)) < 0) {
|
if (!virJSONValueIsArray(files)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Malformed files data from JSON file"));
|
_("Malformed files array"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < virJSONValueArraySize(files); i++) {
|
||||||
virLogHandlerLogFilePtr file;
|
virLogHandlerLogFilePtr file;
|
||||||
virJSONValuePtr child = virJSONValueArrayGet(files, i);
|
virJSONValuePtr child = virJSONValueArrayGet(files, i);
|
||||||
|
|
||||||
|
@ -4124,7 +4124,7 @@ networkGetDHCPLeases(virNetworkPtr net,
|
|||||||
size_t i, j;
|
size_t i, j;
|
||||||
size_t nleases = 0;
|
size_t nleases = 0;
|
||||||
int rv = -1;
|
int rv = -1;
|
||||||
ssize_t size = 0;
|
size_t size = 0;
|
||||||
int custom_lease_file_len = 0;
|
int custom_lease_file_len = 0;
|
||||||
bool need_results = !!leases;
|
bool need_results = !!leases;
|
||||||
long long currtime = 0;
|
long long currtime = 0;
|
||||||
@ -4179,11 +4179,12 @@ networkGetDHCPLeases(virNetworkPtr net,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((size = virJSONValueArraySize(leases_array)) < 0) {
|
if (!virJSONValueIsArray(leases_array)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("couldn't fetch array of leases"));
|
_("Malformed lease_entries array"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
size = virJSONValueArraySize(leases_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
currtime = (long long)time(NULL);
|
currtime = (long long)time(NULL);
|
||||||
|
@ -1490,7 +1490,7 @@ qemuAgentGetVCPUs(qemuAgentPtr mon,
|
|||||||
virJSONValuePtr cmd;
|
virJSONValuePtr cmd;
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data = NULL;
|
virJSONValuePtr data = NULL;
|
||||||
ssize_t ndata;
|
size_t ndata;
|
||||||
|
|
||||||
if (!(cmd = qemuAgentMakeCommand("guest-get-vcpus", NULL)))
|
if (!(cmd = qemuAgentMakeCommand("guest-get-vcpus", NULL)))
|
||||||
return -1;
|
return -1;
|
||||||
@ -1505,6 +1505,12 @@ qemuAgentGetVCPUs(qemuAgentPtr mon,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!virJSONValueIsArray(data)) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("Malformed guest-get-vcpus data array"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
ndata = virJSONValueArraySize(data);
|
ndata = virJSONValueArraySize(data);
|
||||||
|
|
||||||
if (VIR_ALLOC_N(*info, ndata) < 0)
|
if (VIR_ALLOC_N(*info, ndata) < 0)
|
||||||
@ -1847,7 +1853,7 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info,
|
|||||||
{
|
{
|
||||||
size_t i, j, k;
|
size_t i, j, k;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
ssize_t ndata = 0, ndisk;
|
size_t ndata = 0, ndisk;
|
||||||
char **alias;
|
char **alias;
|
||||||
virJSONValuePtr cmd;
|
virJSONValuePtr cmd;
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
@ -1869,15 +1875,14 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virJSONValueGetType(data) != VIR_JSON_TYPE_ARRAY) {
|
if (!virJSONValueIsArray(data)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("guest-get-fsinfo return information was not "
|
_("Malformed guest-get-fsinfo data array"));
|
||||||
"an array"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ndata = virJSONValueArraySize(data);
|
ndata = virJSONValueArraySize(data);
|
||||||
if (!ndata) {
|
if (ndata == 0) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
*info = NULL;
|
*info = NULL;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1928,14 +1933,14 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virJSONValueGetType(entry) != VIR_JSON_TYPE_ARRAY) {
|
if (!virJSONValueIsArray(entry)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("guest-get-fsinfo 'disk' data was not an array"));
|
_("Malformed guest-get-fsinfo 'disk' data array"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ndisk = virJSONValueArraySize(entry);
|
ndisk = virJSONValueArraySize(entry);
|
||||||
if (!ndisk)
|
if (ndisk == 0)
|
||||||
continue;
|
continue;
|
||||||
if (VIR_ALLOC_N(info_ret[i]->devAlias, ndisk) < 0)
|
if (VIR_ALLOC_N(info_ret[i]->devAlias, ndisk) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2035,7 +2040,6 @@ qemuAgentGetInterfaces(qemuAgentPtr mon,
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
ssize_t size = -1;
|
|
||||||
virJSONValuePtr cmd = NULL;
|
virJSONValuePtr cmd = NULL;
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr ret_array = NULL;
|
virJSONValuePtr ret_array = NULL;
|
||||||
@ -2065,17 +2069,16 @@ qemuAgentGetInterfaces(qemuAgentPtr mon,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((size = virJSONValueArraySize(ret_array)) < 0) {
|
if (!virJSONValueIsArray(ret_array)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("qemu agent didn't return an array of interfaces"));
|
_("qemu agent didn't return an array of interfaces"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < virJSONValueArraySize(ret_array); i++) {
|
||||||
virJSONValuePtr tmp_iface = virJSONValueArrayGet(ret_array, i);
|
virJSONValuePtr tmp_iface = virJSONValueArrayGet(ret_array, i);
|
||||||
virJSONValuePtr ip_addr_arr = NULL;
|
virJSONValuePtr ip_addr_arr = NULL;
|
||||||
const char *hwaddr, *ifname_s, *name = NULL;
|
const char *hwaddr, *ifname_s, *name = NULL;
|
||||||
ssize_t ip_addr_arr_size;
|
|
||||||
virDomainInterfacePtr iface = NULL;
|
virDomainInterfacePtr iface = NULL;
|
||||||
|
|
||||||
/* Shouldn't happen but doesn't hurt to check neither */
|
/* Shouldn't happen but doesn't hurt to check neither */
|
||||||
@ -2131,14 +2134,16 @@ qemuAgentGetInterfaces(qemuAgentPtr mon,
|
|||||||
if (!ip_addr_arr)
|
if (!ip_addr_arr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((ip_addr_arr_size = virJSONValueArraySize(ip_addr_arr)) < 0)
|
if (!virJSONValueIsArray(ip_addr_arr)) {
|
||||||
/* Mmm, empty 'ip-address'? */
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("Malformed ip-addresses array"));
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
/* If current iface already exists, continue with the count */
|
/* If current iface already exists, continue with the count */
|
||||||
addrs_count = iface->naddrs;
|
addrs_count = iface->naddrs;
|
||||||
|
|
||||||
for (j = 0; j < ip_addr_arr_size; j++) {
|
for (j = 0; j < virJSONValueArraySize(ip_addr_arr); j++) {
|
||||||
const char *type, *addr;
|
const char *type, *addr;
|
||||||
virJSONValuePtr ip_addr_obj = virJSONValueArrayGet(ip_addr_arr, j);
|
virJSONValuePtr ip_addr_obj = virJSONValueArrayGet(ip_addr_arr, j);
|
||||||
virDomainIPAddressPtr ip_addr;
|
virDomainIPAddressPtr ip_addr;
|
||||||
|
@ -1627,9 +1627,9 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr data,
|
|||||||
struct qemuMonitorQueryCpusEntry *cpus = NULL;
|
struct qemuMonitorQueryCpusEntry *cpus = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
ssize_t ncpus;
|
size_t ncpus;
|
||||||
|
|
||||||
if ((ncpus = virJSONValueArraySize(data)) <= 0)
|
if ((ncpus = virJSONValueArraySize(data)) == 0)
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(cpus, ncpus) < 0)
|
if (VIR_ALLOC_N(cpus, ncpus) < 0)
|
||||||
@ -3595,7 +3595,7 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValuePtr msg,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
virJSONValuePtr returnArray, entry, table, element;
|
virJSONValuePtr returnArray, entry, table, element;
|
||||||
ssize_t nTable;
|
size_t nTable;
|
||||||
size_t i;
|
size_t i;
|
||||||
virNetDevRxFilterPtr fil = virNetDevRxFilterNew();
|
virNetDevRxFilterPtr fil = virNetDevRxFilterNew();
|
||||||
|
|
||||||
@ -3656,12 +3656,13 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValuePtr msg,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if ((!(table = virJSONValueObjectGet(entry, "unicast-table"))) ||
|
if ((!(table = virJSONValueObjectGet(entry, "unicast-table"))) ||
|
||||||
((nTable = virJSONValueArraySize(table)) < 0)) {
|
(!virJSONValueIsArray(table))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Missing or invalid 'unicast-table' array "
|
_("Missing or invalid 'unicast-table' array "
|
||||||
"in query-rx-filter response"));
|
"in query-rx-filter response"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
nTable = virJSONValueArraySize(table);
|
||||||
if (VIR_ALLOC_N(fil->unicast.table, nTable))
|
if (VIR_ALLOC_N(fil->unicast.table, nTable))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
for (i = 0; i < nTable; i++) {
|
for (i = 0; i < nTable; i++) {
|
||||||
@ -3697,12 +3698,13 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValuePtr msg,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if ((!(table = virJSONValueObjectGet(entry, "multicast-table"))) ||
|
if ((!(table = virJSONValueObjectGet(entry, "multicast-table"))) ||
|
||||||
((nTable = virJSONValueArraySize(table)) < 0)) {
|
(!virJSONValueIsArray(table))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Missing or invalid 'multicast-table' array "
|
_("Missing or invalid 'multicast-table' array "
|
||||||
"in query-rx-filter response"));
|
"in query-rx-filter response"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
nTable = virJSONValueArraySize(table);
|
||||||
if (VIR_ALLOC_N(fil->multicast.table, nTable))
|
if (VIR_ALLOC_N(fil->multicast.table, nTable))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
for (i = 0; i < nTable; i++) {
|
for (i = 0; i < nTable; i++) {
|
||||||
@ -3731,12 +3733,13 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValuePtr msg,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if ((!(table = virJSONValueObjectGet(entry, "vlan-table"))) ||
|
if ((!(table = virJSONValueObjectGet(entry, "vlan-table"))) ||
|
||||||
((nTable = virJSONValueArraySize(table)) < 0)) {
|
(!virJSONValueIsArray(table))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Missing or invalid 'vlan-table' array "
|
_("Missing or invalid 'vlan-table' array "
|
||||||
"in query-rx-filter response"));
|
"in query-rx-filter response"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
nTable = virJSONValueArraySize(table);
|
||||||
if (VIR_ALLOC_N(fil->vlan.table, nTable))
|
if (VIR_ALLOC_N(fil->vlan.table, nTable))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
for (i = 0; i < nTable; i++) {
|
for (i = 0; i < nTable; i++) {
|
||||||
@ -4575,7 +4578,7 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
|
|||||||
virJSONValuePtr cmd = NULL;
|
virJSONValuePtr cmd = NULL;
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
ssize_t nr_results;
|
size_t nr_results;
|
||||||
size_t i;
|
size_t i;
|
||||||
virHashTablePtr blockJobs = NULL;
|
virHashTablePtr blockJobs = NULL;
|
||||||
|
|
||||||
@ -4591,12 +4594,7 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((nr_results = virJSONValueArraySize(data)) < 0) {
|
nr_results = virJSONValueArraySize(data);
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("unable to determine array size"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(blockJobs = virHashCreate(nr_results, virHashValueFree)))
|
if (!(blockJobs = virHashCreate(nr_results, virHashValueFree)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -5114,7 +5112,7 @@ int qemuMonitorJSONGetMachines(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
qemuMonitorMachineInfoPtr *infolist = NULL;
|
qemuMonitorMachineInfoPtr *infolist = NULL;
|
||||||
ssize_t n = 0;
|
size_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*machines = NULL;
|
*machines = NULL;
|
||||||
@ -5206,7 +5204,7 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
qemuMonitorCPUDefInfoPtr *cpulist = NULL;
|
qemuMonitorCPUDefInfoPtr *cpulist = NULL;
|
||||||
int n = 0;
|
size_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*cpus = NULL;
|
*cpus = NULL;
|
||||||
@ -5257,7 +5255,7 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
|
|||||||
if (virJSONValueObjectHasKey(child, "unavailable-features")) {
|
if (virJSONValueObjectHasKey(child, "unavailable-features")) {
|
||||||
virJSONValuePtr blockers;
|
virJSONValuePtr blockers;
|
||||||
size_t j;
|
size_t j;
|
||||||
int len;
|
size_t len;
|
||||||
|
|
||||||
blockers = virJSONValueObjectGetArray(child,
|
blockers = virJSONValueObjectGetArray(child,
|
||||||
"unavailable-features");
|
"unavailable-features");
|
||||||
@ -5494,7 +5492,7 @@ int qemuMonitorJSONGetCommands(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
char **commandlist = NULL;
|
char **commandlist = NULL;
|
||||||
ssize_t n = 0;
|
size_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*commands = NULL;
|
*commands = NULL;
|
||||||
@ -5550,7 +5548,7 @@ int qemuMonitorJSONGetEvents(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
char **eventlist = NULL;
|
char **eventlist = NULL;
|
||||||
ssize_t n = 0;
|
size_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*events = NULL;
|
*events = NULL;
|
||||||
@ -5614,7 +5612,7 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr data = NULL;
|
virJSONValuePtr data = NULL;
|
||||||
virJSONValuePtr array = NULL;
|
virJSONValuePtr array = NULL;
|
||||||
char **paramlist = NULL;
|
char **paramlist = NULL;
|
||||||
ssize_t n = 0;
|
size_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*params = NULL;
|
*params = NULL;
|
||||||
@ -5646,17 +5644,17 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
|||||||
"return data"));
|
"return data"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!virJSONValueIsArray(array)) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("Malformed query-cmmand-line-options array"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
qemuMonitorSetOptions(mon, array);
|
qemuMonitorSetOptions(mon, array);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((n = virJSONValueArraySize(array)) < 0) {
|
for (i = 0; i < virJSONValueArraySize(array); i++) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("query-command-line-options reply data was not "
|
|
||||||
"an array"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
virJSONValuePtr child = virJSONValueArrayGet(array, i);
|
virJSONValuePtr child = virJSONValueArrayGet(array, i);
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
|
|
||||||
@ -5681,12 +5679,12 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
|||||||
if (found)
|
if (found)
|
||||||
*found = true;
|
*found = true;
|
||||||
|
|
||||||
if ((n = virJSONValueArraySize(data)) < 0) {
|
if (!virJSONValueIsArray(data)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("query-command-line-options parameter data was not "
|
_("Malformed query-cmmand-line-options parameters array"));
|
||||||
"an array"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
n = virJSONValueArraySize(data);
|
||||||
|
|
||||||
/* null-terminated list */
|
/* null-terminated list */
|
||||||
if (VIR_ALLOC_N(paramlist, n + 1) < 0)
|
if (VIR_ALLOC_N(paramlist, n + 1) < 0)
|
||||||
@ -5776,7 +5774,7 @@ int qemuMonitorJSONGetObjectTypes(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
char **typelist = NULL;
|
char **typelist = NULL;
|
||||||
ssize_t n = 0;
|
size_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*types = NULL;
|
*types = NULL;
|
||||||
@ -5832,7 +5830,7 @@ int qemuMonitorJSONGetObjectListPaths(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
qemuMonitorJSONListPathPtr *pathlist = NULL;
|
qemuMonitorJSONListPathPtr *pathlist = NULL;
|
||||||
ssize_t n = 0;
|
size_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*paths = NULL;
|
*paths = NULL;
|
||||||
@ -6062,7 +6060,7 @@ int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
char **proplist = NULL;
|
char **proplist = NULL;
|
||||||
ssize_t n = 0;
|
size_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*props = NULL;
|
*props = NULL;
|
||||||
@ -6161,7 +6159,7 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr caps;
|
virJSONValuePtr caps;
|
||||||
char **list = NULL;
|
char **list = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
ssize_t n;
|
size_t n;
|
||||||
|
|
||||||
*capabilities = NULL;
|
*capabilities = NULL;
|
||||||
|
|
||||||
@ -6272,7 +6270,7 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr caps;
|
virJSONValuePtr caps;
|
||||||
virGICCapability *list = NULL;
|
virGICCapability *list = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
ssize_t n;
|
size_t n;
|
||||||
|
|
||||||
*capabilities = NULL;
|
*capabilities = NULL;
|
||||||
|
|
||||||
@ -6495,7 +6493,7 @@ qemuMonitorJSONGetStringArray(qemuMonitorPtr mon, const char *qmpCmd,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
char **list = NULL;
|
char **list = NULL;
|
||||||
ssize_t n = 0;
|
size_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*array = NULL;
|
*array = NULL;
|
||||||
@ -6892,14 +6890,11 @@ qemuMonitorJSONParseCPUx86Features(virJSONValuePtr data)
|
|||||||
virCPUDataPtr cpudata = NULL;
|
virCPUDataPtr cpudata = NULL;
|
||||||
virCPUx86CPUID cpuid;
|
virCPUx86CPUID cpuid;
|
||||||
size_t i;
|
size_t i;
|
||||||
ssize_t n;
|
|
||||||
|
|
||||||
n = virJSONValueArraySize(data);
|
|
||||||
|
|
||||||
if (!(cpudata = virCPUDataNew(VIR_ARCH_X86_64)))
|
if (!(cpudata = virCPUDataNew(VIR_ARCH_X86_64)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < virJSONValueArraySize(data); i++) {
|
||||||
if (qemuMonitorJSONParseCPUx86FeatureWord(virJSONValueArrayGet(data, i),
|
if (qemuMonitorJSONParseCPUx86FeatureWord(virJSONValueArrayGet(data, i),
|
||||||
&cpuid) < 0 ||
|
&cpuid) < 0 ||
|
||||||
virCPUx86DataAddCPUID(cpudata, &cpuid) < 0)
|
virCPUx86DataAddCPUID(cpudata, &cpuid) < 0)
|
||||||
@ -6960,7 +6955,7 @@ qemuMonitorJSONCheckCPUx86(qemuMonitorPtr mon)
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
size_t i;
|
size_t i;
|
||||||
ssize_t n;
|
size_t n;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(cmd = qemuMonitorJSONMakeCommand("qom-list",
|
if (!(cmd = qemuMonitorJSONMakeCommand("qom-list",
|
||||||
@ -7098,7 +7093,7 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
qemuMonitorIOThreadInfoPtr *infolist = NULL;
|
qemuMonitorIOThreadInfoPtr *infolist = NULL;
|
||||||
ssize_t n = 0;
|
size_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*iothreads = NULL;
|
*iothreads = NULL;
|
||||||
@ -7180,7 +7175,6 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data = NULL;
|
virJSONValuePtr data = NULL;
|
||||||
qemuMonitorMemoryDeviceInfoPtr meminfo = NULL;
|
qemuMonitorMemoryDeviceInfoPtr meminfo = NULL;
|
||||||
ssize_t n;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!(cmd = qemuMonitorJSONMakeCommand("query-memory-devices", NULL)))
|
if (!(cmd = qemuMonitorJSONMakeCommand("query-memory-devices", NULL)))
|
||||||
@ -7198,9 +7192,8 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
data = virJSONValueObjectGetArray(reply, "return");
|
data = virJSONValueObjectGetArray(reply, "return");
|
||||||
n = virJSONValueArraySize(data);
|
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < virJSONValueArraySize(data); i++) {
|
||||||
virJSONValuePtr elem = virJSONValueArrayGet(data, i);
|
virJSONValuePtr elem = virJSONValueArrayGet(data, i);
|
||||||
const char *type;
|
const char *type;
|
||||||
|
|
||||||
@ -7666,7 +7659,7 @@ qemuMonitorJSONGetHotpluggableCPUs(qemuMonitorPtr mon,
|
|||||||
size_t *nentries)
|
size_t *nentries)
|
||||||
{
|
{
|
||||||
struct qemuMonitorQueryHotpluggableCpusEntry *info = NULL;
|
struct qemuMonitorQueryHotpluggableCpusEntry *info = NULL;
|
||||||
ssize_t ninfo = 0;
|
size_t ninfo = 0;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
|
@ -322,12 +322,7 @@ virNetDaemonNewPostExecRestart(virJSONValuePtr object,
|
|||||||
goto error;
|
goto error;
|
||||||
} else if (virJSONValueIsArray(servers)) {
|
} else if (virJSONValueIsArray(servers)) {
|
||||||
size_t i;
|
size_t i;
|
||||||
ssize_t n = virJSONValueArraySize(servers);
|
size_t n = virJSONValueArraySize(servers);
|
||||||
if (n < 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Server count %zd should be positive"), n);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
if (n > nDefServerNames) {
|
if (n > nDefServerNames) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Server count %zd greater than default name count %zu"),
|
_("Server count %zd greater than default name count %zu"),
|
||||||
|
@ -411,7 +411,6 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
|
|||||||
virJSONValuePtr clients;
|
virJSONValuePtr clients;
|
||||||
virJSONValuePtr services;
|
virJSONValuePtr services;
|
||||||
size_t i;
|
size_t i;
|
||||||
ssize_t n;
|
|
||||||
unsigned int min_workers;
|
unsigned int min_workers;
|
||||||
unsigned int max_workers;
|
unsigned int max_workers;
|
||||||
unsigned int priority_workers;
|
unsigned int priority_workers;
|
||||||
@ -492,14 +491,13 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = virJSONValueArraySize(services);
|
if (!virJSONValueIsArray(services)) {
|
||||||
if (n < 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Malformed services data in JSON document"));
|
_("Malformed services array"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < virJSONValueArraySize(services); i++) {
|
||||||
virNetServerServicePtr service;
|
virNetServerServicePtr service;
|
||||||
virJSONValuePtr child = virJSONValueArrayGet(services, i);
|
virJSONValuePtr child = virJSONValueArrayGet(services, i);
|
||||||
if (!child) {
|
if (!child) {
|
||||||
@ -525,14 +523,13 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = virJSONValueArraySize(clients);
|
if (!virJSONValueIsArray(clients)) {
|
||||||
if (n < 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Malformed clients data in JSON document"));
|
_("Malformed clients array"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < virJSONValueArraySize(clients); i++) {
|
||||||
virNetServerClientPtr client;
|
virNetServerClientPtr client;
|
||||||
virJSONValuePtr child = virJSONValueArrayGet(clients, i);
|
virJSONValuePtr child = virJSONValueArrayGet(clients, i);
|
||||||
if (!child) {
|
if (!child) {
|
||||||
|
@ -325,7 +325,7 @@ virNetServerServicePtr virNetServerServiceNewPostExecRestart(virJSONValuePtr obj
|
|||||||
virNetServerServicePtr svc;
|
virNetServerServicePtr svc;
|
||||||
virJSONValuePtr socks;
|
virJSONValuePtr socks;
|
||||||
size_t i;
|
size_t i;
|
||||||
ssize_t n;
|
size_t n;
|
||||||
unsigned int max;
|
unsigned int max;
|
||||||
|
|
||||||
if (virNetServerServiceInitialize() < 0)
|
if (virNetServerServiceInitialize() < 0)
|
||||||
@ -358,12 +358,13 @@ virNetServerServicePtr virNetServerServiceNewPostExecRestart(virJSONValuePtr obj
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((n = virJSONValueArraySize(socks)) < 0) {
|
if (!virJSONValueIsArray(socks)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("socks field in JSON was not an array"));
|
_("Malformed socks array"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n = virJSONValueArraySize(socks);
|
||||||
if (VIR_ALLOC_N(svc->socks, n) < 0)
|
if (VIR_ALLOC_N(svc->socks, n) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
svc->nsocks = n;
|
svc->nsocks = n;
|
||||||
|
@ -971,12 +971,9 @@ virJSONValueIsArray(virJSONValuePtr array)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ssize_t
|
size_t
|
||||||
virJSONValueArraySize(const virJSONValue *array)
|
virJSONValueArraySize(const virJSONValue *array)
|
||||||
{
|
{
|
||||||
if (array->type != VIR_JSON_TYPE_ARRAY)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return array->data.array.nvalues;
|
return array->data.array.nvalues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ virJSONValuePtr virJSONValueObjectGetByType(virJSONValuePtr object,
|
|||||||
bool virJSONValueIsObject(virJSONValuePtr object);
|
bool virJSONValueIsObject(virJSONValuePtr object);
|
||||||
|
|
||||||
bool virJSONValueIsArray(virJSONValuePtr array);
|
bool virJSONValueIsArray(virJSONValuePtr array);
|
||||||
ssize_t virJSONValueArraySize(const virJSONValue *array);
|
size_t virJSONValueArraySize(const virJSONValue *array);
|
||||||
virJSONValuePtr virJSONValueArrayGet(virJSONValuePtr object, unsigned int element);
|
virJSONValuePtr virJSONValueArrayGet(virJSONValuePtr object, unsigned int element);
|
||||||
virJSONValuePtr virJSONValueArraySteal(virJSONValuePtr object, unsigned int element);
|
virJSONValuePtr virJSONValueArraySteal(virJSONValuePtr object, unsigned int element);
|
||||||
typedef int (*virJSONArrayIteratorFunc)(size_t pos,
|
typedef int (*virJSONArrayIteratorFunc)(size_t pos,
|
||||||
|
@ -293,7 +293,6 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONValuePtr object)
|
|||||||
{
|
{
|
||||||
virLockSpacePtr lockspace;
|
virLockSpacePtr lockspace;
|
||||||
virJSONValuePtr resources;
|
virJSONValuePtr resources;
|
||||||
ssize_t n;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
VIR_DEBUG("object=%p", object);
|
VIR_DEBUG("object=%p", object);
|
||||||
@ -324,19 +323,19 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONValuePtr object)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((n = virJSONValueArraySize(resources)) < 0) {
|
if (!virJSONValueIsArray(resources)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Malformed resources value in JSON document"));
|
_("Malformed resources array"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < virJSONValueArraySize(resources); i++) {
|
||||||
virJSONValuePtr child = virJSONValueArrayGet(resources, i);
|
virJSONValuePtr child = virJSONValueArrayGet(resources, i);
|
||||||
virLockSpaceResourcePtr res;
|
virLockSpaceResourcePtr res;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
virJSONValuePtr owners;
|
virJSONValuePtr owners;
|
||||||
size_t j;
|
size_t j;
|
||||||
ssize_t m;
|
size_t m;
|
||||||
|
|
||||||
if (VIR_ALLOC(res) < 0)
|
if (VIR_ALLOC(res) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
@ -396,18 +395,19 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONValuePtr object)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m = virJSONValueArraySize(owners)) < 0) {
|
if (!virJSONValueIsArray(owners)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Malformed owners value in JSON document"));
|
_("Malformed owners array"));
|
||||||
virLockSpaceResourceFree(res);
|
virLockSpaceResourceFree(res);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
res->nOwners = m;
|
m = virJSONValueArraySize(owners);
|
||||||
if (VIR_ALLOC_N(res->owners, res->nOwners) < 0) {
|
if (VIR_ALLOC_N(res->owners, res->nOwners) < 0) {
|
||||||
virLockSpaceResourceFree(res);
|
virLockSpaceResourceFree(res);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
res->nOwners = m;
|
||||||
|
|
||||||
for (j = 0; j < res->nOwners; j++) {
|
for (j = 0; j < res->nOwners; j++) {
|
||||||
unsigned long long int owner;
|
unsigned long long int owner;
|
||||||
|
@ -2928,8 +2928,7 @@ virStorageSourceParseBackingJSONGluster(virStorageSourcePtr src,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
nservers = virJSONValueArraySize(server);
|
nservers = virJSONValueArraySize(server);
|
||||||
|
if (nservers == 0) {
|
||||||
if (nservers < 1) {
|
|
||||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
_("at least 1 server is necessary in "
|
_("at least 1 server is necessary in "
|
||||||
"JSON backing definition for gluster volume"));
|
"JSON backing definition for gluster volume"));
|
||||||
|
@ -101,11 +101,9 @@ testQEMUSchemaStealObjectMemberByName(const char *name,
|
|||||||
{
|
{
|
||||||
virJSONValuePtr member;
|
virJSONValuePtr member;
|
||||||
virJSONValuePtr ret = NULL;
|
virJSONValuePtr ret = NULL;
|
||||||
size_t n;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
n = virJSONValueArraySize(members);
|
for (i = 0; i < virJSONValueArraySize(members); i++) {
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
member = virJSONValueArrayGet(members, i);
|
member = virJSONValueArrayGet(members, i);
|
||||||
|
|
||||||
if (STREQ_NULLABLE(name, virJSONValueObjectGetString(member, "name"))) {
|
if (STREQ_NULLABLE(name, virJSONValueObjectGetString(member, "name"))) {
|
||||||
@ -188,7 +186,6 @@ testQEMUSchemaValidateObjectMergeVariant(virJSONValuePtr root,
|
|||||||
virHashTablePtr schema,
|
virHashTablePtr schema,
|
||||||
virBufferPtr debug)
|
virBufferPtr debug)
|
||||||
{
|
{
|
||||||
size_t n;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
virJSONValuePtr variants = NULL;
|
virJSONValuePtr variants = NULL;
|
||||||
virJSONValuePtr variant;
|
virJSONValuePtr variant;
|
||||||
@ -203,8 +200,7 @@ testQEMUSchemaValidateObjectMergeVariant(virJSONValuePtr root,
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = virJSONValueArraySize(variants);
|
for (i = 0; i < virJSONValueArraySize(variants); i++) {
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
variant = virJSONValueArrayGet(variants, i);
|
variant = virJSONValueArrayGet(variants, i);
|
||||||
|
|
||||||
if (STREQ_NULLABLE(variantname,
|
if (STREQ_NULLABLE(variantname,
|
||||||
@ -342,7 +338,6 @@ testQEMUSchemaValidateEnum(virJSONValuePtr obj,
|
|||||||
const char *objstr;
|
const char *objstr;
|
||||||
virJSONValuePtr values = NULL;
|
virJSONValuePtr values = NULL;
|
||||||
virJSONValuePtr value;
|
virJSONValuePtr value;
|
||||||
size_t n;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (virJSONValueGetType(obj) != VIR_JSON_TYPE_STRING) {
|
if (virJSONValueGetType(obj) != VIR_JSON_TYPE_STRING) {
|
||||||
@ -358,8 +353,7 @@ testQEMUSchemaValidateEnum(virJSONValuePtr obj,
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = virJSONValueArraySize(values);
|
for (i = 0; i < virJSONValueArraySize(values); i++) {
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
value = virJSONValueArrayGet(values, i);
|
value = virJSONValueArrayGet(values, i);
|
||||||
|
|
||||||
if (STREQ_NULLABLE(objstr, virJSONValueGetString(value))) {
|
if (STREQ_NULLABLE(objstr, virJSONValueGetString(value))) {
|
||||||
@ -383,7 +377,6 @@ testQEMUSchemaValidateArray(virJSONValuePtr objs,
|
|||||||
const char *elemtypename = virJSONValueObjectGetString(root, "element-type");
|
const char *elemtypename = virJSONValueObjectGetString(root, "element-type");
|
||||||
virJSONValuePtr elementschema;
|
virJSONValuePtr elementschema;
|
||||||
virJSONValuePtr obj;
|
virJSONValuePtr obj;
|
||||||
size_t n;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (virJSONValueGetType(objs) != VIR_JSON_TYPE_ARRAY) {
|
if (virJSONValueGetType(objs) != VIR_JSON_TYPE_ARRAY) {
|
||||||
@ -401,8 +394,7 @@ testQEMUSchemaValidateArray(virJSONValuePtr objs,
|
|||||||
virBufferAddLit(debug, "[\n");
|
virBufferAddLit(debug, "[\n");
|
||||||
virBufferAdjustIndent(debug, 3);
|
virBufferAdjustIndent(debug, 3);
|
||||||
|
|
||||||
n = virJSONValueArraySize(objs);
|
for (i = 0; i < virJSONValueArraySize(objs); i++) {
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
obj = virJSONValueArrayGet(objs, i);
|
obj = virJSONValueArrayGet(objs, i);
|
||||||
|
|
||||||
if (testQEMUSchemaValidateRecurse(obj, elementschema, schema, debug) < 0)
|
if (testQEMUSchemaValidateRecurse(obj, elementschema, schema, debug) < 0)
|
||||||
@ -423,8 +415,8 @@ testQEMUSchemaValidateAlternate(virJSONValuePtr obj,
|
|||||||
{
|
{
|
||||||
virJSONValuePtr members;
|
virJSONValuePtr members;
|
||||||
virJSONValuePtr member;
|
virJSONValuePtr member;
|
||||||
size_t n;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
size_t n;
|
||||||
const char *membertype;
|
const char *membertype;
|
||||||
virJSONValuePtr memberschema;
|
virJSONValuePtr memberschema;
|
||||||
int indent;
|
int indent;
|
||||||
|
@ -309,8 +309,7 @@ findLease(const char *name,
|
|||||||
}
|
}
|
||||||
VIR_DIR_CLOSE(dir);
|
VIR_DIR_CLOSE(dir);
|
||||||
|
|
||||||
if ((nleases = virJSONValueArraySize(leases_array)) < 0)
|
nleases = virJSONValueArraySize(leases_array);
|
||||||
goto cleanup;
|
|
||||||
DEBUG("Read %zd leases", nleases);
|
DEBUG("Read %zd leases", nleases);
|
||||||
|
|
||||||
#if !defined(LIBVIRT_NSS_GUEST)
|
#if !defined(LIBVIRT_NSS_GUEST)
|
||||||
|
Loading…
Reference in New Issue
Block a user