summaryrefslogtreecommitdiff
path: root/tools/nss
diff options
context:
space:
mode:
authorJohn Ferlan <jferlan@redhat.com>2018-04-19 17:29:02 -0400
committerJohn Ferlan <jferlan@redhat.com>2018-05-10 14:59:15 -0400
commit4a3d6ed5ee07d2cbfb6577f3870ef1d947177b67 (patch)
treef5747b1fd2efc8e9f7227af8c60ac772b3641606 /tools/nss
parent91234b05736d14d800b4e611a1f7cf3209c5be92 (diff)
downloadlibvirt-4a3d6ed5ee07d2cbfb6577f3870ef1d947177b67.tar.gz
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>
Diffstat (limited to 'tools/nss')
-rw-r--r--tools/nss/libvirt_nss.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
index 62fe589bed..ec73ea575a 100644
--- a/tools/nss/libvirt_nss.c
+++ b/tools/nss/libvirt_nss.c
@@ -309,8 +309,7 @@ findLease(const char *name,
}
VIR_DIR_CLOSE(dir);
- if ((nleases = virJSONValueArraySize(leases_array)) < 0)
- goto cleanup;
+ nleases = virJSONValueArraySize(leases_array);
DEBUG("Read %zd leases", nleases);
#if !defined(LIBVIRT_NSS_GUEST)