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@xxxxxxxxxx> --- src/locking/lock_daemon.c | 2 +- src/network/bridge_driver.c | 2 +- src/qemu/qemu_agent.c | 12 ++++++------ src/qemu/qemu_monitor_json.c | 28 ++++++++++++++-------------- src/rpc/virnetserver.c | 2 +- src/rpc/virnetserverservice.c | 2 +- src/util/virjson.c | 2 +- src/util/virjson.h | 2 +- src/util/virlockspace.c | 4 ++-- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index bf87af1..55fc0c3 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -184,7 +184,7 @@ virLockDaemonNewPostExecRestart(virJSONValuePtr object, bool privileged) virJSONValuePtr lockspaces; virNetServerPtr srv; size_t i; - int n; + ssize_t n; if (VIR_ALLOC(lockd) < 0) return NULL; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index c343e5b..cd9a51e 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -3599,7 +3599,7 @@ networkGetDHCPLeases(virNetworkPtr network, size_t i, j; size_t nleases = 0; int rv = -1; - int size = 0; + ssize_t size = 0; int custom_lease_file_len = 0; bool need_results = !!leases; long long currtime = 0; diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 7021a7a..5735ed8 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1461,7 +1461,7 @@ qemuAgentGetVCPUs(qemuAgentPtr mon, virJSONValuePtr cmd; virJSONValuePtr reply = NULL; virJSONValuePtr data = NULL; - int ndata; + ssize_t ndata; if (!(cmd = qemuAgentMakeCommand("guest-get-vcpus", NULL))) return -1; @@ -1767,7 +1767,7 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info, { size_t i, j, k; int ret = -1; - int ndata = 0, ndisk; + ssize_t ndata = 0, ndisk; char **alias; virJSONValuePtr cmd; virJSONValuePtr reply = NULL; @@ -1810,7 +1810,7 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info, if (!entry) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("array element '%zd' of '%d' missing in " + _("array element '%zd' of '%zd' missing in " "guest-get-fsinfo return data"), i, ndata); goto cleanup; @@ -1871,7 +1871,7 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info, if (!disk) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("array element '%zd' of '%d' missing in " + _("array element '%zd' of '%zd' missing in " "guest-get-fsinfo 'disk' data"), j, ndisk); goto cleanup; @@ -1954,7 +1954,7 @@ qemuAgentGetInterfaces(qemuAgentPtr mon, { int ret = -1; size_t i, j; - int size = -1; + ssize_t size = -1; virJSONValuePtr cmd = NULL; virJSONValuePtr reply = NULL; virJSONValuePtr ret_array = NULL; @@ -1994,7 +1994,7 @@ qemuAgentGetInterfaces(qemuAgentPtr mon, virJSONValuePtr tmp_iface = virJSONValueArrayGet(ret_array, i); virJSONValuePtr ip_addr_arr = NULL; const char *hwaddr, *ifname_s, *name = NULL; - int ip_addr_arr_size; + ssize_t ip_addr_arr_size; virDomainInterfacePtr iface = NULL; /* Shouldn't happen but doesn't hurt to check neither */ diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index df0c82a..b39b29b 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1265,7 +1265,7 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply, int ret = -1; size_t i; int *threads = NULL; - int ncpus; + ssize_t ncpus; if (!(data = virJSONValueObjectGetArray(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -3061,7 +3061,7 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValuePtr msg, int ret = -1; const char *tmp; virJSONValuePtr returnArray, entry, table, element; - int nTable; + ssize_t nTable; size_t i; virNetDevRxFilterPtr fil = virNetDevRxFilterNew(); @@ -4090,7 +4090,7 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon) virJSONValuePtr cmd = NULL; virJSONValuePtr reply = NULL; virJSONValuePtr data; - int nr_results; + ssize_t nr_results; size_t i; virHashTablePtr blockJobs = NULL; @@ -4597,7 +4597,7 @@ int qemuMonitorJSONGetMachines(qemuMonitorPtr mon, virJSONValuePtr reply = NULL; virJSONValuePtr data; qemuMonitorMachineInfoPtr *infolist = NULL; - int n = 0; + ssize_t n = 0; size_t i; *machines = NULL; @@ -4777,7 +4777,7 @@ int qemuMonitorJSONGetCommands(qemuMonitorPtr mon, virJSONValuePtr reply = NULL; virJSONValuePtr data; char **commandlist = NULL; - int n = 0; + ssize_t n = 0; size_t i; *commands = NULL; @@ -4845,7 +4845,7 @@ int qemuMonitorJSONGetEvents(qemuMonitorPtr mon, virJSONValuePtr reply = NULL; virJSONValuePtr data; char **eventlist = NULL; - int n = 0; + ssize_t n = 0; size_t i; *events = NULL; @@ -4922,7 +4922,7 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon, virJSONValuePtr data = NULL; virJSONValuePtr array = NULL; char **paramlist = NULL; - int n = 0; + ssize_t n = 0; size_t i; *params = NULL; @@ -5093,7 +5093,7 @@ int qemuMonitorJSONGetObjectTypes(qemuMonitorPtr mon, virJSONValuePtr reply = NULL; virJSONValuePtr data; char **typelist = NULL; - int n = 0; + ssize_t n = 0; size_t i; *types = NULL; @@ -5162,7 +5162,7 @@ int qemuMonitorJSONGetObjectListPaths(qemuMonitorPtr mon, virJSONValuePtr reply = NULL; virJSONValuePtr data; qemuMonitorJSONListPathPtr *pathlist = NULL; - int n = 0; + ssize_t n = 0; size_t i; *paths = NULL; @@ -5408,7 +5408,7 @@ int qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon, virJSONValuePtr reply = NULL; virJSONValuePtr data; char **proplist = NULL; - int n = 0; + ssize_t n = 0; size_t i; *props = NULL; @@ -5527,7 +5527,7 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon, virJSONValuePtr caps; char **list = NULL; size_t i; - int n; + ssize_t n; *capabilities = NULL; @@ -5804,7 +5804,7 @@ qemuMonitorJSONGetStringArray(qemuMonitorPtr mon, const char *qmpCmd, virJSONValuePtr reply = NULL; virJSONValuePtr data; char **list = NULL; - int n = 0; + ssize_t n = 0; size_t i; *array = NULL; @@ -6167,7 +6167,7 @@ qemuMonitorJSONGetCPUx86Data(qemuMonitorPtr mon, virCPUx86Data *x86Data = NULL; virCPUx86CPUID cpuid; size_t i; - int n; + ssize_t n; int ret = -1; /* look up if the property exists before asking */ @@ -6330,7 +6330,7 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon, virJSONValuePtr reply = NULL; virJSONValuePtr data; qemuMonitorIOThreadInfoPtr *infolist = NULL; - int n = 0; + ssize_t n = 0; size_t i; *iothreads = NULL; diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 80b5588..547e52e 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -369,7 +369,7 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object, virJSONValuePtr clients; virJSONValuePtr services; size_t i; - int n; + ssize_t n; unsigned int min_workers; unsigned int max_workers; unsigned int priority_workers; diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c index 3b35fc0..1ef0636 100644 --- a/src/rpc/virnetserverservice.c +++ b/src/rpc/virnetserverservice.c @@ -328,7 +328,7 @@ virNetServerServicePtr virNetServerServiceNewPostExecRestart(virJSONValuePtr obj virNetServerServicePtr svc; virJSONValuePtr socks; size_t i; - int n; + ssize_t n; unsigned int max; if (virNetServerServiceInitialize() < 0) diff --git a/src/util/virjson.c b/src/util/virjson.c index c123943..ae6362b 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -864,7 +864,7 @@ virJSONValueIsArray(virJSONValuePtr array) } -int +ssize_t virJSONValueArraySize(const virJSONValue *array) { if (array->type != VIR_JSON_TYPE_ARRAY) diff --git a/src/util/virjson.h b/src/util/virjson.h index a7df6e5..66ed48a 100644 --- a/src/util/virjson.h +++ b/src/util/virjson.h @@ -114,7 +114,7 @@ virJSONValuePtr virJSONValueObjectGetByType(virJSONValuePtr object, const char *key, virJSONType type); bool virJSONValueIsArray(virJSONValuePtr array); -int virJSONValueArraySize(const virJSONValue *array); +ssize_t virJSONValueArraySize(const virJSONValue *array); virJSONValuePtr virJSONValueArrayGet(virJSONValuePtr object, unsigned int element); virJSONValuePtr virJSONValueArraySteal(virJSONValuePtr object, unsigned int element); diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c index 2366a74..7aa0f1d 100644 --- a/src/util/virlockspace.c +++ b/src/util/virlockspace.c @@ -293,7 +293,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONValuePtr object) { virLockSpacePtr lockspace; virJSONValuePtr resources; - int n; + ssize_t n; size_t i; VIR_DEBUG("object=%p", object); @@ -336,7 +336,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONValuePtr object) const char *tmp; virJSONValuePtr owners; size_t j; - int m; + ssize_t m; if (VIR_ALLOC(res) < 0) goto error; -- 2.4.9 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list