mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-26 14:03:49 +03:00
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: Andrea Bolognani <abologna@redhat.com> ACKed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
fcf78395d7
commit
956817ef49
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user