From: Oliver Kurth Date: Mon, 26 Feb 2018 20:29:06 +0000 (-0800) Subject: Skip davfs mount points during quiescing (part 2) X-Git-Tag: stable-10.3.0~110 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aefcbec68487e14de8938fafbf0606a9ce37b2b9;p=thirdparty%2Fopen-vm-tools.git Skip davfs mount points during quiescing (part 2) 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. --- diff --git a/open-vm-tools/lib/syncDriver/syncDriverPosix.c b/open-vm-tools/lib/syncDriver/syncDriverPosix.c index 06a4d833f..f66ca8026 100644 --- a/open-vm-tools/lib/syncDriver/syncDriverPosix.c +++ b/open-vm-tools/lib/syncDriver/syncDriverPosix.c @@ -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; } }