提交 956817ef 编写于 作者: A Andrea Bolognani

util: Make virStringStripSuffix() return bool

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: NAndrea Bolognani <abologna@redhat.com>
ACKed-by: NPeter Krempa <pkrempa@redhat.com>
上级 fcf78395
...@@ -1261,7 +1261,7 @@ virStringHasCaseSuffix(const char *str, ...@@ -1261,7 +1261,7 @@ virStringHasCaseSuffix(const char *str,
return STRCASEEQ(str + len - suffixlen, suffix); return STRCASEEQ(str + len - suffixlen, suffix);
} }
int bool
virStringStripSuffix(char *str, virStringStripSuffix(char *str,
const char *suffix) const char *suffix)
{ {
...@@ -1269,14 +1269,14 @@ virStringStripSuffix(char *str, ...@@ -1269,14 +1269,14 @@ virStringStripSuffix(char *str,
int suffixlen = strlen(suffix); int suffixlen = strlen(suffix);
if (len < suffixlen) if (len < suffixlen)
return 0; return false;
if (STRNEQ(str + len - suffixlen, suffix)) if (STRNEQ(str + len - suffixlen, suffix))
return 0; return false;
str[len - suffixlen] = '\0'; str[len - suffixlen] = '\0';
return 1; return true;
} }
int int
......
...@@ -292,8 +292,8 @@ bool virStringHasSuffix(const char *str, ...@@ -292,8 +292,8 @@ bool virStringHasSuffix(const char *str,
const char *suffix); const char *suffix);
bool virStringHasCaseSuffix(const char *str, bool virStringHasCaseSuffix(const char *str,
const char *suffix); const char *suffix);
int virStringStripSuffix(char *str, bool virStringStripSuffix(char *str,
const char *suffix) ATTRIBUTE_RETURN_CHECK; const char *suffix) ATTRIBUTE_RETURN_CHECK;
int virStringMatchesNameSuffix(const char *file, int virStringMatchesNameSuffix(const char *file,
const char *name, const char *name,
const char *suffix); const char *suffix);
......
...@@ -834,7 +834,7 @@ testQemuGetLatestCapsForArch(const char *dirname, ...@@ -834,7 +834,7 @@ testQemuGetLatestCapsForArch(const char *dirname,
if (rc == 0) if (rc == 0)
continue; continue;
if (virStringStripSuffix(tmp, fullsuffix) != 1) if (!virStringStripSuffix(tmp, fullsuffix))
continue; continue;
if (virParseVersionString(tmp, &ver, false) < 0) { if (virParseVersionString(tmp, &ver, false) < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册