Some callers don't need to know the actual lenght of the list but only care whether the required element is present or the list is non-empty. Don't calculate the list length in those cases. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/lxc/lxc_native.c | 2 +- src/qemu/qemu_driver.c | 2 +- src/storage/storage_backend_sheepdog.c | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index e68977dd99..4229a9ca7a 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -568,7 +568,7 @@ lxcNetworkParseDataIPs(const char *name, family = AF_INET6; ipparts = virStringSplit(value->str, "/", 2); - if (virStringListLength((const char * const *)ipparts) != 2 || + if (!ipparts || !ipparts[0] || !ipparts[1] || virSocketAddrParse(&ip->address, ipparts[0], family) < 0 || virStrToLong_ui(ipparts[1], NULL, 10, &ip->prefix) < 0) { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c34af6b7d1..80bd27696b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17737,7 +17737,7 @@ qemuDomainGetResctrlMonData(virQEMUDriverPtr driver, return -1; } - if (virStringListLength((const char * const *)features) == 0) + if (!features || !*features) return 0; for (i = 0; i < dom->def->nresctrls; i++) { diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c index 178cfbae11..2db2384e67 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -157,8 +157,7 @@ virStorageBackendSheepdogRefreshAllVol(virStoragePoolObjPtr pool) cells = virStringSplit(lines[i], " ", 0); - if (cells != NULL && - virStringListLength((const char * const *)cells) > 2) { + if (cells != NULL && cells[0] && cells[1]) { if (virStorageBackendSheepdogAddVolume(pool, cells[1]) < 0) return -1; } -- 2.29.2