提交 4f77c48c 编写于 作者: M Michal Privoznik

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: NMichal Privoznik <mprivozn@redhat.com>
上级 6c928996
......@@ -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;
......
......@@ -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;
......
......@@ -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 */
......
......@@ -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;
......
......@@ -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;
......
......@@ -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)
......
......@@ -864,7 +864,7 @@ virJSONValueIsArray(virJSONValuePtr array)
}
int
ssize_t
virJSONValueArraySize(const virJSONValue *array)
{
if (array->type != VIR_JSON_TYPE_ARRAY)
......
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册