]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Replace virStringListLength where actual lenght is not needed
authorPeter Krempa <pkrempa@redhat.com>
Fri, 5 Feb 2021 16:39:52 +0000 (17:39 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 11 Feb 2021 16:05:34 +0000 (17:05 +0100)
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>
src/lxc/lxc_native.c
src/qemu/qemu_driver.c
src/storage/storage_backend_sheepdog.c

index e68977dd99f5f8fa3c5523b003d5f56ca3fbfff8..4229a9ca7a07dc0e85e8f25541ec8d0d85ae12d6 100644 (file)
@@ -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) {
 
index b0d907fbb313bbeaf676d50ceeafafbe5410e6a4..6c468632e0e4797a1a9752de37466c54d65f0183 100644 (file)
@@ -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++) {
index 178cfbae116fe4bfb5845eafeebe6d13341b84cb..2db2384e670424f5b9e604be28326449b193f4d7 100644 (file)
@@ -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;
         }