]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Rename virFileMatchesNameSuffix() to virStringMatchesNameSuffix()
authorAndrea Bolognani <abologna@redhat.com>
Wed, 6 Mar 2019 14:45:15 +0000 (15:45 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Thu, 7 Mar 2019 09:10:45 +0000 (10:10 +0100)
Despite its name, this is really just a general-purpose string
manipulation function, so it should be moved to the virstring
module and renamed accordingly.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
src/conf/virsecretobj.c
src/conf/virstorageobj.c
src/libvirt_private.syms
src/util/virfile.c
src/util/virfile.h
src/util/virstring.c
src/util/virstring.h

index 5cd36b8a40ffd6b29db66b17cdb8b067d98446cb..b01dc7cc70a58186287d6ed610d37114ff5a19f0 100644 (file)
@@ -819,7 +819,7 @@ virSecretLoadValidateUUID(virSecretDefPtr def,
 
     virUUIDFormat(def->uuid, uuidstr);
 
-    if (!virFileMatchesNameSuffix(file, uuidstr, ".xml")) {
+    if (!virStringMatchesNameSuffix(file, uuidstr, ".xml")) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("<uuid> does not match secret file name '%s'"),
                        file);
index 85b6dd3695ddd88291aea9dd3f9a5ed14bacb647..a30d86d070861f753d00bf67c3bf0f0344112b2f 100644 (file)
@@ -1585,7 +1585,7 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools,
     if (!(def = virStoragePoolDefParseFile(path)))
         return NULL;
 
-    if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
+    if (!virStringMatchesNameSuffix(file, def->name, ".xml")) {
         virReportError(VIR_ERR_XML_ERROR,
                        _("Storage pool config filename '%s' does "
                          "not match pool name '%s'"),
index e057ed0f2cc35a87ef50ed7118dee17867050e5c..b20100b30b273d4b9566bd5e89a11e3b5925e98d 100644 (file)
@@ -1859,7 +1859,6 @@ virFileLoopDeviceAssociate;
 virFileMakeParentPath;
 virFileMakePath;
 virFileMakePathWithMode;
-virFileMatchesNameSuffix;
 virFileMoveMount;
 virFileNBDDeviceAssociate;
 virFileOpenAs;
@@ -2980,6 +2979,7 @@ virStringListLength;
 virStringListMerge;
 virStringListRemove;
 virStringMatch;
+virStringMatchesNameSuffix;
 virStringParsePort;
 virStringReplace;
 virStringSearch;
index c0f3f562937ba0ba78d1b8d436dc0b971c816523..a4c6d184af9f06ea248aff99dbf2ecb81f0f3d91 100644 (file)
@@ -1508,23 +1508,6 @@ virFileWriteStr(const char *path, const char *str, mode_t mode)
     return 0;
 }
 
-int
-virFileMatchesNameSuffix(const char *file,
-                         const char *name,
-                         const char *suffix)
-{
-    int filelen = strlen(file);
-    int namelen = strlen(name);
-    int suffixlen = strlen(suffix);
-
-    if (filelen == (namelen + suffixlen) &&
-        STREQLEN(file, name, namelen) &&
-        STREQLEN(file + namelen, suffix, suffixlen))
-        return 1;
-    else
-        return 0;
-}
-
 #define SAME_INODE(Stat_buf_1, Stat_buf_2) \
   ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
    && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
index 0079e234f8c19f538e4fe435c3b198297cff9588..3dedb7666a3d6a18e37afb22e9cb4e850ff2a395 100644 (file)
@@ -162,10 +162,6 @@ int virFileReadBufQuiet(const char *file, char *buf, int len)
 int virFileWriteStr(const char *path, const char *str, mode_t mode)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
 
-int virFileMatchesNameSuffix(const char *file,
-                             const char *name,
-                             const char *suffix);
-
 int virFileLinkPointsTo(const char *checkLink,
                         const char *checkDest)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
index 60b4167af4a9e4c811feeef95d99d8120d4e0185..b4d10f9884fbe147b81fe9657a896ffd09e81f5f 100644 (file)
@@ -1266,6 +1266,23 @@ virStringStripSuffix(char *str,
     return 1;
 }
 
+int
+virStringMatchesNameSuffix(const char *file,
+                           const char *name,
+                           const char *suffix)
+{
+    int filelen = strlen(file);
+    int namelen = strlen(name);
+    int suffixlen = strlen(suffix);
+
+    if (filelen == (namelen + suffixlen) &&
+        STREQLEN(file, name, namelen) &&
+        STREQLEN(file + namelen, suffix, suffixlen))
+        return 1;
+    else
+        return 0;
+}
+
 /**
  * virStringStripIPv6Brackets:
  * @str: the string to strip
index 580e4da9b9224f4463be74919a5e633e56994f3a..69030566e9f9abb6ab26966bcdd9f48f1e9d0166 100644 (file)
@@ -292,6 +292,9 @@ int virStringHasCaseSuffix(const char *str,
                            const char *suffix);
 int virStringStripSuffix(char *str,
                          const char *suffix) ATTRIBUTE_RETURN_CHECK;
+int virStringMatchesNameSuffix(const char *file,
+                               const char *name,
+                               const char *suffix);
 
 void virStringStripIPv6Brackets(char *str);
 bool virStringHasChars(const char *str,