From 923cb0a9576f63aedf0ca1b995e36ea416ec9cf5 Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Sat, 15 Sep 2018 00:10:30 +0200 Subject: [PATCH] shlwapi: Avoid ARRAY_SIZE-like macros. Signed-off-by: Michael Stefaniuc Signed-off-by: Alexandre Julliard --- 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 ae05381b668..e24835f2384 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 a72f4c24e46..375c25429db 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 c7d717b2d7e..92b4a216cba 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,