提交 094f29df 编写于 作者: A Andrea Bolognani

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: NAndrea Bolognani <abologna@redhat.com>
ACKed-by: NPeter Krempa <pkrempa@redhat.com>
上级 d93b9e88
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册