提交 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, ...@@ -949,7 +949,7 @@ virSecretLoadAllConfigs(virSecretObjListPtr secrets,
char *path; char *path;
virSecretObjPtr obj; virSecretObjPtr obj;
if (!virStringHasCaseSuffix(de->d_name, ".xml")) if (!virStringHasSuffix(de->d_name, ".xml"))
continue; continue;
if (!(path = virFileBuildPath(configDir, de->d_name, NULL))) if (!(path = virFileBuildPath(configDir, de->d_name, NULL)))
......
...@@ -1719,7 +1719,7 @@ virStoragePoolObjLoadAllConfigs(virStoragePoolObjListPtr pools, ...@@ -1719,7 +1719,7 @@ virStoragePoolObjLoadAllConfigs(virStoragePoolObjListPtr pools,
char *autostartLink; char *autostartLink;
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
if (!virStringHasCaseSuffix(entry->d_name, ".xml")) if (!virStringHasSuffix(entry->d_name, ".xml"))
continue; continue;
if (!(path = virFileBuildPath(configDir, entry->d_name, NULL))) if (!(path = virFileBuildPath(configDir, entry->d_name, NULL)))
......
...@@ -1600,7 +1600,7 @@ virVMXParseConfig(virVMXContext *ctx, ...@@ -1600,7 +1600,7 @@ virVMXParseConfig(virVMXContext *ctx,
if (virVMXGetConfigString(conf, "guestOS", &guestOS, true) < 0) if (virVMXGetConfigString(conf, "guestOS", &guestOS, true) < 0)
goto cleanup; goto cleanup;
if (guestOS != NULL && virStringHasCaseSuffix(guestOS, "-64")) { if (guestOS != NULL && virStringHasSuffix(guestOS, "-64")) {
def->os.arch = VIR_ARCH_X86_64; def->os.arch = VIR_ARCH_X86_64;
} else { } else {
def->os.arch = VIR_ARCH_I686; def->os.arch = VIR_ARCH_I686;
......
...@@ -525,8 +525,8 @@ virTestRewrapFile(const char *filename) ...@@ -525,8 +525,8 @@ virTestRewrapFile(const char *filename)
char *script = NULL; char *script = NULL;
virCommandPtr cmd = NULL; virCommandPtr cmd = NULL;
if (!(virStringHasCaseSuffix(filename, ".args") || if (!(virStringHasSuffix(filename, ".args") ||
virStringHasCaseSuffix(filename, ".ldargs"))) virStringHasSuffix(filename, ".ldargs")))
return 0; return 0;
if (!perl) { if (!perl) {
......
...@@ -41,7 +41,7 @@ static int ...@@ -41,7 +41,7 @@ static int
testSchemaFile(const void *args) testSchemaFile(const void *args)
{ {
const struct testSchemaData *data = 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; xmlDocPtr xml = NULL;
int ret = -1; int ret = -1;
...@@ -82,7 +82,7 @@ testSchemaDir(const char *schema, ...@@ -82,7 +82,7 @@ testSchemaDir(const char *schema,
return -1; return -1;
while ((rc = virDirRead(dir, &ent, dir_path)) > 0) { while ((rc = virDirRead(dir, &ent, dir_path)) > 0) {
if (!virStringHasCaseSuffix(ent->d_name, ".xml")) if (!virStringHasSuffix(ent->d_name, ".xml"))
continue; continue;
if (ent->d_name[0] == '.') if (ent->d_name[0] == '.')
continue; continue;
......
...@@ -274,7 +274,7 @@ findLease(const char *name, ...@@ -274,7 +274,7 @@ findLease(const char *name,
while ((ret = virDirRead(dir, &entry, leaseDir)) > 0) { while ((ret = virDirRead(dir, &entry, leaseDir)) > 0) {
char *path; char *path;
if (virStringHasCaseSuffix(entry->d_name, ".status")) { if (virStringHasSuffix(entry->d_name, ".status")) {
if (!(path = virFileBuildPath(leaseDir, entry->d_name, NULL))) if (!(path = virFileBuildPath(leaseDir, entry->d_name, NULL)))
goto cleanup; goto cleanup;
...@@ -285,7 +285,7 @@ findLease(const char *name, ...@@ -285,7 +285,7 @@ findLease(const char *name,
goto cleanup; goto cleanup;
} }
VIR_FREE(path); 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))) if (!(path = virFileBuildPath(leaseDir, entry->d_name, NULL)))
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册