While this function is not, strictly speaking, a predicate,
it still mostly behaves like one as evidenced by the vast
majority of its callers, so using bool rather than int as
the return type makes sense.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/util/virstring.c | 8 ++++----
src/util/virstring.h | 4 ++--
tests/testutilsqemu.c | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/util/virstring.c b/src/util/virstring.c
index cd781a84f9..e479d3194c 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -1261,7 +1261,7 @@ virStringHasCaseSuffix(const char *str,
return STRCASEEQ(str + len - suffixlen, suffix);
}
-int
+bool
virStringStripSuffix(char *str,
const char *suffix)
{
@@ -1269,14 +1269,14 @@ virStringStripSuffix(char *str,
int suffixlen = strlen(suffix);
if (len < suffixlen)
- return 0;
+ return false;
if (STRNEQ(str + len - suffixlen, suffix))
- return 0;
+ return false;
str[len - suffixlen] = '\0';
- return 1;
+ return true;
}
int
diff --git a/src/util/virstring.h b/src/util/virstring.h
index ed2db8a3dc..f5f1ecbe1e 100644
--- a/src/util/virstring.h
+++ b/src/util/virstring.h
@@ -292,8 +292,8 @@ bool virStringHasSuffix(const char *str,
const char *suffix);
bool virStringHasCaseSuffix(const char *str,
const char *suffix);
-int virStringStripSuffix(char *str,
- const char *suffix) ATTRIBUTE_RETURN_CHECK;
+bool virStringStripSuffix(char *str,
+ const char *suffix) ATTRIBUTE_RETURN_CHECK;
int virStringMatchesNameSuffix(const char *file,
const char *name,
const char *suffix);
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 61bf67d5ad..03a3f86c62 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -834,7 +834,7 @@ testQemuGetLatestCapsForArch(const char *dirname,
if (rc == 0)
continue;
- if (virStringStripSuffix(tmp, fullsuffix) != 1)
+ if (!virStringStripSuffix(tmp, fullsuffix))
continue;
if (virParseVersionString(tmp, &ver, false) < 0) {
--
2.20.1