]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Use virStringHasSuffix() where possible
authorAndrea Bolognani <abologna@redhat.com>
Thu, 7 Mar 2019 08:40:54 +0000 (09:40 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Thu, 7 Mar 2019 09:10:49 +0000 (10:10 +0100)
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>
src/conf/virsecretobj.c
src/conf/virstorageobj.c
src/vmx/vmx.c
tests/testutils.c
tests/virschematest.c
tools/nss/libvirt_nss.c

index b01dc7cc70a58186287d6ed610d37114ff5a19f0..7800912bffcfc3da05843e66a184c3711c486e02 100644 (file)
@@ -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)))
index a30d86d070861f753d00bf67c3bf0f0344112b2f..1d6c9d1937002ede9044f313a8988a8ff8ec8a32 100644 (file)
@@ -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)))
index bbf8e55c3fa5ae09d52608c0c380614ba4dcf755..8ffd5ff08813895e85e6376c2d0017346df18504 100644 (file)
@@ -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;
index cfdf122ae00b50c00917b26cec6dff9e5dec3e35..d2aa4e5d490c612724e14ff7b510cf708a7c6fb0 100644 (file)
@@ -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) {
index 5ef61e3056c6acb049fab8072c42f4cb3c65e484..8dfab5e2a3351fd10c56bd8a1eab7df71226fcc1 100644 (file)
@@ -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;
index 4d86f8e6ce86665da3bbdd33e9f8883841b3055c..3ff1bada31eb1f207440cae82f6c59ccec93d4b1 100644 (file)
@@ -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;