mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Replace virStringListLength where actual lenght is not needed
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@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
|
||||
@@ -17739,7 +17739,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++) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user