提交 d1a71023 编写于 作者: M Michal Privoznik 提交者: Cole Robinson

virStringListLength: Ensure const correctness

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: NMichal Privoznik <mprivozn@redhat.com>

(crobinso: fix up spacing and squash in sheepdog bit suggested
 by Andrea)
上级 129c3532
...@@ -611,7 +611,7 @@ lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void *data) ...@@ -611,7 +611,7 @@ lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void *data)
family = AF_INET6; family = AF_INET6;
ipparts = virStringSplit(value->str, "/", 2); ipparts = virStringSplit(value->str, "/", 2);
if (virStringListLength(ipparts) != 2 || if (virStringListLength((const char * const *)ipparts) != 2 ||
virSocketAddrParse(&ip->address, ipparts[0], family) < 0 || virSocketAddrParse(&ip->address, ipparts[0], family) < 0 ||
virStrToLong_ui(ipparts[1], NULL, 10, &ip->prefix) < 0) { virStrToLong_ui(ipparts[1], NULL, 10, &ip->prefix) < 0) {
......
...@@ -167,7 +167,8 @@ virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -167,7 +167,8 @@ virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn ATTRIBUTE_UNUSED,
cells = virStringSplit(line, " ", 0); 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) if (virStorageBackendSheepdogAddVolume(conn, pool, cells[1]) < 0)
goto cleanup; goto cleanup;
} }
......
...@@ -3209,7 +3209,7 @@ virStorageAddISCSIPoolSourceHost(virDomainDiskDefPtr def, ...@@ -3209,7 +3209,7 @@ virStorageAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
if (!(tokens = virStringSplit(def->src->srcpool->volume, ":", 0))) if (!(tokens = virStringSplit(def->src->srcpool->volume, ":", 0)))
goto cleanup; goto cleanup;
if (virStringListLength(tokens) != 4) { if (virStringListLength((const char * const *)tokens) != 4) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected iscsi volume name '%s'"), _("unexpected iscsi volume name '%s'"),
def->src->srcpool->volume); def->src->srcpool->volume);
......
...@@ -965,7 +965,7 @@ int virProcessGetStartTime(pid_t pid, ...@@ -965,7 +965,7 @@ int virProcessGetStartTime(pid_t pid,
tokens = virStringSplit(tmp, " ", 0); tokens = virStringSplit(tmp, " ", 0);
if (virStringListLength(tokens) < 20) { if (virStringListLength((const char * const *)tokens) < 20) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot find start time in %s"), _("Cannot find start time in %s"),
filename); filename);
......
...@@ -1283,7 +1283,7 @@ virStorageFileParseChainIndex(const char *diskTarget, ...@@ -1283,7 +1283,7 @@ virStorageFileParseChainIndex(const char *diskTarget,
if (name && diskTarget) if (name && diskTarget)
strings = virStringSplit(name, "[", 2); strings = virStringSplit(name, "[", 2);
if (virStringListLength(strings) != 2) if (virStringListLength((const char * const *)strings) != 2)
goto cleanup; goto cleanup;
if (virStrToLong_uip(strings[1], &suffix, 10, &idx) < 0 || if (virStrToLong_uip(strings[1], &suffix, 10, &idx) < 0 ||
......
...@@ -765,7 +765,7 @@ virStrndup(char **dest, ...@@ -765,7 +765,7 @@ virStrndup(char **dest,
} }
size_t virStringListLength(char **strings) size_t virStringListLength(const char * const *strings)
{ {
size_t i = 0; size_t i = 0;
......
...@@ -201,7 +201,7 @@ int virVasprintfInternal(bool report, int domcode, const char *filename, ...@@ -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, \ # define VIR_STRNDUP_QUIET(dst, src, n) virStrndup(&(dst), src, n, false, \
0, NULL, NULL, 0) 0, NULL, NULL, 0)
size_t virStringListLength(char **strings); size_t virStringListLength(const char * const *strings);
/** /**
* virVasprintf * virVasprintf
......
...@@ -336,10 +336,10 @@ testStringSearch(const void *opaque) ...@@ -336,10 +336,10 @@ testStringSearch(const void *opaque)
goto cleanup; 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", fprintf(stderr, "expected %zu matches on %s but got %zd matches\n",
data->expectNMatches, data->str, data->expectNMatches, data->str,
virStringListLength(matches)); virStringListLength((const char * const *)matches));
goto cleanup; goto cleanup;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册