]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Skip davfs mount points during quiescing (part 2)
authorOliver Kurth <okurth@vmware.com>
Mon, 26 Feb 2018 20:29:06 +0000 (12:29 -0800)
committerOliver Kurth <okurth@vmware.com>
Mon, 26 Feb 2018 20:29:06 +0000 (12:29 -0800)
Refactor the change to skip davfs mount points.  Capture the length
of the static URL prefixes at compile time and avoid repetitive
strlen() calls when checking each active mount point.

open-vm-tools/lib/syncDriver/syncDriverPosix.c

index 06a4d833f3c036a55cc757a0a0f8c6fbb0c0de17..f66ca8026c88e23c56693f60e87946d1450bd984 100644 (file)
@@ -50,11 +50,20 @@ static const char *gRemoteFSTypes[] = {
    "vmhgfs"
 };
 
-static const char *gRemoteDevPrefixes[] = {
-   "https://",
-   "http://"
+typedef struct {
+   const char *prefix;
+   size_t len;
+} RemoteDevPrefix;
+
+#define DEF_DEV_PREFIX(a) {(a), sizeof((a)) - 1}
+
+static RemoteDevPrefix gRemoteDevPrefixes[] = {
+   DEF_DEV_PREFIX("https://"),
+   DEF_DEV_PREFIX("http://")
 };
 
+#undef DEF_DEV_PREFIX
+
 
 /*
  *-----------------------------------------------------------------------------
@@ -85,8 +94,9 @@ SyncDriverIsRemoteFS(const MNTINFO *mntinfo)
    }
 
    for (i = 0; i < ARRAYSIZE(gRemoteDevPrefixes); i++) {
-      if (Str_Strncasecmp(gRemoteDevPrefixes[i], MNTINFO_NAME(mntinfo),
-                          strlen(gRemoteDevPrefixes[i])) == 0) {
+      if (Str_Strncasecmp(gRemoteDevPrefixes[i].prefix,
+                          MNTINFO_NAME(mntinfo),
+                          gRemoteDevPrefixes[i].len) == 0) {
          return TRUE;
       }
    }