Michael Stefaniuc : shlwapi: Avoid ARRAY_SIZE-like macros.

Alexandre Julliard julliard at winehq.org
Mon Sep 17 15:02:25 CDT 2018


Module: wine
Branch: master
Commit: 923cb0a9576f63aedf0ca1b995e36ea416ec9cf5
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=923cb0a9576f63aedf0ca1b995e36ea416ec9cf5

Author: Michael Stefaniuc <mstefani at winehq.org>
Date:   Sat Sep 15 00:10:30 2018 +0200

shlwapi: Avoid ARRAY_SIZE-like macros.

Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/shlwapi/path.c | 10 ++++------
 dlls/shlwapi/reg.c  |  7 +++----
 dlls/shlwapi/url.c  |  2 +-
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c
index ae05381..e24835f 100644
--- a/dlls/shlwapi/path.c
+++ b/dlls/shlwapi/path.c
@@ -4217,8 +4217,6 @@ HRESULT WINAPI SHGetWebFolderFilePathW(LPCWSTR lpszFile, LPWSTR lpszPath, DWORD
 {
   static const WCHAR szWeb[] = {'\\','W','e','b','\\','\0'};
   static const WCHAR szWebMui[] = {'m','u','i','\\','%','0','4','x','\\','\0'};
-#define szWebLen (sizeof(szWeb)/sizeof(WCHAR))
-#define szWebMuiLen ((sizeof(szWebMui)+1)/sizeof(WCHAR))
   DWORD dwLen, dwFileLen;
   LANGID lidSystem, lidUser;
 
@@ -4231,11 +4229,11 @@ HRESULT WINAPI SHGetWebFolderFilePathW(LPCWSTR lpszFile, LPWSTR lpszPath, DWORD
 
   dwFileLen = strlenW(lpszFile);
 
-  if (dwLen + dwFileLen + szWebLen >= dwPathLen)
+  if (dwLen + dwFileLen + ARRAY_SIZE(szWeb) >= dwPathLen)
     return E_FAIL; /* lpszPath too short */
 
   strcpyW(lpszPath+dwLen, szWeb);
-  dwLen += szWebLen;
+  dwLen += ARRAY_SIZE(szWeb);
   dwPathLen = dwPathLen - dwLen; /* Remaining space */
 
   lidSystem = GetSystemDefaultUILanguage();
@@ -4243,11 +4241,11 @@ HRESULT WINAPI SHGetWebFolderFilePathW(LPCWSTR lpszFile, LPWSTR lpszPath, DWORD
 
   if (lidSystem != lidUser)
   {
-    if (dwFileLen + szWebMuiLen < dwPathLen)
+    if (dwFileLen + ARRAY_SIZE(szWebMui) < dwPathLen)
     {
       /* Use localised content in the users UI language if present */
       wsprintfW(lpszPath + dwLen, szWebMui, lidUser);
-      strcpyW(lpszPath + dwLen + szWebMuiLen, lpszFile);
+      strcpyW(lpszPath + dwLen + ARRAY_SIZE(szWebMui), lpszFile);
       if (PathFileExistsW(lpszPath))
         return S_OK;
     }
diff --git a/dlls/shlwapi/reg.c b/dlls/shlwapi/reg.c
index a72f4c2..375c254 100644
--- a/dlls/shlwapi/reg.c
+++ b/dlls/shlwapi/reg.c
@@ -2426,19 +2426,18 @@ HRESULT WINAPI SHRegGetCLSIDKeyW(REFGUID guid, LPCWSTR lpszValue, BOOL bUseHKCU,
     'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
     'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
     'E','x','p','l','o','r','e','r','\\','C','L','S','I','D','\\' };
-#define szClassIdKeyLen (sizeof(szClassIdKey)/sizeof(WCHAR))
   WCHAR szKey[MAX_PATH];
   DWORD dwRet;
   HKEY hkey;
 
   /* Create the key string */
   memcpy(szKey, szClassIdKey, sizeof(szClassIdKey));
-  SHStringFromGUIDW(guid, szKey + szClassIdKeyLen, 39); /* Append guid */
+  SHStringFromGUIDW(guid, szKey + ARRAY_SIZE(szClassIdKey), 39); /* Append guid */
 
   if(lpszValue)
   {
-    szKey[szClassIdKeyLen + 39] = '\\';
-    strcpyW(szKey + szClassIdKeyLen + 40, lpszValue); /* Append value name */
+    szKey[ARRAY_SIZE(szClassIdKey) + 39] = '\\';
+    strcpyW(szKey + ARRAY_SIZE(szClassIdKey) + 40, lpszValue); /* Append value name */
   }
 
   hkey = bUseHKCU ? HKEY_CURRENT_USER : HKEY_CLASSES_ROOT;
diff --git a/dlls/shlwapi/url.c b/dlls/shlwapi/url.c
index c7d717b..92b4a21 100644
--- a/dlls/shlwapi/url.c
+++ b/dlls/shlwapi/url.c
@@ -2570,7 +2570,7 @@ HRESULT WINAPI MLBuildResURLW(LPCWSTR lpszLibName, HMODULE hMod, DWORD dwFlags,
                               LPCWSTR lpszRes, LPWSTR lpszDest, DWORD dwDestLen)
 {
   static const WCHAR szRes[] = { 'r','e','s',':','/','/','\0' };
-#define szResLen ((sizeof(szRes) - sizeof(WCHAR))/sizeof(WCHAR))
+  static const unsigned int szResLen = ARRAY_SIZE(szRes) - 1;
   HRESULT hRet = E_FAIL;
 
   TRACE("(%s,%p,0x%08x,%s,%p,%d)\n", debugstr_w(lpszLibName), hMod, dwFlags,




More information about the wine-cvs mailing list