mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
Use virStringHasSuffix() where possible
When dealing with internal paths we don't need to worry about whether or not suffixes are lowercase since we have full control over them, which means we can avoid performing case-insensitive string comparisons. Signed-off-by: Andrea Bolognani <abologna@redhat.com> ACKed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
d93b9e8829
commit
094f29df07
@ -949,7 +949,7 @@ virSecretLoadAllConfigs(virSecretObjListPtr secrets,
|
||||
char *path;
|
||||
virSecretObjPtr obj;
|
||||
|
||||
if (!virStringHasCaseSuffix(de->d_name, ".xml"))
|
||||
if (!virStringHasSuffix(de->d_name, ".xml"))
|
||||
continue;
|
||||
|
||||
if (!(path = virFileBuildPath(configDir, de->d_name, NULL)))
|
||||
|
@ -1719,7 +1719,7 @@ virStoragePoolObjLoadAllConfigs(virStoragePoolObjListPtr pools,
|
||||
char *autostartLink;
|
||||
virStoragePoolObjPtr obj;
|
||||
|
||||
if (!virStringHasCaseSuffix(entry->d_name, ".xml"))
|
||||
if (!virStringHasSuffix(entry->d_name, ".xml"))
|
||||
continue;
|
||||
|
||||
if (!(path = virFileBuildPath(configDir, entry->d_name, NULL)))
|
||||
|
@ -1600,7 +1600,7 @@ virVMXParseConfig(virVMXContext *ctx,
|
||||
if (virVMXGetConfigString(conf, "guestOS", &guestOS, true) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (guestOS != NULL && virStringHasCaseSuffix(guestOS, "-64")) {
|
||||
if (guestOS != NULL && virStringHasSuffix(guestOS, "-64")) {
|
||||
def->os.arch = VIR_ARCH_X86_64;
|
||||
} else {
|
||||
def->os.arch = VIR_ARCH_I686;
|
||||
|
@ -525,8 +525,8 @@ virTestRewrapFile(const char *filename)
|
||||
char *script = NULL;
|
||||
virCommandPtr cmd = NULL;
|
||||
|
||||
if (!(virStringHasCaseSuffix(filename, ".args") ||
|
||||
virStringHasCaseSuffix(filename, ".ldargs")))
|
||||
if (!(virStringHasSuffix(filename, ".args") ||
|
||||
virStringHasSuffix(filename, ".ldargs")))
|
||||
return 0;
|
||||
|
||||
if (!perl) {
|
||||
|
@ -41,7 +41,7 @@ static int
|
||||
testSchemaFile(const void *args)
|
||||
{
|
||||
const struct testSchemaData *data = args;
|
||||
bool shouldFail = virStringHasCaseSuffix(data->xml_path, "-invalid.xml");
|
||||
bool shouldFail = virStringHasSuffix(data->xml_path, "-invalid.xml");
|
||||
xmlDocPtr xml = NULL;
|
||||
int ret = -1;
|
||||
|
||||
@ -82,7 +82,7 @@ testSchemaDir(const char *schema,
|
||||
return -1;
|
||||
|
||||
while ((rc = virDirRead(dir, &ent, dir_path)) > 0) {
|
||||
if (!virStringHasCaseSuffix(ent->d_name, ".xml"))
|
||||
if (!virStringHasSuffix(ent->d_name, ".xml"))
|
||||
continue;
|
||||
if (ent->d_name[0] == '.')
|
||||
continue;
|
||||
|
@ -274,7 +274,7 @@ findLease(const char *name,
|
||||
while ((ret = virDirRead(dir, &entry, leaseDir)) > 0) {
|
||||
char *path;
|
||||
|
||||
if (virStringHasCaseSuffix(entry->d_name, ".status")) {
|
||||
if (virStringHasSuffix(entry->d_name, ".status")) {
|
||||
if (!(path = virFileBuildPath(leaseDir, entry->d_name, NULL)))
|
||||
goto cleanup;
|
||||
|
||||
@ -285,7 +285,7 @@ findLease(const char *name,
|
||||
goto cleanup;
|
||||
}
|
||||
VIR_FREE(path);
|
||||
} else if (virStringHasCaseSuffix(entry->d_name, ".macs")) {
|
||||
} else if (virStringHasSuffix(entry->d_name, ".macs")) {
|
||||
if (!(path = virFileBuildPath(leaseDir, entry->d_name, NULL)))
|
||||
goto cleanup;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user