]> xenbits.xensource.com Git - libvirt.git/commitdiff
virStringListLength: Ensure const correctness
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 9 Feb 2016 17:18:49 +0000 (18:18 +0100)
committerCole Robinson <crobinso@redhat.com>
Tue, 9 Feb 2016 20:44:58 +0000 (15:44 -0500)
The virStringListLength function does not ever modify the passed
string list. It merely counts the items in it. Make sure that we
reflect this bit in the function header.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(crobinso: fix up spacing and squash in sheepdog bit suggested
 by Andrea)

src/lxc/lxc_native.c
src/storage/storage_backend_sheepdog.c
src/storage/storage_driver.c
src/util/virprocess.c
src/util/virstoragefile.c
src/util/virstring.c
src/util/virstring.h
tests/virstringtest.c

index 78f9c6789bc1ec15b72da87ea94da6308ce7cc95..ef92c7ddffee4098e64a1d6016e082df607b91e6 100644 (file)
@@ -611,7 +611,7 @@ lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void *data)
             family = AF_INET6;
 
         ipparts = virStringSplit(value->str, "/", 2);
-        if (virStringListLength(ipparts) != 2 ||
+        if (virStringListLength((const char * const *)ipparts) != 2 ||
             virSocketAddrParse(&ip->address, ipparts[0], family) < 0 ||
             virStrToLong_ui(ipparts[1], NULL, 10, &ip->prefix) < 0) {
 
index 12008139112ae7fbfd34dbc8f48d24307a5b934a..a3bd78a2d1ec4fbec620437cfb09d29ac6edeba1 100644 (file)
@@ -167,7 +167,8 @@ virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 
         cells = virStringSplit(line, " ", 0);
 
-        if (cells != NULL && virStringListLength(cells) > 2) {
+        if (cells != NULL &&
+            virStringListLength((const char * const *)cells) > 2) {
             if (virStorageBackendSheepdogAddVolume(conn, pool, cells[1]) < 0)
                 goto cleanup;
         }
index ed5395be9cbc68634f92510bce6c9863810c25a3..8ee28406f23246fa47367570d0e2f31474ad9648 100644 (file)
@@ -3209,7 +3209,7 @@ virStorageAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
     if (!(tokens = virStringSplit(def->src->srcpool->volume, ":", 0)))
         goto cleanup;
 
-    if (virStringListLength(tokens) != 4) {
+    if (virStringListLength((const char * const *)tokens) != 4) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("unexpected iscsi volume name '%s'"),
                        def->src->srcpool->volume);
index 277b3bc34e2034e58a123ec7a1fa474cc3c00ee5..c7ffa42066c73a0e8740ba24a61d471e6e1565fc 100644 (file)
@@ -965,7 +965,7 @@ int virProcessGetStartTime(pid_t pid,
 
     tokens = virStringSplit(tmp, " ", 0);
 
-    if (virStringListLength(tokens) < 20) {
+    if (virStringListLength((const char * const *)tokens) < 20) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Cannot find start time in %s"),
                        filename);
index 101070f95ae8900b1f9950bdab2e786c2e274f81..3e79ae139699345ec1114204a2b2433812477f56 100644 (file)
@@ -1283,7 +1283,7 @@ virStorageFileParseChainIndex(const char *diskTarget,
     if (name && diskTarget)
         strings = virStringSplit(name, "[", 2);
 
-    if (virStringListLength(strings) != 2)
+    if (virStringListLength((const char * const *)strings) != 2)
         goto cleanup;
 
     if (virStrToLong_uip(strings[1], &suffix, 10, &idx) < 0 ||
index fc4f5ba7e641b7efca71ae832ee254dd730f646f..7ec42aa18903d115b2f3d7ffc2f906a2da9587b8 100644 (file)
@@ -765,7 +765,7 @@ virStrndup(char **dest,
 }
 
 
-size_t virStringListLength(char **strings)
+size_t virStringListLength(const char * const *strings)
 {
     size_t i = 0;
 
index cdf10588259cee7aa5bb989d6951a1b6c8f00a20..16ed3b29a50c2abd4d634607e4da7fb51918b254 100644 (file)
@@ -201,7 +201,7 @@ int virVasprintfInternal(bool report, int domcode, const char *filename,
 # define VIR_STRNDUP_QUIET(dst, src, n) virStrndup(&(dst), src, n, false, \
                                                    0, NULL, NULL, 0)
 
-size_t virStringListLength(char **strings);
+size_t virStringListLength(const char * const *strings);
 
 /**
  * virVasprintf
index 38d0126d26c8629f6af80234aa5462bb331bf5bc..7a1dcfdfb8847d2cf6d16ff6442882ab3d930e22 100644 (file)
@@ -336,10 +336,10 @@ testStringSearch(const void *opaque)
             goto cleanup;
         }
 
-        if (virStringListLength(matches) != nmatches) {
+        if (virStringListLength((const char * const *)matches) != nmatches) {
             fprintf(stderr, "expected %zu matches on %s but got %zd matches\n",
                     data->expectNMatches, data->str,
-                    virStringListLength(matches));
+                    virStringListLength((const char * const *)matches));
             goto cleanup;
         }