Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
September 2018
- 70 participants
- 1549 messages
[PATCH v2] quartz/filtergraph: Return correct interface for IID_IGraphVersion.
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
v2: rebased on top of master
dlls/quartz/filtergraph.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c
index d6e8c90..20dd5fd 100644
--- a/dlls/quartz/filtergraph.c
+++ b/dlls/quartz/filtergraph.c
@@ -442,8 +442,8 @@ static HRESULT WINAPI FilterGraphInner_QueryInterface(IUnknown *iface, REFIID ri
TRACE(" returning IFilterMapper3 interface from aggregated filtermapper (%p)\n", *ppvObj);
return IUnknown_QueryInterface(This->punkFilterMapper2, riid, ppvObj);
} else if (IsEqualGUID(&IID_IGraphVersion, riid)) {
- *ppvObj = &This->IGraphConfig_iface;
- TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj);
+ *ppvObj = &This->IGraphVersion_iface;
+ TRACE(" returning IGraphVersion interface (%p)\n", *ppvObj);
} else {
*ppvObj = NULL;
FIXME("unknown interface %s\n", debugstr_guid(riid));
--
2.7.4
Sept. 14, 2018
Re: [PATCH] quartz/filtergraph: Return correct interface for IID_IGraphVersion.
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at:
https://testbot.winehq.org/JobDetails.pl?Key=42055
Your paranoid android.
=== debian9 (build log) ===
error: patch failed: dlls/quartz/filtergraph.c:442
Task: Patch failed to apply
Sept. 14, 2018
[PATCH] quartz/filtergraph: Return correct interface for IID_IGraphVersion.
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/quartz/filtergraph.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c
index 03fdd19..ac915f6 100644
--- a/dlls/quartz/filtergraph.c
+++ b/dlls/quartz/filtergraph.c
@@ -442,8 +442,8 @@ static HRESULT WINAPI FilterGraphInner_QueryInterface(IUnknown *iface, REFIID ri
TRACE(" returning IFilterMapper3 interface from aggregated filtermapper (%p)\n", *ppvObj);
return IUnknown_QueryInterface(This->punkFilterMapper2, riid, ppvObj);
} else if (IsEqualGUID(&IID_IGraphVersion, riid)) {
- *ppvObj = &This->IGraphConfig_iface;
- TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj);
+ *ppvObj = &This->IGraphVersion_iface;
+ TRACE(" returning IGraphVersion interface (%p)\n", *ppvObj);
} else if (IsEqualGUID(&IID_IVideoFrameStep, riid)) {
*ppvObj = &This->IVideoFrameStep_iface;
TRACE(" returning IVideoFrameStep interface (%p)\n", *ppvObj);
--
2.7.4
Sept. 14, 2018
[PATCH] shlwapi: Use the ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/shlwapi/assoc.c | 2 +-
dlls/shlwapi/ordinal.c | 18 +++++++++---------
dlls/shlwapi/path.c | 18 +++++++++---------
dlls/shlwapi/reg.c | 10 +++++-----
dlls/shlwapi/string.c | 14 ++++++--------
dlls/shlwapi/url.c | 29 ++++++++++++++---------------
6 files changed, 44 insertions(+), 47 deletions(-)
diff --git a/dlls/shlwapi/assoc.c b/dlls/shlwapi/assoc.c
index 31569908b3..5faeab64fb 100644
--- a/dlls/shlwapi/assoc.c
+++ b/dlls/shlwapi/assoc.c
@@ -276,7 +276,7 @@ HRESULT WINAPI AssocQueryStringA(ASSOCF cfFlags, ASSOCSTR str, LPCSTR pszAssoc,
lpszReturnW = HeapAlloc(GetProcessHeap(), 0,
(dwLenOut + 1) * sizeof(WCHAR));
else
- dwLenOut = sizeof(szReturnW) / sizeof(szReturnW[0]);
+ dwLenOut = ARRAY_SIZE(szReturnW);
if (!lpszReturnW)
hRet = E_OUTOFMEMORY;
diff --git a/dlls/shlwapi/ordinal.c b/dlls/shlwapi/ordinal.c
index 903df91aa0..449b47b2f7 100644
--- a/dlls/shlwapi/ordinal.c
+++ b/dlls/shlwapi/ordinal.c
@@ -2440,7 +2440,7 @@ HMODULE WINAPI SHPinDllOfCLSID(REFIID refiid)
CHAR value[MAX_PATH], string[MAX_PATH];
strcpy(string, "CLSID\\");
- SHStringFromGUIDA(refiid, string + 6, sizeof(string)/sizeof(char) - 6);
+ SHStringFromGUIDA(refiid, string + 6, ARRAY_SIZE(string) - 6);
strcat(string, "\\InProcServer32");
count = MAX_PATH;
@@ -2778,7 +2778,7 @@ VOID WINAPI SHWeakReleaseInterface(IUnknown *lpDest, IUnknown **lppUnknown)
BOOL WINAPI GUIDFromStringA(LPCSTR idstr, CLSID *id)
{
WCHAR wClsid[40];
- MultiByteToWideChar(CP_ACP, 0, idstr, -1, wClsid, sizeof(wClsid)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, idstr, -1, wClsid, ARRAY_SIZE(wClsid));
return SUCCEEDED(CLSIDFromString(wClsid, id));
}
@@ -3600,8 +3600,8 @@ HMODULE WINAPI MLLoadLibraryW(LPCWSTR new_mod, HMODULE inst_hwnd, DWORD dwCrossC
DWORD len;
FIXME("(%s,%p,%d) semi-stub!\n", debugstr_w(new_mod), inst_hwnd, dwCrossCodePage);
- len = GetModuleFileNameW(inst_hwnd, mod_path, sizeof(mod_path) / sizeof(WCHAR));
- if (!len || len >= sizeof(mod_path) / sizeof(WCHAR)) return NULL;
+ len = GetModuleFileNameW(inst_hwnd, mod_path, ARRAY_SIZE(mod_path));
+ if (!len || len >= ARRAY_SIZE(mod_path)) return NULL;
ptr = strrchrW(mod_path, '\\');
if (ptr) {
@@ -4755,7 +4755,7 @@ INT WINAPIV ShellMessageBoxWrapW(HINSTANCE hInstance, HWND hWnd, LPCWSTR lpText,
TRACE("(%p,%p,%p,%p,%08x)\n", hInstance, hWnd, lpText, lpCaption, uType);
if (IS_INTRESOURCE(lpCaption))
- LoadStringW(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle)/sizeof(szTitle[0]));
+ LoadStringW(hInstance, LOWORD(lpCaption), szTitle, ARRAY_SIZE(szTitle));
else
pszTitle = lpCaption;
@@ -5280,8 +5280,8 @@ DWORD WINAPI SHGetObjectCompatFlags(IUnknown *pUnk, const CLSID *clsid)
'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'S','h','e','l','l','C','o','m','p','a','t','i','b','i','l','i','t','y','\\',
'O','b','j','e','c','t','s','\\','%','s',0};
- WCHAR strW[sizeof(compatpathW)/sizeof(WCHAR) + 38 /* { CLSID } */];
- DWORD ret, length = sizeof(strW)/sizeof(WCHAR);
+ WCHAR strW[ARRAY_SIZE(compatpathW) + 38 /* { CLSID } */];
+ DWORD ret, length = ARRAY_SIZE(strW);
OLECHAR *clsid_str;
HKEY key;
INT i;
@@ -5311,7 +5311,7 @@ DWORD WINAPI SHGetObjectCompatFlags(IUnknown *pUnk, const CLSID *clsid)
/* search in table */
left = 0;
- right = sizeof(objcompat_table) / sizeof(struct objcompat_entry) - 1;
+ right = ARRAY_SIZE(objcompat_table) - 1;
while (right >= left) {
x = (left + right) / 2;
@@ -5327,7 +5327,7 @@ DWORD WINAPI SHGetObjectCompatFlags(IUnknown *pUnk, const CLSID *clsid)
left = x + 1;
}
- length = sizeof(strW)/sizeof(WCHAR);
+ length = ARRAY_SIZE(strW);
}
return ret;
diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c
index e24835f238..ad78c5d224 100644
--- a/dlls/shlwapi/path.c
+++ b/dlls/shlwapi/path.c
@@ -3264,7 +3264,7 @@ HRESULT WINAPI PathCreateFromUrlA(LPCSTR pszUrl, LPSTR pszPath,
WCHAR *pathW = bufW;
UNICODE_STRING urlW;
HRESULT ret;
- DWORD lenW = sizeof(bufW)/sizeof(WCHAR), lenA;
+ DWORD lenW = ARRAY_SIZE(bufW), lenA;
if (!pszUrl || !pszPath || !pcchPath || !*pcchPath)
return E_INVALIDARG;
@@ -3684,7 +3684,7 @@ VOID WINAPI PathSetDlgItemPathW(HWND hDlg, int id, LPCWSTR lpszPath)
return;
if (lpszPath)
- lstrcpynW(path, lpszPath, sizeof(path) / sizeof(WCHAR));
+ lstrcpynW(path, lpszPath, ARRAY_SIZE(path));
else
path[0] = '\0';
@@ -4122,7 +4122,7 @@ static void init_envvars_map(struct envvars_map *map)
{
while (map->var)
{
- map->len = ExpandEnvironmentStringsW(map->var, map->path, sizeof(map->path)/sizeof(WCHAR));
+ map->len = ExpandEnvironmentStringsW(map->var, map->path, ARRAY_SIZE(map->path));
/* exclude null from length */
if (map->len) map->len--;
map++;
@@ -4139,12 +4139,12 @@ BOOL WINAPI PathUnExpandEnvStringsW(LPCWSTR path, LPWSTR buffer, UINT buf_len)
static struct envvars_map null_var = {NULL, 0, {0}, 0};
struct envvars_map *match = &null_var, *cur;
struct envvars_map envvars[] = {
- { allusersprofileW, sizeof(allusersprofileW)/sizeof(WCHAR) },
- { appdataW, sizeof(appdataW)/sizeof(WCHAR) },
- { programfilesW, sizeof(programfilesW)/sizeof(WCHAR) },
- { systemrootW, sizeof(systemrootW)/sizeof(WCHAR) },
- { systemdriveW, sizeof(systemdriveW)/sizeof(WCHAR) },
- { userprofileW, sizeof(userprofileW)/sizeof(WCHAR) },
+ { allusersprofileW, ARRAY_SIZE(allusersprofileW) },
+ { appdataW, ARRAY_SIZE(appdataW) },
+ { programfilesW, ARRAY_SIZE(programfilesW) },
+ { systemrootW, ARRAY_SIZE(systemrootW) },
+ { systemdriveW, ARRAY_SIZE(systemdriveW) },
+ { userprofileW, ARRAY_SIZE(userprofileW) },
{ NULL }
};
DWORD pathlen;
diff --git a/dlls/shlwapi/reg.c b/dlls/shlwapi/reg.c
index 375c25429d..163351995c 100644
--- a/dlls/shlwapi/reg.c
+++ b/dlls/shlwapi/reg.c
@@ -134,7 +134,7 @@ LONG WINAPI SHRegOpenUSKeyW(LPCWSTR Path, REGSAM AccessType, HUSKEY hRelativeUSK
/* Create internal HUSKEY */
hKey = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*hKey));
- lstrcpynW(hKey->lpszPath, Path, sizeof(hKey->lpszPath)/sizeof(WCHAR));
+ lstrcpynW(hKey->lpszPath, Path, ARRAY_SIZE(hKey->lpszPath));
if (hRelativeUSKey)
{
@@ -275,7 +275,7 @@ LONG WINAPI SHRegCreateUSKeyW(LPCWSTR path, REGSAM samDesired, HUSKEY relative_k
}
ret_key = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret_key));
- lstrcpynW(ret_key->lpszPath, path, sizeof(ret_key->lpszPath)/sizeof(WCHAR));
+ lstrcpynW(ret_key->lpszPath, path, ARRAY_SIZE(ret_key->lpszPath));
if (relative_key)
{
@@ -1534,7 +1534,7 @@ DWORD WINAPI SHDeleteKeyA(HKEY hKey, LPCSTR lpszSubKey)
{
WCHAR subkeyW[MAX_PATH];
- MultiByteToWideChar (CP_ACP, 0, lpszSubKey, -1, subkeyW, sizeof(subkeyW)/sizeof(WCHAR));
+ MultiByteToWideChar (CP_ACP, 0, lpszSubKey, -1, subkeyW, ARRAY_SIZE(subkeyW));
return SHDeleteKeyW(hKey, subkeyW);
}
@@ -1560,7 +1560,7 @@ DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
if(!dwRet)
{
dwMaxSubkeyLen++;
- if (dwMaxSubkeyLen > sizeof(szNameBuf)/sizeof(WCHAR))
+ if (dwMaxSubkeyLen > ARRAY_SIZE(szNameBuf))
/* Name too big: alloc a buffer for it */
lpszName = HeapAlloc(GetProcessHeap(), 0, dwMaxSubkeyLen*sizeof(WCHAR));
@@ -2409,7 +2409,7 @@ HRESULT WINAPI SHRegGetCLSIDKeyA(REFGUID guid, LPCSTR lpszValue, BOOL bUseHKCU,
WCHAR szValue[MAX_PATH];
if (lpszValue)
- MultiByteToWideChar(CP_ACP, 0, lpszValue, -1, szValue, sizeof(szValue)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, lpszValue, -1, szValue, ARRAY_SIZE(szValue));
return SHRegGetCLSIDKeyW(guid, lpszValue ? szValue : NULL, bUseHKCU, bCreate, phKey);
}
diff --git a/dlls/shlwapi/string.c b/dlls/shlwapi/string.c
index 0b34d43624..b190ffc9e4 100644
--- a/dlls/shlwapi/string.c
+++ b/dlls/shlwapi/string.c
@@ -71,7 +71,7 @@ static void FillNumberFmt(NUMBERFMTW *fmt, LPWSTR decimal_buffer, int decimal_bu
* http://blogs.msdn.com/oldnewthing/archive/2006/04/18/578251.aspx
*/
fmt->Grouping = 0;
- GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SGROUPING, grouping, sizeof(grouping)/sizeof(WCHAR));
+ GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SGROUPING, grouping, ARRAY_SIZE(grouping));
for (c = grouping; *c; c++)
if (*c >= '0' && *c < '9')
{
@@ -101,8 +101,7 @@ static int FormatInt(LONGLONG qdwValue, LPWSTR pszBuf, int cchBuf)
WCHAR *c;
BOOL neg = (qdwValue < 0);
- FillNumberFmt(&fmt, decimal, sizeof decimal / sizeof (WCHAR),
- thousand, sizeof thousand / sizeof (WCHAR));
+ FillNumberFmt(&fmt, decimal, ARRAY_SIZE(decimal), thousand, ARRAY_SIZE(thousand));
c = &buf[24];
*(--c) = 0;
@@ -135,8 +134,7 @@ static int FormatDouble(double value, int decimals, LPWSTR pszBuf, int cchBuf)
snprintfW(buf, 64, flfmt, value);
- FillNumberFmt(&fmt, decimal, sizeof decimal / sizeof (WCHAR),
- thousand, sizeof thousand / sizeof (WCHAR));
+ FillNumberFmt(&fmt, decimal, ARRAY_SIZE(decimal), thousand, ARRAY_SIZE(thousand));
fmt.NumDigits = decimals;
return GetNumberFormatW(LOCALE_USER_DEFAULT, 0, buf, &fmt, pszBuf, cchBuf);
}
@@ -2124,7 +2122,7 @@ INT WINAPI StrFromTimeIntervalA(LPSTR lpszStr, UINT cchMax, DWORD dwMS,
if (lpszStr && cchMax)
{
WCHAR szBuff[128];
- StrFromTimeIntervalW(szBuff, sizeof(szBuff)/sizeof(WCHAR), dwMS, iDigits);
+ StrFromTimeIntervalW(szBuff, ARRAY_SIZE(szBuff), dwMS, iDigits);
WideCharToMultiByte(CP_ACP,0,szBuff,-1,lpszStr,cchMax,0,0);
}
return iRet;
@@ -2420,7 +2418,7 @@ LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
/* Note that if this loop completes without finding a match, i will be
* pointing at the last entry, which is a catch all for > 1000 PB
*/
- while (i < sizeof(bfFormats) / sizeof(SHLWAPI_BYTEFORMATS) - 1)
+ while (i < ARRAY_SIZE(bfFormats) - 1)
{
if (llBytes < bfFormats[i].dLimit)
break;
@@ -2455,7 +2453,7 @@ LPSTR WINAPI StrFormatByteSize64A(LONGLONG llBytes, LPSTR lpszDest, UINT cchMax)
{
WCHAR wszBuff[32];
- StrFormatByteSizeW(llBytes, wszBuff, sizeof(wszBuff)/sizeof(WCHAR));
+ StrFormatByteSizeW(llBytes, wszBuff, ARRAY_SIZE(wszBuff));
if (lpszDest)
WideCharToMultiByte(CP_ACP, 0, wszBuff, -1, lpszDest, cchMax, 0, 0);
diff --git a/dlls/shlwapi/url.c b/dlls/shlwapi/url.c
index 92b4a216cb..8313b98fb2 100644
--- a/dlls/shlwapi/url.c
+++ b/dlls/shlwapi/url.c
@@ -136,7 +136,7 @@ static DWORD get_scheme_code(LPCWSTR scheme, DWORD scheme_len)
{
unsigned int i;
- for(i=0; i < sizeof(shlwapi_schemes)/sizeof(shlwapi_schemes[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(shlwapi_schemes); i++) {
if(scheme_len == strlenW(shlwapi_schemes[i].scheme_name)
&& !memicmpW(scheme, shlwapi_schemes[i].scheme_name, scheme_len))
return shlwapi_schemes[i].scheme_number;
@@ -182,8 +182,7 @@ HRESULT WINAPI ParseURLA(LPCSTR x, PARSEDURLA *y)
y->pszSuffix = ptr+1;
y->cchSuffix = strlen(y->pszSuffix);
- len = MultiByteToWideChar(CP_ACP, 0, x, ptr-x,
- scheme, sizeof(scheme)/sizeof(WCHAR));
+ len = MultiByteToWideChar(CP_ACP, 0, x, ptr-x, scheme, ARRAY_SIZE(scheme));
y->nScheme = get_scheme_code(scheme, len);
return S_OK;
@@ -331,7 +330,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
return E_OUTOFMEMORY;
}
- is_file_url = !strncmpW(wszFile, url, sizeof(wszFile)/sizeof(WCHAR));
+ is_file_url = !strncmpW(wszFile, url, ARRAY_SIZE(wszFile));
if ((nByteLen >= sizeof(wszHttp) &&
!memcmp(wszHttp, url, sizeof(wszHttp))) || is_file_url)
@@ -362,7 +361,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
if(url[1] == ':') { /* Assume path */
memcpy(wk2, wszFilePrefix, sizeof(wszFilePrefix));
- wk2 += sizeof(wszFilePrefix)/sizeof(WCHAR);
+ wk2 += ARRAY_SIZE(wszFilePrefix);
if (dwFlags & (URL_FILE_USE_PATHURL | URL_WININET_COMPATIBILITY))
{
slash = '\\';
@@ -397,7 +396,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
if((dwFlags & URL_FILE_USE_PATHURL) && nByteLen >= sizeof(wszLocalhost)
&& is_file_url
&& !memcmp(wszLocalhost, wk1, sizeof(wszLocalhost))){
- wk1 += sizeof(wszLocalhost)/sizeof(WCHAR);
+ wk1 += ARRAY_SIZE(wszLocalhost);
while(*wk1 == '\\' && (dwFlags & URL_FILE_USE_PATHURL))
wk1++;
}
@@ -954,7 +953,7 @@ HRESULT WINAPI UrlEscapeA(
WCHAR *escapedW = bufW;
UNICODE_STRING urlW;
HRESULT ret;
- DWORD lenW = sizeof(bufW)/sizeof(WCHAR), lenA;
+ DWORD lenW = ARRAY_SIZE(bufW), lenA;
if (!pszEscaped || !pcchEscaped || !*pcchEscaped)
return E_INVALIDARG;
@@ -1162,7 +1161,7 @@ HRESULT WINAPI UrlEscapeW(
len = 0;
if((int_flags & WINE_URL_COLLAPSE_SLASHES) && src == pszUrl + parsed_url.cchProtocol + 1) {
- int localhost_len = sizeof(localhost)/sizeof(WCHAR) - 1;
+ int localhost_len = ARRAY_SIZE(localhost) - 1;
while(cur == '/' || cur == '\\') {
slashes++;
cur = *++src;
@@ -2442,7 +2441,7 @@ HRESULT WINAPI UrlCreateFromPathA(LPCSTR pszPath, LPSTR pszUrl, LPDWORD pcchUrl,
WCHAR *urlW = bufW;
UNICODE_STRING pathW;
HRESULT ret;
- DWORD lenW = sizeof(bufW)/sizeof(WCHAR), lenA;
+ DWORD lenW = ARRAY_SIZE(bufW), lenA;
if(!RtlCreateUnicodeStringFromAsciiz(&pathW, pszPath))
return E_INVALIDARG;
@@ -2545,13 +2544,13 @@ HRESULT WINAPI MLBuildResURLA(LPCSTR lpszLibName, HMODULE hMod, DWORD dwFlags,
HRESULT hRet;
if (lpszLibName)
- MultiByteToWideChar(CP_ACP, 0, lpszLibName, -1, szLibName, sizeof(szLibName)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, lpszLibName, -1, szLibName, ARRAY_SIZE(szLibName));
if (lpszRes)
- MultiByteToWideChar(CP_ACP, 0, lpszRes, -1, szRes, sizeof(szRes)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, lpszRes, -1, szRes, ARRAY_SIZE(szRes));
- if (dwDestLen > sizeof(szLibName)/sizeof(WCHAR))
- dwDestLen = sizeof(szLibName)/sizeof(WCHAR);
+ if (dwDestLen > ARRAY_SIZE(szLibName))
+ dwDestLen = ARRAY_SIZE(szLibName);
hRet = MLBuildResURLW(lpszLibName ? szLibName : NULL, hMod, dwFlags,
lpszRes ? szRes : NULL, lpszDest ? szDest : NULL, dwDestLen);
@@ -2592,8 +2591,8 @@ HRESULT WINAPI MLBuildResURLW(LPCWSTR lpszLibName, HMODULE hMod, DWORD dwFlags,
WCHAR szBuff[MAX_PATH];
DWORD len;
- len = GetModuleFileNameW(hMod, szBuff, sizeof(szBuff)/sizeof(WCHAR));
- if (len && len < sizeof(szBuff)/sizeof(WCHAR))
+ len = GetModuleFileNameW(hMod, szBuff, ARRAY_SIZE(szBuff));
+ if (len && len < ARRAY_SIZE(szBuff))
{
DWORD dwPathLen = strlenW(szBuff) + 1;
--
2.14.4
Sept. 14, 2018
[PATCH] shlwapi: Avoid ARRAY_SIZE-like macros
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)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 ae05381b66..e24835f238 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 a72f4c24e4..375c25429d 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 c7d717b2d7..92b4a216cb 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,
--
2.14.4
Sept. 14, 2018
[PATCH] shlwapi: Avoid a temporary variable
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/shlwapi/thread.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/shlwapi/thread.c b/dlls/shlwapi/thread.c
index eb2c35d6dc..5726b855dc 100644
--- a/dlls/shlwapi/thread.c
+++ b/dlls/shlwapi/thread.c
@@ -491,7 +491,6 @@ HANDLE WINAPI SHGlobalCounterCreateNamedW(LPCWSTR lpszName, DWORD iInitial)
static const WCHAR szPrefix[] = { 's', 'h', 'e', 'l', 'l', '.', '\0' };
const int iPrefixLen = 6;
WCHAR szBuff[MAX_PATH];
- const int iBuffLen = sizeof(szBuff)/sizeof(WCHAR);
SECURITY_DESCRIPTOR sd;
SECURITY_ATTRIBUTES sAttr, *pSecAttr;
HANDLE hRet;
@@ -501,7 +500,7 @@ HANDLE WINAPI SHGlobalCounterCreateNamedW(LPCWSTR lpszName, DWORD iInitial)
/* Create Semaphore name */
memcpy(szBuff, szPrefix, (iPrefixLen + 1) * sizeof(WCHAR));
if (lpszName)
- StrCpyNW(szBuff + iPrefixLen, lpszName, iBuffLen - iPrefixLen);
+ StrCpyNW(szBuff + iPrefixLen, lpszName, ARRAY_SIZE(szBuff) - iPrefixLen);
/* Initialise security attributes */
pSecAttr = CreateAllAccessSecurityAttributes(&sAttr, &sd, 0);
--
2.14.4
Sept. 14, 2018
[PATCH] setupapi: Use the ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/setupapi/devinst.c | 23 ++++++++++-------------
dlls/setupapi/dialog.c | 15 +++++----------
dlls/setupapi/fakedll.c | 12 ++++++------
dlls/setupapi/install.c | 27 ++++++++++++---------------
dlls/setupapi/misc.c | 8 ++++----
dlls/setupapi/parser.c | 9 ++++-----
dlls/setupapi/query.c | 3 +--
dlls/setupapi/queue.c | 10 +++++-----
8 files changed, 47 insertions(+), 60 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c
index 71356e8021..7134a8b58c 100644
--- a/dlls/setupapi/devinst.c
+++ b/dlls/setupapi/devinst.c
@@ -901,7 +901,7 @@ BOOL WINAPI SetupDiClassGuidsFromNameExW(
for (dwIndex = 0; ; dwIndex++)
{
- dwLength = sizeof(szKeyName) / sizeof(WCHAR);
+ dwLength = ARRAY_SIZE(szKeyName);
lError = RegEnumKeyExW(hClassesKey,
dwIndex,
szKeyName,
@@ -1995,7 +1995,7 @@ static void SETUPDI_AddDeviceInterfaces(struct device *device, HKEY key,
for (i = 0; !l; i++)
{
- len = sizeof(subKeyName) / sizeof(subKeyName[0]);
+ len = ARRAY_SIZE(subKeyName);
l = RegEnumKeyExW(key, i, subKeyName, &len, NULL, NULL, NULL, NULL);
if (!l)
{
@@ -2046,7 +2046,7 @@ static void SETUPDI_EnumerateMatchingInterfaces(HDEVINFO DeviceInfoSet,
&enumKey, NULL);
for (i = 0; !l; i++)
{
- len = sizeof(subKeyName) / sizeof(subKeyName[0]);
+ len = ARRAY_SIZE(subKeyName);
l = RegEnumKeyExW(key, i, subKeyName, &len, NULL, NULL, NULL, NULL);
if (!l)
{
@@ -2124,7 +2124,7 @@ static void SETUPDI_EnumerateInterfaces(HDEVINFO DeviceInfoSet,
for (i = 0; !l; i++)
{
- len = sizeof(interfaceGuidStr) / sizeof(interfaceGuidStr[0]);
+ len = ARRAY_SIZE(interfaceGuidStr);
l = RegEnumKeyExW(interfacesKey, i, interfaceGuidStr, &len,
NULL, NULL, NULL, NULL);
if (!l)
@@ -2175,7 +2175,7 @@ static void SETUPDI_EnumerateMatchingDeviceInstances(struct DeviceInfoSet *set,
for (i = 0; !l; i++)
{
- len = sizeof(deviceInstance) / sizeof(deviceInstance[0]);
+ len = ARRAY_SIZE(deviceInstance);
l = RegEnumKeyExW(deviceKey, i, deviceInstance, &len, NULL, NULL, NULL,
NULL);
if (!l)
@@ -2240,7 +2240,7 @@ static void SETUPDI_EnumerateMatchingDevices(HDEVINFO DeviceInfoSet,
for (i = 0; !l; i++)
{
- len = sizeof(subKeyName) / sizeof(subKeyName[0]);
+ len = ARRAY_SIZE(subKeyName);
l = RegEnumKeyExW(key, i, subKeyName, &len, NULL, NULL, NULL, NULL);
if (!l)
{
@@ -2294,7 +2294,7 @@ static void SETUPDI_EnumerateDevices(HDEVINFO DeviceInfoSet, const GUID *class,
l = ERROR_SUCCESS;
for (i = 0; !l; i++)
{
- len = sizeof(subKeyName) / sizeof(subKeyName[0]);
+ len = ARRAY_SIZE(subKeyName);
l = RegEnumKeyExW(enumKey, i, subKeyName, &len, NULL,
NULL, NULL, NULL);
if (!l)
@@ -2999,8 +2999,7 @@ BOOL WINAPI SetupDiGetDeviceRegistryPropertyA(
return FALSE;
}
device = (struct device *)DeviceInfoData->Reserved;
- if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
- && PropertyMap[Property].nameA)
+ if (Property < ARRAY_SIZE(PropertyMap) && PropertyMap[Property].nameA)
{
DWORD size = PropertyBufferSize;
LONG l = RegQueryValueExA(device->key, PropertyMap[Property].nameA,
@@ -3062,8 +3061,7 @@ BOOL WINAPI SetupDiGetDeviceRegistryPropertyW(
return FALSE;
}
device = (struct device *)DeviceInfoData->Reserved;
- if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
- && PropertyMap[Property].nameW)
+ if (Property < ARRAY_SIZE(PropertyMap) && PropertyMap[Property].nameW)
{
DWORD size = PropertyBufferSize;
LONG l = RegQueryValueExW(device->key, PropertyMap[Property].nameW,
@@ -3117,8 +3115,7 @@ BOOL WINAPI SetupDiSetDeviceRegistryPropertyA(
return FALSE;
}
device = (struct device *)DeviceInfoData->Reserved;
- if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
- && PropertyMap[Property].nameA)
+ if (Property < ARRAY_SIZE(PropertyMap) && PropertyMap[Property].nameA)
{
LONG l = RegSetValueExA(device->key, PropertyMap[Property].nameA, 0,
PropertyMap[Property].regType, PropertyBuffer,
diff --git a/dlls/setupapi/dialog.c b/dlls/setupapi/dialog.c
index 24a46e8535..fc74cfc172 100644
--- a/dlls/setupapi/dialog.c
+++ b/dlls/setupapi/dialog.c
@@ -64,28 +64,23 @@ static void promptdisk_init(HWND hwnd, struct promptdisk_params *params)
WCHAR format[256];
WCHAR unknown[256];
DWORD_PTR args[2];
- LoadStringW(SETUPAPI_hInstance, IDS_PROMPTDISK, format,
- sizeof(format)/sizeof(format[0]));
+ LoadStringW(SETUPAPI_hInstance, IDS_PROMPTDISK, format, ARRAY_SIZE(format));
args[0] = (DWORD_PTR)params->FileSought;
if(params->DiskName)
args[1] = (DWORD_PTR)params->DiskName;
else
{
- LoadStringW(SETUPAPI_hInstance, IDS_UNKNOWN, unknown,
- sizeof(unknown)/sizeof(unknown[0]));
+ LoadStringW(SETUPAPI_hInstance, IDS_UNKNOWN, unknown, ARRAY_SIZE(unknown));
args[1] = (DWORD_PTR)unknown;
}
FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
- format, 0, 0, message, sizeof(message)/sizeof(*message),
- (__ms_va_list*)args);
+ format, 0, 0, message, ARRAY_SIZE(message), (__ms_va_list*)args);
SetDlgItemTextW(hwnd, IDC_FILENEEDED, message);
- LoadStringW(SETUPAPI_hInstance, IDS_INFO, message,
- sizeof(message)/sizeof(message[0]));
+ LoadStringW(SETUPAPI_hInstance, IDS_INFO, message, ARRAY_SIZE(message));
SetDlgItemTextW(hwnd, IDC_INFO, message);
- LoadStringW(SETUPAPI_hInstance, IDS_COPYFROM, message,
- sizeof(message)/sizeof(message[0]));
+ LoadStringW(SETUPAPI_hInstance, IDS_COPYFROM, message, ARRAY_SIZE(message));
SetDlgItemTextW(hwnd, IDC_COPYFROM, message);
}
if(params->DiskPromptStyle & IDF_NOBROWSE)
diff --git a/dlls/setupapi/fakedll.c b/dlls/setupapi/fakedll.c
index d310cc9c31..e0d012a034 100644
--- a/dlls/setupapi/fakedll.c
+++ b/dlls/setupapi/fakedll.c
@@ -637,14 +637,14 @@ static BOOL create_winsxs_dll( const WCHAR *dll_name, const xmlstr_t *arch, cons
if (!(filename = strrchrW( dll_name, '\\' ))) filename = dll_name;
else filename++;
- path_len = GetWindowsDirectoryW( NULL, 0 ) + 1 + sizeof(winsxsW)/sizeof(WCHAR)
+ path_len = GetWindowsDirectoryW( NULL, 0 ) + 1 + ARRAY_SIZE( winsxsW )
+ arch->len + name->len + key->len + version->len + 18 + strlenW( filename ) + 1;
path = HeapAlloc( GetProcessHeap(), 0, path_len * sizeof(WCHAR) );
pos = GetWindowsDirectoryW( path, path_len );
path[pos++] = '\\';
memcpy( path + pos, winsxsW, sizeof(winsxsW) );
- pos += sizeof(winsxsW) / sizeof(WCHAR);
+ pos += ARRAY_SIZE( winsxsW );
get_manifest_filename( arch, name, key, version, lang, path + pos, path_len - pos );
pos += strlenW( path + pos );
path[pos++] = '\\';
@@ -672,14 +672,14 @@ static BOOL create_manifest( const xmlstr_t *arch, const xmlstr_t *name, const x
HANDLE handle;
BOOL ret = FALSE;
- path_len = GetWindowsDirectoryW( NULL, 0 ) + 1 + sizeof(winsxsW)/sizeof(WCHAR)
- + arch->len + name->len + key->len + version->len + 18 + sizeof(extensionW)/sizeof(WCHAR);
+ path_len = GetWindowsDirectoryW( NULL, 0 ) + 1 + ARRAY_SIZE( winsxsW )
+ + arch->len + name->len + key->len + version->len + 18 + ARRAY_SIZE( extensionW );
path = HeapAlloc( GetProcessHeap(), 0, path_len * sizeof(WCHAR) );
pos = GetWindowsDirectoryW( path, MAX_PATH );
path[pos++] = '\\';
memcpy( path + pos, winsxsW, sizeof(winsxsW) );
- pos += sizeof(winsxsW) / sizeof(WCHAR);
+ pos += ARRAY_SIZE( winsxsW );
get_manifest_filename( arch, name, key, version, lang, path + pos, MAX_PATH - pos );
strcatW( path + pos, extensionW );
handle = CreateFileW( path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL );
@@ -730,7 +730,7 @@ static BOOL CALLBACK register_manifest( HMODULE module, const WCHAR *type, WCHAR
SIZE_T len;
HRSRC rsrc;
- if (IS_INTRESOURCE(res_name) || strncmpW( res_name, manifestW, sizeof(manifestW)/sizeof(WCHAR) ))
+ if (IS_INTRESOURCE( res_name ) || strncmpW( res_name, manifestW, ARRAY_SIZE( manifestW )))
return TRUE;
rsrc = FindResourceW( module, res_name, type );
diff --git a/dlls/setupapi/install.c b/dlls/setupapi/install.c
index 5a76e3a581..5b2d4b8ee3 100644
--- a/dlls/setupapi/install.c
+++ b/dlls/setupapi/install.c
@@ -435,13 +435,13 @@ static BOOL registry_callback( HINF hinf, PCWSTR field, void *arg )
INT flags;
/* get root */
- if (!SetupGetStringFieldW( &context, 1, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
+ if (!SetupGetStringFieldW( &context, 1, buffer, ARRAY_SIZE( buffer ), NULL ))
continue;
if (!(root_key = get_root_key( buffer, info->default_root )))
continue;
/* get key */
- if (!SetupGetStringFieldW( &context, 2, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
+ if (!SetupGetStringFieldW( &context, 2, buffer, ARRAY_SIZE( buffer ), NULL ))
*buffer = 0;
/* get flags */
@@ -480,7 +480,7 @@ static BOOL registry_callback( HINF hinf, PCWSTR field, void *arg )
TRACE( "key %p %s\n", root_key, debugstr_w(buffer) );
/* get value name */
- if (!SetupGetStringFieldW( &context, 3, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
+ if (!SetupGetStringFieldW( &context, 3, buffer, ARRAY_SIZE( buffer ), NULL ))
*buffer = 0;
/* and now do it */
@@ -669,7 +669,7 @@ static BOOL register_dlls_callback( HINF hinf, PCWSTR field, void *arg )
if (!(path = PARSER_get_dest_dir( &context ))) continue;
/* get dll name */
- if (!SetupGetStringFieldW( &context, 3, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
+ if (!SetupGetStringFieldW( &context, 3, buffer, ARRAY_SIZE( buffer ), NULL ))
goto done;
if (!(p = HeapReAlloc( GetProcessHeap(), 0, path,
(strlenW(path) + strlenW(buffer) + 2) * sizeof(WCHAR) ))) goto done;
@@ -686,7 +686,7 @@ static BOOL register_dlls_callback( HINF hinf, PCWSTR field, void *arg )
/* get command line */
args = NULL;
- if (SetupGetStringFieldW( &context, 6, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
+ if (SetupGetStringFieldW( &context, 6, buffer, ARRAY_SIZE( buffer ), NULL ))
args = buffer;
ret = do_register_dll( info, path, flags, timeout, args );
@@ -717,7 +717,7 @@ static BOOL fake_dlls_callback( HINF hinf, PCWSTR field, void *arg )
if (!(path = PARSER_get_dest_dir( &context ))) continue;
/* get dll name */
- if (!SetupGetStringFieldW( &context, 3, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
+ if (!SetupGetStringFieldW( &context, 3, buffer, ARRAY_SIZE( buffer ), NULL ))
goto done;
if (!(p = HeapReAlloc( GetProcessHeap(), 0, path,
(strlenW(path) + strlenW(buffer) + 2) * sizeof(WCHAR) ))) goto done;
@@ -727,7 +727,7 @@ static BOOL fake_dlls_callback( HINF hinf, PCWSTR field, void *arg )
strcpyW( p, buffer );
/* get source dll */
- if (SetupGetStringFieldW( &context, 4, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
+ if (SetupGetStringFieldW( &context, 4, buffer, ARRAY_SIZE( buffer ), NULL ))
p = buffer; /* otherwise use target base name as default source */
create_fake_dll( path, p ); /* ignore errors */
@@ -758,16 +758,13 @@ static BOOL update_ini_callback( HINF hinf, PCWSTR field, void *arg )
WCHAR string[MAX_INF_STRING_LENGTH];
LPWSTR divider;
- if (!SetupGetStringFieldW( &context, 1, filename,
- sizeof(filename)/sizeof(WCHAR), NULL ))
+ if (!SetupGetStringFieldW( &context, 1, filename, ARRAY_SIZE( filename ), NULL ))
continue;
- if (!SetupGetStringFieldW( &context, 2, section,
- sizeof(section)/sizeof(WCHAR), NULL ))
+ if (!SetupGetStringFieldW( &context, 2, section, ARRAY_SIZE( section ), NULL ))
continue;
- if (!SetupGetStringFieldW( &context, 4, buffer,
- sizeof(buffer)/sizeof(WCHAR), NULL ))
+ if (!SetupGetStringFieldW( &context, 4, buffer, ARRAY_SIZE( buffer ), NULL ))
continue;
divider = strchrW(buffer,'=');
@@ -949,7 +946,7 @@ static BOOL iterate_section_fields( HINF hinf, PCWSTR section, PCWSTR key,
{
WCHAR static_buffer[200];
WCHAR *buffer = static_buffer;
- DWORD size = sizeof(static_buffer)/sizeof(WCHAR);
+ DWORD size = ARRAY_SIZE( static_buffer );
INFCONTEXT context;
BOOL ret = FALSE;
@@ -1211,7 +1208,7 @@ void WINAPI InstallHinfSectionW( HWND hwnd, HINSTANCE handle, LPCWSTR cmdline, I
static const WCHAR nt_genericW[] = {'.','n','t',0};
static const WCHAR servicesW[] = {'.','S','e','r','v','i','c','e','s',0};
- WCHAR *s, *path, section[MAX_PATH + (sizeof(nt_platformW) + sizeof(servicesW)) / sizeof(WCHAR)];
+ WCHAR *s, *path, section[MAX_PATH + ARRAY_SIZE( nt_platformW ) + ARRAY_SIZE( servicesW )];
void *callback_context;
UINT mode;
HINF hinf;
diff --git a/dlls/setupapi/misc.c b/dlls/setupapi/misc.c
index 98a6ed7e89..c83df698ad 100644
--- a/dlls/setupapi/misc.c
+++ b/dlls/setupapi/misc.c
@@ -934,7 +934,7 @@ BOOL WINAPI SetupCopyOEMInfW( PCWSTR source, PCWSTR location,
return FALSE;
}
- if (!GetWindowsDirectoryW( target, sizeof(target)/sizeof(WCHAR) )) return FALSE;
+ if (!GetWindowsDirectoryW( target, ARRAY_SIZE( target ))) return FALSE;
strcatW( target, inf );
if ((p = strrchrW( source, '\\' )))
@@ -963,7 +963,7 @@ BOOL WINAPI SetupCopyOEMInfW( PCWSTR source, PCWSTR location,
p = strrchrW( target, '\\' ) + 1;
memcpy( p, oem, sizeof(oem) );
- p += sizeof(oem)/sizeof(oem[0]) - 1;
+ p += ARRAY_SIZE( oem ) - 1;
/* generate OEMnnn.inf ending */
for (i = 0; i < OEM_INDEX_LIMIT; i++)
@@ -1004,7 +1004,7 @@ BOOL WINAPI SetupCopyOEMInfW( PCWSTR source, PCWSTR location,
if (hinf == INVALID_HANDLE_VALUE) return FALSE;
if (SetupGetLineTextW( NULL, hinf, wszVersion, wszCatalogFile, catalog_file,
- sizeof(catalog_file)/sizeof(catalog_file[0]), NULL ))
+ ARRAY_SIZE( catalog_file ), NULL ))
{
WCHAR source_cat[MAX_PATH];
HCATADMIN handle;
@@ -1099,7 +1099,7 @@ BOOL WINAPI SetupUninstallOEMInfW( PCWSTR inf_file, DWORD flags, PVOID reserved
return FALSE;
}
- if (!GetWindowsDirectoryW( target, sizeof(target)/sizeof(WCHAR) )) return FALSE;
+ if (!GetWindowsDirectoryW( target, ARRAY_SIZE( target ))) return FALSE;
strcatW( target, infW );
strcatW( target, inf_file );
diff --git a/dlls/setupapi/parser.c b/dlls/setupapi/parser.c
index 5cc3ef58ce..bc5dba0454 100644
--- a/dlls/setupapi/parser.c
+++ b/dlls/setupapi/parser.c
@@ -226,7 +226,7 @@ static int add_section( struct inf_file *file, const WCHAR *name )
if (!(section = HeapAlloc( GetProcessHeap(), 0, sizeof(*section) ))) return -1;
section->name = name;
section->nb_lines = 0;
- section->alloc_lines = sizeof(section->lines)/sizeof(section->lines[0]);
+ section->alloc_lines = ARRAY_SIZE( section->lines );
file->sections[file->nb_sections] = section;
return file->nb_sections++;
}
@@ -425,7 +425,7 @@ static unsigned int PARSER_string_substA( const struct inf_file *file, const WCH
WCHAR buffW[MAX_STRING_LEN+1];
DWORD ret;
- unsigned int len = PARSER_string_substW( file, text, buffW, sizeof(buffW)/sizeof(WCHAR) );
+ unsigned int len = PARSER_string_substW( file, text, buffW, ARRAY_SIZE( buffW ));
if (!buffer) RtlUnicodeToMultiByteSize( &ret, buffW, len * sizeof(WCHAR) );
else
{
@@ -449,7 +449,7 @@ static WCHAR *push_string( struct inf_file *file, const WCHAR *string )
/* push the current state on the parser stack */
static inline void push_state( struct parser *parser, enum parser_state state )
{
- assert( parser->stack_pos < sizeof(parser->stack)/sizeof(parser->stack[0]) );
+ assert( parser->stack_pos < ARRAY_SIZE( parser->stack ));
parser->stack[parser->stack_pos++] = state;
}
@@ -1217,8 +1217,7 @@ BOOL WINAPI SetupOpenAppendInfFileW( PCWSTR name, HINF parent_hinf, UINT *error
int idx = 1;
if (!SetupFindFirstLineW( parent_hinf, Version, LayoutFile, &context )) return FALSE;
- while (SetupGetStringFieldW( &context, idx++, filename,
- sizeof(filename)/sizeof(WCHAR), NULL ))
+ while (SetupGetStringFieldW( &context, idx++, filename, ARRAY_SIZE( filename ), NULL ))
{
child_hinf = SetupOpenInfFileW( filename, NULL, INF_STYLE_WIN4, error );
if (child_hinf == INVALID_HANDLE_VALUE) return FALSE;
diff --git a/dlls/setupapi/query.c b/dlls/setupapi/query.c
index eaeadc0f2b..627c543d6b 100644
--- a/dlls/setupapi/query.c
+++ b/dlls/setupapi/query.c
@@ -689,8 +689,7 @@ BOOL WINAPI SetupQueryInfOriginalFileInformationW(
if (!SetupGetLineTextW(NULL, hinf, wszVersion, wszCatalogFile,
OriginalFileInfo->OriginalCatalogName,
- sizeof(OriginalFileInfo->OriginalCatalogName)/sizeof(OriginalFileInfo->OriginalCatalogName[0]),
- NULL))
+ ARRAY_SIZE(OriginalFileInfo->OriginalCatalogName), NULL))
{
OriginalFileInfo->OriginalCatalogName[0] = '\0';
}
diff --git a/dlls/setupapi/queue.c b/dlls/setupapi/queue.c
index d2e2a1d9d5..cc17966770 100644
--- a/dlls/setupapi/queue.c
+++ b/dlls/setupapi/queue.c
@@ -755,9 +755,9 @@ BOOL WINAPI SetupQueueCopySectionW( HSPFILEQ queue, PCWSTR src_root, HINF hinf,
if (!(params.TargetDirectory = dest_dir = get_destination_dir( hinf, section ))) return FALSE;
do
{
- if (!SetupGetStringFieldW( &context, 1, dest, sizeof(dest)/sizeof(WCHAR), NULL ))
+ if (!SetupGetStringFieldW( &context, 1, dest, ARRAY_SIZE( dest ), NULL ))
goto end;
- if (!SetupGetStringFieldW( &context, 2, src, sizeof(src)/sizeof(WCHAR), NULL )) *src = 0;
+ if (!SetupGetStringFieldW( &context, 2, src, ARRAY_SIZE( src ), NULL )) *src = 0;
if (!SetupGetIntField( &context, 4, &flags )) flags = 0; /* FIXME */
params.SourceFilename = *src ? src : NULL;
@@ -806,7 +806,7 @@ BOOL WINAPI SetupQueueDeleteSectionW( HSPFILEQ queue, HINF hinf, HINF hlist, PCW
if (!(dest_dir = get_destination_dir( hinf, section ))) return FALSE;
do
{
- if (!SetupGetStringFieldW( &context, 1, buffer, sizeof(buffer)/sizeof(WCHAR), NULL ))
+ if (!SetupGetStringFieldW( &context, 1, buffer, ARRAY_SIZE( buffer ), NULL ))
goto done;
if (!SetupGetIntField( &context, 4, &flags )) flags = 0;
if (!SetupQueueDeleteW( queue, dest_dir, buffer )) goto done;
@@ -854,9 +854,9 @@ BOOL WINAPI SetupQueueRenameSectionW( HSPFILEQ queue, HINF hinf, HINF hlist, PCW
if (!(dest_dir = get_destination_dir( hinf, section ))) return FALSE;
do
{
- if (!SetupGetStringFieldW( &context, 1, dst, sizeof(dst)/sizeof(WCHAR), NULL ))
+ if (!SetupGetStringFieldW( &context, 1, dst, ARRAY_SIZE( dst ), NULL ))
goto done;
- if (!SetupGetStringFieldW( &context, 2, src, sizeof(src)/sizeof(WCHAR), NULL ))
+ if (!SetupGetStringFieldW( &context, 2, src, ARRAY_SIZE( src ), NULL ))
goto done;
if (!SetupQueueRenameW( queue, dest_dir, src, NULL, dst )) goto done;
} while (SetupFindNextLine( &context, &context ));
--
2.14.4
Sept. 14, 2018
[PATCH 2/2] shell32/brsfolder: Add shortcut to delete folders with the delete key
by Fabian Maurer
Signed-off-by: Fabian Maurer <dark.shadow4(a)web.de>
---
dlls/shell32/brsfolder.c | 93 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 93 insertions(+)
diff --git a/dlls/shell32/brsfolder.c b/dlls/shell32/brsfolder.c
index 91936bd9ce..988aff7460 100644
--- a/dlls/shell32/brsfolder.c
+++ b/dlls/shell32/brsfolder.c
@@ -38,6 +38,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(shell);
+#define SHV_CHANGE_NOTIFY WM_USER + 0x1111
+
/* original margins and control size */
typedef struct tagLAYOUT_DATA
{
@@ -53,6 +55,7 @@ typedef struct tagbrowse_info
LPITEMIDLIST pidlRet;
LAYOUT_DATA *layout; /* filled by LayoutInit, used by LayoutUpdate */
SIZE szMin;
+ ULONG hNotify; /* change notification handle */
} browse_info;
typedef struct tagTV_ITEMDATA
@@ -635,6 +638,30 @@ static LRESULT BrsFolder_Treeview_Keydown(browse_info *info, LPNMTVKEYDOWN keydo
case VK_F2:
BrsFolder_Rename(info, selected_item);
break;
+ case VK_DELETE:
+ {
+ const ITEMIDLIST *item_id;
+ ISFHelper *psfhlp;
+ HRESULT hr;
+ TVITEMW item;
+ TV_ITEMDATA *item_data;
+
+ item.mask = TVIF_PARAM;
+ item.mask = TVIF_HANDLE|TVIF_PARAM;
+ item.hItem = selected_item;
+ SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item);
+ item_data = (TV_ITEMDATA *)item.lParam;
+ item_id = item_data->lpi;
+
+ hr = IShellFolder_QueryInterface(item_data->lpsfParent, &IID_ISFHelper, (void**)&psfhlp);
+ if(FAILED(hr))
+ return 0;
+
+ /* perform the item deletion - tree view gets updated over shell notification */
+ ISFHelper_DeleteItems(psfhlp, 1, &item_id);
+ ISFHelper_Release(psfhlp);
+ }
+ break;
}
return 0;
}
@@ -680,6 +707,8 @@ static LRESULT BrsFolder_OnNotify( browse_info *info, UINT CtlID, LPNMHDR lpnmh
static BOOL BrsFolder_OnCreate( HWND hWnd, browse_info *info )
{
+ LPITEMIDLIST computer_pidl;
+ SHChangeNotifyEntry ntreg;
LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo;
info->hWnd = hWnd;
@@ -745,6 +774,14 @@ static BOOL BrsFolder_OnCreate( HWND hWnd, browse_info *info )
else
ERR("treeview control missing!\n");
+ /* Register for change notifications */
+ SHGetFolderLocation(NULL, CSIDL_DESKTOP, NULL, 0, &computer_pidl);
+
+ ntreg.pidl = computer_pidl;
+ ntreg.fRecursive = TRUE;
+
+ info->hNotify = SHChangeNotifyRegister(hWnd, SHCNRF_InterruptLevel, SHCNE_ALLEVENTS, SHV_CHANGE_NOTIFY, 1, &ntreg);
+
browsefolder_callback( info->lpBrowseInfo, hWnd, BFFM_INITIALIZED, 0 );
return TRUE;
@@ -1001,9 +1038,62 @@ static INT BrsFolder_OnDestroy(browse_info *info)
info->layout = NULL;
}
+ SHChangeNotifyDeregister(info->hNotify);
+
return 0;
}
+/* Find a treeview node by recursively walking the treeview */
+static HTREEITEM BrsFolder_FindItemByPidl(browse_info *info, LPCITEMIDLIST pidl, HTREEITEM hItem)
+{
+ TV_ITEMW item;
+ TV_ITEMDATA *item_data;
+ HRESULT hr;
+
+ item.mask = TVIF_HANDLE | TVIF_PARAM;
+ item.hItem = hItem;
+ SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item);
+ item_data = (TV_ITEMDATA *)item.lParam;
+
+ hr = IShellFolder_CompareIDs(item_data->lpsfParent, 0, item_data->lpifq, pidl);
+ if(SUCCEEDED(hr) && !HRESULT_CODE(hr))
+ return hItem;
+
+ hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem);
+
+ while (hItem)
+ {
+ HTREEITEM newItem = BrsFolder_FindItemByPidl(info, pidl, hItem);
+ if (newItem)
+ return newItem;
+ hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem);
+ }
+ return NULL;
+}
+
+static LRESULT BrsFolder_OnChange(browse_info *info, const LPCITEMIDLIST *pidls, LONG event)
+{
+ BOOL ret = TRUE;
+
+ TRACE("(%p)->(%p, %p, 0x%08x)\n", info, pidls[0], pidls[1], event);
+
+ switch (event)
+ {
+ case SHCNE_RMDIR:
+ case SHCNE_DELETE:
+ {
+ HTREEITEM handle_root = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_ROOT, 0);
+ HTREEITEM handle_item = BrsFolder_FindItemByPidl(info, pidls[0], handle_root);
+
+ if (handle_item)
+ SendMessageW(info->hwndTreeView, TVM_DELETEITEM, 0, (LPARAM)handle_item);
+
+ break;
+ }
+ }
+ return ret;
+}
+
/*************************************************************************
* BrsFolderDlgProc32 (not an exported API function)
*/
@@ -1064,6 +1154,9 @@ static INT_PTR CALLBACK BrsFolderDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
case BFFM_SETEXPANDED: /* unicode only */
return BrsFolder_OnSetExpanded(info, (LPVOID)lParam, (BOOL)wParam, NULL);
+ case SHV_CHANGE_NOTIFY:
+ return BrsFolder_OnChange(info, (const LPCITEMIDLIST*)wParam, (LONG)lParam);
+
case WM_DESTROY:
return BrsFolder_OnDestroy(info);
}
--
2.19.0
Sept. 14, 2018
[PATCH 1/2] shell32/brsfolder: Add shortcut to rename folders with the F2 key
by Fabian Maurer
Signed-off-by: Fabian Maurer <dark.shadow4(a)web.de>
---
dlls/shell32/brsfolder.c | 36 +++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/dlls/shell32/brsfolder.c b/dlls/shell32/brsfolder.c
index daddf1e9ec..91936bd9ce 100644
--- a/dlls/shell32/brsfolder.c
+++ b/dlls/shell32/brsfolder.c
@@ -613,6 +613,32 @@ static LRESULT BrsFolder_Treeview_Rename(browse_info *info, NMTVDISPINFOW *pnmtv
return 0;
}
+static HRESULT BrsFolder_Rename(browse_info *info, HTREEITEM rename)
+{
+ SendMessageW(info->hwndTreeView, TVM_SELECTITEM, TVGN_CARET, (LPARAM)rename);
+ SendMessageW(info->hwndTreeView, TVM_EDITLABELW, 0, (LPARAM)rename);
+ return S_OK;
+}
+
+static LRESULT BrsFolder_Treeview_Keydown(browse_info *info, LPNMTVKEYDOWN keydown)
+{
+ HTREEITEM selected_item;
+
+ /* Old dialog doesn't support those advanced features */
+ if (!(info->lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE))
+ return 0;
+
+ selected_item = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_CARET, 0);
+
+ switch (keydown->wVKey)
+ {
+ case VK_F2:
+ BrsFolder_Rename(info, selected_item);
+ break;
+ }
+ return 0;
+}
+
static LRESULT BrsFolder_OnNotify( browse_info *info, UINT CtlID, LPNMHDR lpnmh )
{
NMTREEVIEWW *pnmtv = (NMTREEVIEWW *)lpnmh;
@@ -640,6 +666,9 @@ static LRESULT BrsFolder_OnNotify( browse_info *info, UINT CtlID, LPNMHDR lpnmh
case TVN_ENDLABELEDITW:
return BrsFolder_Treeview_Rename( info, (LPNMTVDISPINFOW)pnmtv );
+ case TVN_KEYDOWN:
+ return BrsFolder_Treeview_Keydown( info, (LPNMTVKEYDOWN)pnmtv );
+
default:
WARN("unhandled (%d)\n", pnmtv->hdr.code);
break;
@@ -721,13 +750,6 @@ static BOOL BrsFolder_OnCreate( HWND hWnd, browse_info *info )
return TRUE;
}
-static HRESULT BrsFolder_Rename(browse_info *info, HTREEITEM rename)
-{
- SendMessageW(info->hwndTreeView, TVM_SELECTITEM, TVGN_CARET, (LPARAM)rename);
- SendMessageW(info->hwndTreeView, TVM_EDITLABELW, 0, (LPARAM)rename);
- return S_OK;
-}
-
static HRESULT BrsFolder_NewFolder(browse_info *info)
{
DWORD flags = BrowseFlagsToSHCONTF(info->lpBrowseInfo->ulFlags);
--
2.19.0
Sept. 14, 2018
[PATCH] wined3d: Make the resource parameter to wined3d_resource_get_decompress_format() const.
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/resource.c | 2 +-
dlls/wined3d/wined3d_private.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 95c9b7ff197..a3dadec3ab1 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -478,7 +478,7 @@ void wined3d_resource_update_draw_binding(struct wined3d_resource *resource)
}
}
-const struct wined3d_format *wined3d_resource_get_decompress_format(struct wined3d_resource *resource)
+const struct wined3d_format *wined3d_resource_get_decompress_format(const struct wined3d_resource *resource)
{
const struct wined3d_adapter *adapter = resource->device->adapter;
if (resource->format_flags & (WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index aea874f84ea..88e0756704a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3126,7 +3126,7 @@ void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
const struct wined3d_format *wined3d_resource_get_decompress_format(
- struct wined3d_resource *resource) DECLSPEC_HIDDEN;
+ const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
--
2.11.0
Sept. 14, 2018