mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-05 12:35:20 +00:00
virJSONValueArraySize: return ssize_t
The internal representation of a JSON array counts the items in size_t. However, for some reason, when asking for the count it's reported as int. Firstly, we need the function to return a signed type as it's returning -1 on an error. But, not every system has integer the same size as size_t. Therefore, lets return ssize_t. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
6c928996e6
commit
4f77c48cba
@ -184,7 +184,7 @@ virLockDaemonNewPostExecRestart(virJSONValuePtr object, bool privileged)
|
|||||||
virJSONValuePtr lockspaces;
|
virJSONValuePtr lockspaces;
|
||||||
virNetServerPtr srv;
|
virNetServerPtr srv;
|
||||||
size_t i;
|
size_t i;
|
||||||
int n;
|
ssize_t n;
|
||||||
|
|
||||||
if (VIR_ALLOC(lockd) < 0)
|
if (VIR_ALLOC(lockd) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -3599,7 +3599,7 @@ networkGetDHCPLeases(virNetworkPtr network,
|
|||||||
size_t i, j;
|
size_t i, j;
|
||||||
size_t nleases = 0;
|
size_t nleases = 0;
|
||||||
int rv = -1;
|
int rv = -1;
|
||||||
int size = 0;
|
ssize_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;
|
||||||
|
@ -1461,7 +1461,7 @@ qemuAgentGetVCPUs(qemuAgentPtr mon,
|
|||||||
virJSONValuePtr cmd;
|
virJSONValuePtr cmd;
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data = NULL;
|
virJSONValuePtr data = NULL;
|
||||||
int ndata;
|
ssize_t ndata;
|
||||||
|
|
||||||
if (!(cmd = qemuAgentMakeCommand("guest-get-vcpus", NULL)))
|
if (!(cmd = qemuAgentMakeCommand("guest-get-vcpus", NULL)))
|
||||||
return -1;
|
return -1;
|
||||||
@ -1767,7 +1767,7 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info,
|
|||||||
{
|
{
|
||||||
size_t i, j, k;
|
size_t i, j, k;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int ndata = 0, ndisk;
|
ssize_t ndata = 0, ndisk;
|
||||||
char **alias;
|
char **alias;
|
||||||
virJSONValuePtr cmd;
|
virJSONValuePtr cmd;
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
@ -1810,7 +1810,7 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info,
|
|||||||
|
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("array element '%zd' of '%d' missing in "
|
_("array element '%zd' of '%zd' missing in "
|
||||||
"guest-get-fsinfo return data"),
|
"guest-get-fsinfo return data"),
|
||||||
i, ndata);
|
i, ndata);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1871,7 +1871,7 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info,
|
|||||||
|
|
||||||
if (!disk) {
|
if (!disk) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("array element '%zd' of '%d' missing in "
|
_("array element '%zd' of '%zd' missing in "
|
||||||
"guest-get-fsinfo 'disk' data"),
|
"guest-get-fsinfo 'disk' data"),
|
||||||
j, ndisk);
|
j, ndisk);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1954,7 +1954,7 @@ qemuAgentGetInterfaces(qemuAgentPtr mon,
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
int size = -1;
|
ssize_t size = -1;
|
||||||
virJSONValuePtr cmd = NULL;
|
virJSONValuePtr cmd = NULL;
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr ret_array = NULL;
|
virJSONValuePtr ret_array = NULL;
|
||||||
@ -1994,7 +1994,7 @@ qemuAgentGetInterfaces(qemuAgentPtr mon,
|
|||||||
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;
|
||||||
int ip_addr_arr_size;
|
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 */
|
||||||
|
@ -1265,7 +1265,7 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
int *threads = NULL;
|
int *threads = NULL;
|
||||||
int ncpus;
|
ssize_t ncpus;
|
||||||
|
|
||||||
if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
|
if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
@ -3061,7 +3061,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;
|
||||||
int nTable;
|
ssize_t nTable;
|
||||||
size_t i;
|
size_t i;
|
||||||
virNetDevRxFilterPtr fil = virNetDevRxFilterNew();
|
virNetDevRxFilterPtr fil = virNetDevRxFilterNew();
|
||||||
|
|
||||||
@ -4090,7 +4090,7 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
|
|||||||
virJSONValuePtr cmd = NULL;
|
virJSONValuePtr cmd = NULL;
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
int nr_results;
|
ssize_t nr_results;
|
||||||
size_t i;
|
size_t i;
|
||||||
virHashTablePtr blockJobs = NULL;
|
virHashTablePtr blockJobs = NULL;
|
||||||
|
|
||||||
@ -4597,7 +4597,7 @@ int qemuMonitorJSONGetMachines(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
qemuMonitorMachineInfoPtr *infolist = NULL;
|
qemuMonitorMachineInfoPtr *infolist = NULL;
|
||||||
int n = 0;
|
ssize_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*machines = NULL;
|
*machines = NULL;
|
||||||
@ -4777,7 +4777,7 @@ int qemuMonitorJSONGetCommands(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
char **commandlist = NULL;
|
char **commandlist = NULL;
|
||||||
int n = 0;
|
ssize_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*commands = NULL;
|
*commands = NULL;
|
||||||
@ -4845,7 +4845,7 @@ int qemuMonitorJSONGetEvents(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
char **eventlist = NULL;
|
char **eventlist = NULL;
|
||||||
int n = 0;
|
ssize_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*events = NULL;
|
*events = NULL;
|
||||||
@ -4922,7 +4922,7 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr data = NULL;
|
virJSONValuePtr data = NULL;
|
||||||
virJSONValuePtr array = NULL;
|
virJSONValuePtr array = NULL;
|
||||||
char **paramlist = NULL;
|
char **paramlist = NULL;
|
||||||
int n = 0;
|
ssize_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*params = NULL;
|
*params = NULL;
|
||||||
@ -5093,7 +5093,7 @@ int qemuMonitorJSONGetObjectTypes(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
char **typelist = NULL;
|
char **typelist = NULL;
|
||||||
int n = 0;
|
ssize_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*types = NULL;
|
*types = NULL;
|
||||||
@ -5162,7 +5162,7 @@ int qemuMonitorJSONGetObjectListPaths(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
qemuMonitorJSONListPathPtr *pathlist = NULL;
|
qemuMonitorJSONListPathPtr *pathlist = NULL;
|
||||||
int n = 0;
|
ssize_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*paths = NULL;
|
*paths = NULL;
|
||||||
@ -5408,7 +5408,7 @@ int qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
char **proplist = NULL;
|
char **proplist = NULL;
|
||||||
int n = 0;
|
ssize_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*props = NULL;
|
*props = NULL;
|
||||||
@ -5527,7 +5527,7 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr caps;
|
virJSONValuePtr caps;
|
||||||
char **list = NULL;
|
char **list = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
int n;
|
ssize_t n;
|
||||||
|
|
||||||
*capabilities = NULL;
|
*capabilities = NULL;
|
||||||
|
|
||||||
@ -5804,7 +5804,7 @@ qemuMonitorJSONGetStringArray(qemuMonitorPtr mon, const char *qmpCmd,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
char **list = NULL;
|
char **list = NULL;
|
||||||
int n = 0;
|
ssize_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*array = NULL;
|
*array = NULL;
|
||||||
@ -6167,7 +6167,7 @@ qemuMonitorJSONGetCPUx86Data(qemuMonitorPtr mon,
|
|||||||
virCPUx86Data *x86Data = NULL;
|
virCPUx86Data *x86Data = NULL;
|
||||||
virCPUx86CPUID cpuid;
|
virCPUx86CPUID cpuid;
|
||||||
size_t i;
|
size_t i;
|
||||||
int n;
|
ssize_t n;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
/* look up if the property exists before asking */
|
/* look up if the property exists before asking */
|
||||||
@ -6330,7 +6330,7 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
qemuMonitorIOThreadInfoPtr *infolist = NULL;
|
qemuMonitorIOThreadInfoPtr *infolist = NULL;
|
||||||
int n = 0;
|
ssize_t n = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
*iothreads = NULL;
|
*iothreads = NULL;
|
||||||
|
@ -369,7 +369,7 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
|
|||||||
virJSONValuePtr clients;
|
virJSONValuePtr clients;
|
||||||
virJSONValuePtr services;
|
virJSONValuePtr services;
|
||||||
size_t i;
|
size_t i;
|
||||||
int n;
|
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;
|
||||||
|
@ -328,7 +328,7 @@ virNetServerServicePtr virNetServerServiceNewPostExecRestart(virJSONValuePtr obj
|
|||||||
virNetServerServicePtr svc;
|
virNetServerServicePtr svc;
|
||||||
virJSONValuePtr socks;
|
virJSONValuePtr socks;
|
||||||
size_t i;
|
size_t i;
|
||||||
int n;
|
ssize_t n;
|
||||||
unsigned int max;
|
unsigned int max;
|
||||||
|
|
||||||
if (virNetServerServiceInitialize() < 0)
|
if (virNetServerServiceInitialize() < 0)
|
||||||
|
@ -864,7 +864,7 @@ virJSONValueIsArray(virJSONValuePtr array)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
ssize_t
|
||||||
virJSONValueArraySize(const virJSONValue *array)
|
virJSONValueArraySize(const virJSONValue *array)
|
||||||
{
|
{
|
||||||
if (array->type != VIR_JSON_TYPE_ARRAY)
|
if (array->type != VIR_JSON_TYPE_ARRAY)
|
||||||
|
@ -114,7 +114,7 @@ virJSONValuePtr virJSONValueObjectGetByType(virJSONValuePtr object,
|
|||||||
const char *key, virJSONType type);
|
const char *key, virJSONType type);
|
||||||
|
|
||||||
bool virJSONValueIsArray(virJSONValuePtr array);
|
bool virJSONValueIsArray(virJSONValuePtr array);
|
||||||
int virJSONValueArraySize(const virJSONValue *array);
|
ssize_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);
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONValuePtr object)
|
|||||||
{
|
{
|
||||||
virLockSpacePtr lockspace;
|
virLockSpacePtr lockspace;
|
||||||
virJSONValuePtr resources;
|
virJSONValuePtr resources;
|
||||||
int n;
|
ssize_t n;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
VIR_DEBUG("object=%p", object);
|
VIR_DEBUG("object=%p", object);
|
||||||
@ -336,7 +336,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONValuePtr object)
|
|||||||
const char *tmp;
|
const char *tmp;
|
||||||
virJSONValuePtr owners;
|
virJSONValuePtr owners;
|
||||||
size_t j;
|
size_t j;
|
||||||
int m;
|
ssize_t m;
|
||||||
|
|
||||||
if (VIR_ALLOC(res) < 0)
|
if (VIR_ALLOC(res) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
Loading…
Reference in New Issue
Block a user