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
June 2018
- 68 participants
- 1149 messages
[PATCH] d3dx9/tests: Add initial tests for ID3DXFont::DrawText().
by Matteo Bruni
From: Kieran Duggan <kieranduggan15(a)gmail.com>
Signed-off-by: Kieran Duggan <kieranduggan15(a)gmail.com>
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
---
dlls/d3dx9_36/tests/core.c | 81 +++++++++++++++++++++++++++++++++++-----------
1 file changed, 62 insertions(+), 19 deletions(-)
diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c
index 75d33c1e0dc..3ed25f8176b 100644
--- a/dlls/d3dx9_36/tests/core.c
+++ b/dlls/d3dx9_36/tests/core.c
@@ -305,23 +305,28 @@ static void test_ID3DXSprite(IDirect3DDevice9 *device)
static void test_ID3DXFont(IDirect3DDevice9 *device)
{
- D3DXFONT_DESCA desc;
- ID3DXFont *font;
- HRESULT hr;
- int ref;
- int i;
- static const struct {
- INT font_height;
- UINT expected_size;
- DWORD expected_levels;
- } texture_tests[] = {
+ static const WCHAR testW[] = {'t','e','s','t',0};
+ static const struct
+ {
+ int font_height;
+ unsigned int expected_size;
+ unsigned int expected_levels;
+ }
+ tests[] =
+ {
{ 6, 128, 4 },
{ 8, 128, 4 },
{ 10, 256, 5 },
{ 12, 256, 5 },
- { 72, 256, 8 }
+ { 72, 256, 8 },
};
-
+ const unsigned int size = ARRAY_SIZE(testW);
+ D3DXFONT_DESCA desc;
+ ID3DXSprite *sprite;
+ int ref, i, height;
+ ID3DXFont *font;
+ HRESULT hr;
+ RECT rect;
/* D3DXCreateFont */
ref = get_ref((IUnknown*)device);
@@ -463,8 +468,6 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
/* ID3DXFont_PreloadText */
hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font);
if(SUCCEEDED(hr)) {
- const WCHAR testW[] = {'t','e','s','t',0};
-
todo_wine {
hr = ID3DXFont_PreloadTextA(font, NULL, -1);
ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
@@ -552,7 +555,8 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
check_release((IUnknown*)font, 0);
} else skip("Failed to create a ID3DXFont object\n");
- for(i = 0; i < ARRAY_SIZE(texture_tests); i++) {
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
+ {
HDC hdc;
DWORD ret;
HRESULT hr;
@@ -560,7 +564,8 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
char c = 'a';
IDirect3DTexture9 *texture;
- hr = D3DXCreateFontA(device, texture_tests[i].font_height, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font);
+ hr = D3DXCreateFontA(device, tests[i].font_height, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET,
+ OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font);
if(FAILED(hr)) {
skip("Failed to create a ID3DXFont object\n");
continue;
@@ -578,17 +583,55 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
D3DSURFACE_DESC desc;
levels = IDirect3DTexture9_GetLevelCount(texture);
- ok(levels == texture_tests[i].expected_levels, "Got levels %u, expected %u\n", levels, texture_tests[i].expected_levels);
+ ok(levels == tests[i].expected_levels, "Got levels %u, expected %u\n",
+ levels, tests[i].expected_levels);
hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc);
ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc failed\n");
ok(desc.Format == D3DFMT_A8R8G8B8, "Got format %#x, expected %#x\n", desc.Format, D3DFMT_A8R8G8B8);
ok(desc.Usage == 0, "Got usage %#x, expected %#x\n", desc.Usage, 0);
- ok(desc.Width == texture_tests[i].expected_size, "Got width %u, expected %u\n", desc.Width, texture_tests[i].expected_size);
- ok(desc.Height == texture_tests[i].expected_size, "Got height %u, expected %u\n", desc.Height, texture_tests[i].expected_size);
+ ok(desc.Width == tests[i].expected_size, "Got width %u, expected %u\n",
+ desc.Width, tests[i].expected_size);
+ ok(desc.Height == tests[i].expected_size, "Got height %u, expected %u\n",
+ desc.Height, tests[i].expected_size);
ok(desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected %u\n", desc.Pool, D3DPOOL_MANAGED);
IDirect3DTexture9_Release(texture);
}
+
+ /* ID3DXFontImpl_DrawText */
+ D3DXCreateSprite(device, &sprite);
+ SetRect(&rect, 0, 0, 640, 480);
+
+ IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0);
+
+ IDirect3DDevice9_BeginScene(device);
+ hr = ID3DXSprite_Begin(sprite, D3DXSPRITE_ALPHABLEND);
+ ok (hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ height = ID3DXFont_DrawTextW(font, sprite, testW, -1, &rect, DT_TOP, 0xffffffff);
+ ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
+ height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_TOP, 0xffffffff);
+ ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
+ height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_RIGHT, 0xffffffff);
+ ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
+ height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_LEFT | DT_NOCLIP,
+ 0xffffffff);
+ ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
+
+ SetRect(&rect, 0, 0, 0, 0);
+ height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect,
+ DT_LEFT | DT_CALCRECT, 0xffffffff);
+ ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
+ ok(!rect.left, "Got unexpected rect left %d.\n", rect.left);
+ ok(!rect.top, "Got unexpected rect top %d.\n", rect.top);
+ ok(rect.right, "Got unexpected rect right %d.\n", rect.right);
+ ok(rect.bottom == tests[i].font_height, "Got unexpected rect bottom %d.\n", rect.bottom);
+
+ hr = ID3DXSprite_End(sprite);
+ ok (hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ IDirect3DDevice9_EndScene(device);
+ ID3DXSprite_Release(sprite);
+
ID3DXFont_Release(font);
}
}
--
2.16.1
June 14, 2018
[PATCH] urlmon/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/urlmon/tests/misc.c | 66 +++++++++++++++++---------------------
dlls/urlmon/tests/protocol.c | 26 +++++++--------
dlls/urlmon/tests/sec_mgr.c | 20 ++++++------
dlls/urlmon/tests/uri.c | 76 ++++++++++++++++++++++----------------------
dlls/urlmon/tests/url.c | 2 +-
5 files changed, 91 insertions(+), 99 deletions(-)
diff --git a/dlls/urlmon/tests/misc.c b/dlls/urlmon/tests/misc.c
index e88c960497..ff0f24ed76 100644
--- a/dlls/urlmon/tests/misc.c
+++ b/dlls/urlmon/tests/misc.c
@@ -85,7 +85,7 @@ static HRESULT (WINAPI *pIEInstallScope)(DWORD*);
static int strcmp_wa(const WCHAR *strw, const char *stra)
{
WCHAR buf[512];
- MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, ARRAY_SIZE(buf));
return lstrcmpW(strw, buf);
}
@@ -367,23 +367,23 @@ static void test_CoInternetParseUrl(void)
3, &size, 0);
ok(hres == E_POINTER, "schema failed: %08x, expected E_POINTER\n", hres);
- for(i=0; i < sizeof(parse_tests)/sizeof(parse_tests[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(parse_tests); i++) {
memset(buf, 0xf0, sizeof(buf));
hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_SECURITY_URL, 0, buf,
- sizeof(buf)/sizeof(WCHAR), &size, 0);
+ ARRAY_SIZE(buf), &size, 0);
ok(hres == parse_tests[i].secur_hres, "[%d] security url failed: %08x, expected %08x\n",
i, hres, parse_tests[i].secur_hres);
memset(buf, 0xf0, sizeof(buf));
hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_ENCODE, 0, buf,
- sizeof(buf)/sizeof(WCHAR), &size, 0);
+ ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "[%d] encoding failed: %08x\n", i, hres);
ok(size == lstrlenW(parse_tests[i].encoded_url), "[%d] wrong size\n", i);
ok(!lstrcmpW(parse_tests[i].encoded_url, buf), "[%d] wrong encoded url\n", i);
memset(buf, 0xf0, sizeof(buf));
hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_PATH_FROM_URL, 0, buf,
- sizeof(buf)/sizeof(WCHAR), &size, 0);
+ ARRAY_SIZE(buf), &size, 0);
ok(hres == parse_tests[i].path_hres, "[%d] path failed: %08x, expected %08x\n",
i, hres, parse_tests[i].path_hres);
if(parse_tests[i].path) {
@@ -393,7 +393,7 @@ static void test_CoInternetParseUrl(void)
memset(buf, 0xf0, sizeof(buf));
hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_SCHEMA, 0, buf,
- sizeof(buf)/sizeof(WCHAR), &size, 0);
+ ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "[%d] schema failed: %08x\n", i, hres);
ok(size == lstrlenW(parse_tests[i].schema), "[%d] wrong size\n", i);
ok(!lstrcmpW(parse_tests[i].schema, buf), "[%d] wrong schema\n", i);
@@ -402,7 +402,7 @@ static void test_CoInternetParseUrl(void)
&& memcmp(parse_tests[i].url, wszAbout, 5*sizeof(WCHAR))) {
memset(buf, 0xf0, sizeof(buf));
hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_DOMAIN, 0, buf,
- sizeof(buf)/sizeof(WCHAR), &size, 0);
+ ARRAY_SIZE(buf), &size, 0);
ok(hres == parse_tests[i].domain_hres, "[%d] domain failed: %08x\n", i, hres);
if(parse_tests[i].domain)
ok(!lstrcmpW(parse_tests[i].domain, buf), "[%d] wrong domain, received %s\n", i, wine_dbgstr_w(buf));
@@ -410,7 +410,7 @@ static void test_CoInternetParseUrl(void)
memset(buf, 0xf0, sizeof(buf));
hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_ROOTDOCUMENT, 0, buf,
- sizeof(buf)/sizeof(WCHAR), &size, 0);
+ ARRAY_SIZE(buf), &size, 0);
ok(hres == parse_tests[i].rootdocument_hres, "[%d] rootdocument failed: %08x\n", i, hres);
if(parse_tests[i].rootdocument)
ok(!lstrcmpW(parse_tests[i].rootdocument, buf), "[%d] wrong rootdocument, received %s\n", i, wine_dbgstr_w(buf));
@@ -451,7 +451,7 @@ static void test_CoInternetQueryInfo(void)
DWORD cb, i;
HRESULT hres;
- for(i=0; i < sizeof(query_info_tests)/sizeof(query_info_tests[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(query_info_tests); i++) {
cb = 0xdeadbeef;
memset(buf, '?', sizeof(buf));
hres = pCoInternetQueryInfo(query_info_tests[0].url, QUERY_USES_NETWORK, 0, buf, sizeof(buf), &cb, 0);
@@ -724,7 +724,7 @@ static void test_FindMimeFromData(void)
static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
static const WCHAR text_plainW[] = {'t','e','x','t','/','p','l','a','i','n',0};
- for(i=0; i<sizeof(mime_tests)/sizeof(mime_tests[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(mime_tests); i++) {
mime = (LPWSTR)0xf0f0f0f0;
url = a2w(mime_tests[i].url);
hres = pFindMimeFromData(NULL, url, NULL, 0, NULL, 0, &mime, 0);
@@ -757,7 +757,7 @@ static void test_FindMimeFromData(void)
heap_free(url);
}
- for(i=0; i < sizeof(mime_tests2)/sizeof(mime_tests2[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(mime_tests2); i++) {
url = a2w(mime_tests2[i].url);
proposed_mime = a2w(mime_tests2[i].proposed_mime);
hres = pFindMimeFromData(NULL, url, mime_tests2[i].data, mime_tests2[i].size,
@@ -879,9 +879,9 @@ static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface
if(ParseAction == PARSE_SECURITY_URL) {
if(pcchResult)
- *pcchResult = sizeof(url1)/sizeof(WCHAR);
+ *pcchResult = ARRAY_SIZE(url1);
- if(cchResult<sizeof(url1)/sizeof(WCHAR))
+ if(cchResult < ARRAY_SIZE(url1))
return S_FALSE;
memcpy(pwzResult, url1, sizeof(url1));
@@ -1032,8 +1032,7 @@ static void test_NameSpace(void)
SET_EXPECT(CreateInstance);
SET_EXPECT(ParseUrl);
- hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
- &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
CHECK_CALLED(QI_IInternetProtocolInfo);
@@ -1044,8 +1043,7 @@ static void test_NameSpace(void)
SET_EXPECT(QI_IInternetProtocolInfo);
SET_EXPECT(ParseUrl);
- hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
- &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
CHECK_CALLED(QI_IInternetProtocolInfo);
@@ -1054,11 +1052,10 @@ static void test_NameSpace(void)
SET_EXPECT(QI_IInternetProtocolInfo);
SET_EXPECT(ParseUrl);
- hres = pCoInternetParseUrl(url8, PARSE_SECURITY_URL, 0, buf,
- sizeof(buf)/sizeof(WCHAR), &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_SECURITY_URL, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
- ok(size == sizeof(url1)/sizeof(WCHAR), "Size = %d\n", size);
- if(size == sizeof(url1)/sizeof(WCHAR))
+ ok(size == ARRAY_SIZE(url1), "Size = %d\n", size);
+ if(size == ARRAY_SIZE(url1))
ok(!memcmp(buf, url1, sizeof(url1)), "Encoded url = %s\n", wine_dbgstr_w(buf));
CHECK_CALLED(QI_IInternetProtocolInfo);
@@ -1071,7 +1068,7 @@ static void test_NameSpace(void)
hres = pCoInternetGetSecurityUrl(url8, &sec_url, PSU_SECURITY_URL_ONLY, 0);
ok(hres == S_OK, "CoInternetGetSecurityUrl failed: %08x\n", hres);
if(hres == S_OK) {
- ok(lstrlenW(sec_url)>sizeof(wszFile)/sizeof(WCHAR) &&
+ ok(lstrlenW(sec_url) > ARRAY_SIZE(wszFile) &&
!memcmp(sec_url, wszFile, sizeof(wszFile)-sizeof(WCHAR)),
"Encoded url = %s\n", wine_dbgstr_w(sec_url));
CoTaskMemFree(sec_url);
@@ -1084,8 +1081,7 @@ static void test_NameSpace(void)
hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
- hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
- &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf2, &IID_NULL,
@@ -1103,8 +1099,7 @@ static void test_NameSpace(void)
SET_EXPECT(QI_IInternetProtocolInfo);
SET_EXPECT(ParseUrl);
- hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
- &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
CHECK_CALLED(QI_IInternetProtocolInfo);
@@ -1116,8 +1111,7 @@ static void test_NameSpace(void)
SET_EXPECT(QI_IInternetProtocolInfo);
SET_EXPECT(ParseUrl);
- hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
- &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
CHECK_CALLED(QI_IInternetProtocolInfo);
@@ -1130,8 +1124,7 @@ static void test_NameSpace(void)
SET_EXPECT(QI_IInternetProtocolInfo);
SET_EXPECT(ParseUrl);
- hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
- &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
CHECK_CALLED(QI_IInternetProtocolInfo);
@@ -1149,8 +1142,7 @@ static void test_NameSpace(void)
hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf2, wszTest);
ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
- hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
- &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
IInternetSession_Release(session);
@@ -1627,7 +1619,7 @@ static void test_MkParseDisplayNameEx(void)
CreateBindCtx(0, &bctx);
- for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
{
eaten = 0xdeadbeef;
mon = (IMoniker *)0xdeadbeef;
@@ -1643,7 +1635,7 @@ static void test_MkParseDisplayNameEx(void)
hres = MkParseDisplayNameEx(bctx, url9, &eaten, &mon);
ok(hres == S_OK, "MkParseDisplayNameEx failed: %08x\n", hres);
- ok(eaten == sizeof(url9)/sizeof(WCHAR)-1, "eaten=%d\n", eaten);
+ ok(eaten == ARRAY_SIZE(url9)-1, "eaten=%d\n", eaten);
ok(mon != NULL, "mon == NULL\n");
hres = IMoniker_GetDisplayName(mon, NULL, 0, &name);
@@ -1659,7 +1651,7 @@ static void test_MkParseDisplayNameEx(void)
hres = MkParseDisplayNameEx(bctx, clsid_nameW, &eaten, &mon);
ok(hres == S_OK, "MkParseDisplayNameEx failed: %08x\n", hres);
- ok(eaten == sizeof(clsid_nameW)/sizeof(WCHAR)-1, "eaten=%d\n", eaten);
+ ok(eaten == ARRAY_SIZE(clsid_nameW)-1, "eaten=%d\n", eaten);
ok(mon != NULL, "mon == NULL\n");
hres = IMoniker_IsSystemMoniker(mon, &issys);
@@ -1733,7 +1725,7 @@ static void test_internet_feature_defaults(void) {
HRESULT hres;
DWORD i;
- for(i = 0; i < sizeof(default_feature_tests)/sizeof(default_feature_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(default_feature_tests); ++i) {
hres = pCoInternetIsFeatureEnabled(default_feature_tests[i].feature, default_feature_tests[i].get_flags);
todo_wine_if (default_feature_tests[i].todo)
ok(hres == default_feature_tests[i].expected, "CoInternetIsFeatureEnabled returned %08x, expected %08x on test %d\n",
@@ -1880,7 +1872,7 @@ static void test_CoInternetSetFeatureEnabled(void) {
hres = pCoInternetSetFeatureEnabled(FEATURE_ENTRY_COUNT,SET_FEATURE_ON_PROCESS,TRUE);
ok(hres == E_FAIL, "CoInternetSetFeatureEnabled returned %08x, expected E_FAIL\n", hres);
- for(i = 0; i < sizeof(internet_feature_tests)/sizeof(internet_feature_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(internet_feature_tests); ++i) {
hres = pCoInternetSetFeatureEnabled(internet_feature_tests[i].feature, internet_feature_tests[i].set_flags,
internet_feature_tests[i].enable);
todo_wine_if (internet_feature_tests[i].set_todo)
diff --git a/dlls/urlmon/tests/protocol.c b/dlls/urlmon/tests/protocol.c
index 0ca8feebcb..999b591f5f 100644
--- a/dlls/urlmon/tests/protocol.c
+++ b/dlls/urlmon/tests/protocol.c
@@ -824,7 +824,7 @@ static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface,
if (winetest_debug > 1)
{
- if (ulStatusCode < sizeof(status_names)/sizeof(status_names[0]))
+ if (ulStatusCode < ARRAY_SIZE(status_names))
trace( "progress: %s %s\n", status_names[ulStatusCode], wine_dbgstr_w(szStatusText) );
else
trace( "progress: %u %s\n", ulStatusCode, wine_dbgstr_w(szStatusText) );
@@ -3051,55 +3051,55 @@ static void test_file_protocol(void) {
test_file_protocol_url(index_url);
memcpy(buf, wszFile, sizeof(wszFile));
- len = sizeof(wszFile)/sizeof(WCHAR)-1;
- len += GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR)-len, buf+len);
+ len = ARRAY_SIZE(wszFile)-1;
+ len += GetCurrentDirectoryW(ARRAY_SIZE(buf)-len, buf+len);
buf[len++] = '\\';
memcpy(buf+len, wszIndexHtml, sizeof(wszIndexHtml));
- file_name = buf + sizeof(wszFile)/sizeof(WCHAR)-1;
+ file_name = buf + ARRAY_SIZE(wszFile)-1;
bindf = 0;
test_file_protocol_url(buf);
bindf = BINDF_FROMURLMON;
test_file_protocol_url(buf);
memcpy(buf, wszFile2, sizeof(wszFile2));
- len = GetCurrentDirectoryW(sizeof(file_name_buf)/sizeof(WCHAR), file_name_buf);
+ len = GetCurrentDirectoryW(ARRAY_SIZE(file_name_buf), file_name_buf);
file_name_buf[len++] = '\\';
memcpy(file_name_buf+len, wszIndexHtml, sizeof(wszIndexHtml));
- lstrcpyW(buf+sizeof(wszFile2)/sizeof(WCHAR)-1, file_name_buf);
+ lstrcpyW(buf+ARRAY_SIZE(wszFile2)-1, file_name_buf);
file_name = file_name_buf;
bindf = 0;
test_file_protocol_url(buf);
bindf = BINDF_FROMURLMON;
test_file_protocol_url(buf);
- buf[sizeof(wszFile2)/sizeof(WCHAR)] = '|';
+ buf[ARRAY_SIZE(wszFile2)] = '|';
test_file_protocol_url(buf);
memcpy(buf, wszFile3, sizeof(wszFile3));
- len = sizeof(wszFile3)/sizeof(WCHAR)-1;
- len += GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR)-len, buf+len);
+ len = ARRAY_SIZE(wszFile3)-1;
+ len += GetCurrentDirectoryW(ARRAY_SIZE(buf)-len, buf+len);
buf[len++] = '\\';
memcpy(buf+len, wszIndexHtml, sizeof(wszIndexHtml));
- file_name = buf + sizeof(wszFile3)/sizeof(WCHAR)-1;
+ file_name = buf + ARRAY_SIZE(wszFile3)-1;
bindf = 0;
test_file_protocol_url(buf);
bindf = BINDF_FROMURLMON;
test_file_protocol_url(buf);
memcpy(buf, wszFile4, sizeof(wszFile4));
- len = GetCurrentDirectoryW(sizeof(file_name_buf)/sizeof(WCHAR), file_name_buf);
+ len = GetCurrentDirectoryW(ARRAY_SIZE(file_name_buf), file_name_buf);
file_name_buf[len++] = '\\';
memcpy(file_name_buf+len, wszIndexHtml, sizeof(wszIndexHtml));
- lstrcpyW(buf+sizeof(wszFile4)/sizeof(WCHAR)-1, file_name_buf);
+ lstrcpyW(buf+ARRAY_SIZE(wszFile4)-1, file_name_buf);
file_name = file_name_buf;
bindf = 0;
test_file_protocol_url(buf);
bindf = BINDF_FROMURLMON;
test_file_protocol_url(buf);
- buf[sizeof(wszFile4)/sizeof(WCHAR)] = '|';
+ buf[ARRAY_SIZE(wszFile4)] = '|';
test_file_protocol_url(buf);
/* Fragment part of URL is skipped if the file doesn't exist. */
diff --git a/dlls/urlmon/tests/sec_mgr.c b/dlls/urlmon/tests/sec_mgr.c
index 411a3b7781..2974eecc36 100644
--- a/dlls/urlmon/tests/sec_mgr.c
+++ b/dlls/urlmon/tests/sec_mgr.c
@@ -221,7 +221,7 @@ static LONG myRegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
dwMaxSubkeyLen++;
dwMaxValueLen++;
dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
- if (dwMaxLen > sizeof(szNameBuf)/sizeof(CHAR))
+ if (dwMaxLen > ARRAY_SIZE(szNameBuf))
{
/* Name too big: alloc a buffer for it */
if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(CHAR))))
@@ -381,7 +381,7 @@ static void test_SecurityManager(void)
if(FAILED(hres))
return;
- for(i=0; i < sizeof(secmgr_tests)/sizeof(secmgr_tests[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(secmgr_tests); i++) {
zone = 100;
hres = IInternetSecurityManager_MapUrlToZone(secmgr, secmgr_tests[i].url,
&zone, 0);
@@ -785,7 +785,7 @@ static BOOL register_zone_domains(void)
res = RegOpenKeyA(HKEY_CURRENT_USER, szZoneMapDomainsKey, &domains);
ok(res == ERROR_SUCCESS, "RegOpenKey failed: %d\n", res);
- for(i = 0; i < sizeof(zone_domain_mappings)/sizeof(zone_domain_mappings[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(zone_domain_mappings); ++i) {
const zone_domain_mapping *test = zone_domain_mappings+i;
HKEY domain;
@@ -830,7 +830,7 @@ static void unregister_zone_domains(void)
res = RegOpenKeyA(HKEY_CURRENT_USER, szZoneMapDomainsKey, &domains);
ok(res == ERROR_SUCCESS, "RegOpenKey failed: %d\n", res);
- for(i = 0; i < sizeof(zone_domain_mappings)/sizeof(zone_domain_mappings[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(zone_domain_mappings); ++i) {
const zone_domain_mapping *test = zone_domain_mappings+i;
/* FIXME: Uses the "cludge" approach to remove the test data from the registry!
@@ -936,7 +936,7 @@ static void test_zone_domain_mappings(void)
RegCloseKey(domains);
}
- for(i = 0; i < sizeof(zone_mapping_tests)/sizeof(zone_mapping_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(zone_mapping_tests); ++i) {
const zone_mapping_test *test = zone_mapping_tests+i;
LPWSTR urlW = a2w(test->url);
zone = URLZONE_INVALID;
@@ -1360,7 +1360,7 @@ static void test_InternetGetSecurityUrl(void)
trace("testing CoInternetGetSecurityUrl...\n");
- for(i=0; i<sizeof(in)/sizeof(WCHAR*); i++) {
+ for(i = 0; i < ARRAY_SIZE(in); i++) {
hres = pCoInternetGetSecurityUrl(in[i], &sec, PSU_DEFAULT, 0);
ok(hres == S_OK, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i, hres);
if(hres == S_OK) {
@@ -1625,7 +1625,7 @@ static void test_InternetGetSecurityUrlEx(void)
ok(hr == E_INVALIDARG, "CoInternetGetSecurityUrlEx returned 0x%08x, expected E_INVALIDARG\n", hr);
ok(result == (void*) 0xdeadbeef, "'result' was %p\n", result);
- for(i = 0; i < sizeof(sec_url_ex_tests)/sizeof(sec_url_ex_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(sec_url_ex_tests); ++i) {
LPWSTR uriW = a2w(sec_url_ex_tests[i].uri);
uri = NULL;
@@ -1827,7 +1827,7 @@ static void test_SecurityManagerEx2(void)
IUri_Release(uri);
- for(i = 0; i < sizeof(sec_mgr_ex2_tests)/sizeof(sec_mgr_ex2_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(sec_mgr_ex2_tests); ++i) {
LPWSTR uriW = a2w(sec_mgr_ex2_tests[i].uri);
uri = NULL;
@@ -1925,7 +1925,7 @@ static void test_CoInternetIsFeatureZoneElevationEnabled(void)
trace("Testing CoInternetIsFeatureZoneElevationEnabled... (%x)\n", hres);
- for(i=0; i<sizeof(testcases)/sizeof(testcases[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(testcases); i++) {
if(hres==S_OK && testcases[i].flags == GET_FEATURE_FROM_PROCESS)
testcases[i].policy_flags = URLPOLICY_ALLOW;
}
@@ -1940,7 +1940,7 @@ static void test_CoInternetIsFeatureZoneElevationEnabled(void)
return;
}
- for(i=0; i<sizeof(testcases)/sizeof(testcases[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(testcases); i++) {
url_from = a2w(testcases[i].url_from);
url_to = a2w(testcases[i].url_to);
diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c
index 90f51bf5dd..7580a1302d 100644
--- a/dlls/urlmon/tests/uri.c
+++ b/dlls/urlmon/tests/uri.c
@@ -7786,7 +7786,7 @@ static void change_property(IUriBuilder *builder, const uri_builder_property *pr
static void test_CreateUri_InvalidFlags(void) {
DWORD i;
- for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(invalid_flag_tests); ++i) {
HRESULT hr;
IUri *uri = (void*) 0xdeadbeef;
@@ -7825,7 +7825,7 @@ static void test_CreateUri_InvalidArgs(void) {
static void test_CreateUri_InvalidUri(void) {
DWORD i;
- for(i = 0; i < sizeof(invalid_uri_tests)/sizeof(invalid_uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(invalid_uri_tests); ++i) {
invalid_uri test = invalid_uri_tests[i];
IUri *uri = NULL;
LPWSTR uriW;
@@ -7877,7 +7877,7 @@ static void test_IUri_GetPropertyBSTR(void) {
}
if(uri) IUri_Release(uri);
- for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); ++i) {
uri_properties test = uri_tests[i];
LPWSTR uriW;
uri = NULL;
@@ -7937,7 +7937,7 @@ static void test_IUri_GetPropertyDWORD(void) {
}
if(uri) IUri_Release(uri);
- for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); ++i) {
uri_properties test = uri_tests[i];
LPWSTR uriW;
uri = NULL;
@@ -7952,7 +7952,7 @@ static void test_IUri_GetPropertyDWORD(void) {
DWORD j;
/* Checks all the DWORD properties of the uri. */
- for(j = 0; j < sizeof(test.dword_props)/sizeof(test.dword_props[0]); ++j) {
+ for(j = 0; j < ARRAY_SIZE(test.dword_props); ++j) {
DWORD received;
uri_dword_property prop = test.dword_props[j];
@@ -8029,7 +8029,7 @@ static void test_IUri_GetStrProperties(void) {
}
if(uri) IUri_Release(uri);
- for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); ++i) {
uri_properties test = uri_tests[i];
LPWSTR uriW;
uri = NULL;
@@ -8257,7 +8257,7 @@ static void test_IUri_GetDwordProperties(void) {
}
if(uri) IUri_Release(uri);
- for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); ++i) {
uri_properties test = uri_tests[i];
LPWSTR uriW;
uri = NULL;
@@ -8343,7 +8343,7 @@ static void test_IUri_GetPropertyLength(void) {
}
if(uri) IUri_Release(uri);
- for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); ++i) {
uri_properties test = uri_tests[i];
LPWSTR uriW;
uri = NULL;
@@ -8426,7 +8426,7 @@ static void test_IUri_GetProperties(void) {
}
if(uri) IUri_Release(uri);
- for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); ++i) {
uri_properties test = uri_tests[i];
LPWSTR uriW;
uri = NULL;
@@ -8475,7 +8475,7 @@ static void test_IUri_HasProperty(void) {
}
if(uri) IUri_Release(uri);
- for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); ++i) {
uri_properties test = uri_tests[i];
LPWSTR uriW;
uri = NULL;
@@ -8540,7 +8540,7 @@ static void test_IUri_IsEqual(void) {
IUri_Release(uriA);
IUri_Release(uriB);
- for(i = 0; i < sizeof(equality_tests)/sizeof(equality_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(equality_tests); ++i) {
uri_equality test = equality_tests[i];
LPWSTR uriA_W, uriB_W;
@@ -8592,7 +8592,7 @@ static void test_CreateUriWithFragment_InvalidArgs(void) {
static void test_CreateUriWithFragment_InvalidFlags(void) {
DWORD i;
- for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(invalid_flag_tests); ++i) {
HRESULT hr;
IUri *uri = (void*) 0xdeadbeef;
@@ -8606,7 +8606,7 @@ static void test_CreateUriWithFragment_InvalidFlags(void) {
static void test_CreateUriWithFragment(void) {
DWORD i;
- for(i = 0; i < sizeof(uri_fragment_tests)/sizeof(uri_fragment_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_fragment_tests); ++i) {
HRESULT hr;
IUri *uri = NULL;
LPWSTR uriW, fragW;
@@ -8685,7 +8685,7 @@ static void test_IUriBuilder_CreateUri(IUriBuilder *builder, const uri_builder_t
if(SUCCEEDED(hr)) {
DWORD i;
- for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->expected_str_props); ++i) {
uri_builder_str_property prop = test->expected_str_props[i];
BSTR received = NULL;
@@ -8703,7 +8703,7 @@ static void test_IUriBuilder_CreateUri(IUriBuilder *builder, const uri_builder_t
SysFreeString(received);
}
- for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->expected_dword_props); ++i) {
uri_builder_dword_property prop = test->expected_dword_props[i];
DWORD received = -2;
@@ -8737,7 +8737,7 @@ static void test_IUriBuilder_CreateUriSimple(IUriBuilder *builder, const uri_bui
if(SUCCEEDED(hr)) {
DWORD i;
- for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->expected_str_props); ++i) {
uri_builder_str_property prop = test->expected_str_props[i];
BSTR received = NULL;
@@ -8755,7 +8755,7 @@ static void test_IUriBuilder_CreateUriSimple(IUriBuilder *builder, const uri_bui
SysFreeString(received);
}
- for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->expected_dword_props); ++i) {
uri_builder_dword_property prop = test->expected_dword_props[i];
DWORD received = -2;
@@ -8790,7 +8790,7 @@ static void test_IUriBuilder_CreateUriWithFlags(IUriBuilder *builder, const uri_
if(SUCCEEDED(hr)) {
DWORD i;
- for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->expected_str_props); ++i) {
uri_builder_str_property prop = test->expected_str_props[i];
BSTR received = NULL;
@@ -8808,7 +8808,7 @@ static void test_IUriBuilder_CreateUriWithFlags(IUriBuilder *builder, const uri_
SysFreeString(received);
}
- for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->expected_dword_props); ++i) {
uri_builder_dword_property prop = test->expected_dword_props[i];
DWORD received = -2;
@@ -9051,7 +9051,7 @@ static void test_IUriBuilder_GetFragment(IUriBuilder *builder, const uri_builder
const uri_builder_property *prop = NULL;
/* Check if the property was set earlier. */
- for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->properties); ++i) {
if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_FRAGMENT)
prop = &(test->properties[i]);
}
@@ -9146,7 +9146,7 @@ static void test_IUriBuilder_GetHost(IUriBuilder *builder, const uri_builder_tes
const uri_builder_property *prop = NULL;
/* Check if the property was set earlier. */
- for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->properties); ++i) {
if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_HOST)
prop = &(test->properties[i]);
}
@@ -9241,7 +9241,7 @@ static void test_IUriBuilder_GetPassword(IUriBuilder *builder, const uri_builder
const uri_builder_property *prop = NULL;
/* Check if the property was set earlier. */
- for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->properties); ++i) {
if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PASSWORD)
prop = &(test->properties[i]);
}
@@ -9336,7 +9336,7 @@ static void test_IUriBuilder_GetPath(IUriBuilder *builder, const uri_builder_tes
const uri_builder_property *prop = NULL;
/* Check if the property was set earlier. */
- for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->properties); ++i) {
if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PATH)
prop = &(test->properties[i]);
}
@@ -9498,7 +9498,7 @@ static void test_IUriBuilder_GetQuery(IUriBuilder *builder, const uri_builder_te
const uri_builder_property *prop = NULL;
/* Check if the property was set earlier. */
- for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->properties); ++i) {
if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_QUERY)
prop = &(test->properties[i]);
}
@@ -9593,7 +9593,7 @@ static void test_IUriBuilder_GetSchemeName(IUriBuilder *builder, const uri_build
const uri_builder_property *prop = NULL;
/* Check if the property was set earlier. */
- for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->properties); ++i) {
if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_SCHEME_NAME)
prop = &(test->properties[i]);
}
@@ -9688,7 +9688,7 @@ static void test_IUriBuilder_GetUserName(IUriBuilder *builder, const uri_builder
const uri_builder_property *prop = NULL;
/* Check if the property was set earlier. */
- for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->properties); ++i) {
if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_USER_NAME)
prop = &(test->properties[i]);
}
@@ -9780,7 +9780,7 @@ static void test_IUriBuilder(void) {
IUriBuilder *builder;
DWORD i;
- for(i = 0; i < sizeof(uri_builder_tests)/sizeof(uri_builder_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_builder_tests); ++i) {
IUri *uri = NULL;
uri_builder_test test = uri_builder_tests[i];
LPWSTR uriW = NULL;
@@ -10132,7 +10132,7 @@ static void test_IUriBuilder_RemoveProperties(void) {
}
if(builder) IUriBuilder_Release(builder);
- for(i = 0; i < sizeof(uri_builder_remove_tests)/sizeof(uri_builder_remove_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_builder_remove_tests); ++i) {
uri_builder_remove_test test = uri_builder_remove_tests[i];
IUri *uri = NULL;
LPWSTR uriW;
@@ -10328,7 +10328,7 @@ static void test_CoInternetCombineIUri(void) {
if(base) IUri_Release(base);
if(relative) IUri_Release(relative);
- for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_combine_tests); ++i) {
LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
@@ -10349,7 +10349,7 @@ static void test_CoInternetCombineIUri(void) {
if(SUCCEEDED(hr)) {
DWORD j;
- for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
+ for(j = 0; j < ARRAY_SIZE(uri_combine_tests[i].str_props); ++j) {
uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
BSTR received;
@@ -10366,7 +10366,7 @@ static void test_CoInternetCombineIUri(void) {
SysFreeString(received);
}
- for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
+ for(j = 0; j < ARRAY_SIZE(uri_combine_tests[i].dword_props); ++j) {
uri_dword_property prop = uri_combine_tests[i].dword_props[j];
DWORD received;
@@ -10619,7 +10619,7 @@ static void test_CoInternetCombineUrlEx(void) {
hr, E_POINTER);
if(base) IUri_Release(base);
- for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_combine_tests); ++i) {
LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
@@ -10636,7 +10636,7 @@ static void test_CoInternetCombineUrlEx(void) {
if(SUCCEEDED(hr)) {
DWORD j;
- for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
+ for(j = 0; j < ARRAY_SIZE(uri_combine_tests[i].str_props); ++j) {
uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
BSTR received;
LPCSTR value = (prop.value_ex) ? prop.value_ex : prop.value;
@@ -10654,7 +10654,7 @@ static void test_CoInternetCombineUrlEx(void) {
SysFreeString(received);
}
- for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
+ for(j = 0; j < ARRAY_SIZE(uri_combine_tests[i].dword_props); ++j) {
uri_dword_property prop = uri_combine_tests[i].dword_props[j];
DWORD received;
@@ -10776,7 +10776,7 @@ static void test_CoInternetParseIUri_InvalidArgs(void) {
len = INTERNET_MAX_URL_LENGTH*2;
longurl = heap_alloc((len+1)*sizeof(WCHAR));
memcpy(longurl, http_urlW, sizeof(http_urlW));
- for(i = sizeof(http_urlW)/sizeof(WCHAR)-1; i < len; i++)
+ for(i = ARRAY_SIZE(http_urlW)-1; i < len; i++)
longurl[i] = 'x';
longurl[len] = 0;
@@ -10803,7 +10803,7 @@ static void test_CoInternetParseIUri_InvalidArgs(void) {
static void test_CoInternetParseIUri(void) {
DWORD i;
- for(i = 0; i < sizeof(uri_parse_tests)/sizeof(uri_parse_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_parse_tests); ++i) {
HRESULT hr;
IUri *uri;
LPWSTR uriW;
@@ -11001,7 +11001,7 @@ static void test_CreateURLMoniker(void)
IUri *uri, *base_uri;
HRESULT hres;
- for(test = create_urlmon_tests; test < create_urlmon_tests + sizeof(create_urlmon_tests)/sizeof(*create_urlmon_tests); test++) {
+ for(test = create_urlmon_tests; test < create_urlmon_tests + ARRAY_SIZE(create_urlmon_tests); test++) {
url = a2w(test->url);
base_url = a2w(test->base_url);
@@ -11100,7 +11100,7 @@ static void test_IPersistStream(void)
props_order[Uri_PROPERTY_SCHEME_NAME] = 8;
props_order[Uri_PROPERTY_USER_NAME] = 9;
- for(i=0; i<sizeof(uri_tests)/sizeof(*uri_tests); i++) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); i++) {
const uri_properties *test = uri_tests+i;
LPWSTR uriW;
IUri *uri;
diff --git a/dlls/urlmon/tests/url.c b/dlls/urlmon/tests/url.c
index 8da0fd8256..893632fd2e 100644
--- a/dlls/urlmon/tests/url.c
+++ b/dlls/urlmon/tests/url.c
@@ -2901,7 +2901,7 @@ static void init_bind_test(int protocol, DWORD flags, DWORD t)
}
if(url_a)
- MultiByteToWideChar(CP_ACP, 0, url_a, -1, current_url, sizeof(current_url)/sizeof(*current_url));
+ MultiByteToWideChar(CP_ACP, 0, url_a, -1, current_url, ARRAY_SIZE(current_url));
test_redirect = (flags & BINDTEST_REDIRECT) != 0;
use_cache_file = (flags & BINDTEST_USE_CACHE) != 0;
--
2.14.4
June 14, 2018
[PATCH] shell32/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/shell32/tests/autocomplete.c | 4 ++--
dlls/shell32/tests/shelldispatch.c | 14 +++++++-------
dlls/shell32/tests/shelllink.c | 2 +-
dlls/shell32/tests/shellole.c | 2 +-
dlls/shell32/tests/shellpath.c | 4 ++--
dlls/shell32/tests/shlexec.c | 14 +++++++-------
dlls/shell32/tests/string.c | 8 ++++----
7 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/dlls/shell32/tests/autocomplete.c b/dlls/shell32/tests/autocomplete.c
index 859734ce59..1c51e5179f 100644
--- a/dlls/shell32/tests/autocomplete.c
+++ b/dlls/shell32/tests/autocomplete.c
@@ -369,7 +369,7 @@ static void test_custom_source(void)
hr = CoCreateInstance(&CLSID_AutoComplete, NULL, CLSCTX_INPROC_SERVER, &IID_IAutoComplete2, (void**)&autocomplete);
ok(hr == S_OK, "CoCreateInstance failed: %x\n", hr);
- string_enumerator_create((void**)&enumerator, suggestions, sizeof(suggestions) / sizeof(*suggestions));
+ string_enumerator_create((void**)&enumerator, suggestions, ARRAY_SIZE(suggestions));
hr = IAutoComplete2_SetOptions(autocomplete, ACO_AUTOSUGGEST | ACO_AUTOAPPEND);
ok(hr == S_OK, "IAutoComplete2_SetOptions failed: %x\n", hr);
@@ -385,7 +385,7 @@ static void test_custom_source(void)
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
- SendMessageW(hwnd_edit, WM_GETTEXT, sizeof(buffer) / sizeof(*buffer), (LPARAM)buffer);
+ SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer);
ok(lstrcmpW(str_beta, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str_beta), wine_dbgstr_w(buffer));
ShowWindow(hMainWnd, SW_HIDE);
diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c
index ed109a9e17..30c8291f58 100644
--- a/dlls/shell32/tests/shelldispatch.c
+++ b/dlls/shell32/tests/shelldispatch.c
@@ -161,7 +161,7 @@ static void test_namespace(void)
ok(folder == NULL, "expected NULL, got %p\n", folder);
/* test valid folder ids */
- for (i = 0; i < sizeof(special_folders)/sizeof(special_folders[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(special_folders); i++)
{
V_VT(&var) = VT_I4;
V_I4(&var) = special_folders[i];
@@ -474,7 +474,7 @@ static void test_items(void)
ok(!item, "item is not null\n");
/* create test files */
- for (i = 0; i < sizeof(file_defs)/sizeof(file_defs[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(file_defs); i++)
{
switch (file_defs[i].type)
{
@@ -605,7 +605,7 @@ static void test_items(void)
V_VT(&int_index) = VT_I4;
/* test the folder item corresponding to each file */
- for (i = 0; i < sizeof(file_defs)/sizeof(file_defs[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(file_defs); i++)
{
VARIANT_BOOL b;
BSTR name;
@@ -729,7 +729,7 @@ static void test_items(void)
}
/* test that there are only as many folder items as there were files */
- V_I4(&int_index) = sizeof(file_defs)/sizeof(file_defs[0]);
+ V_I4(&int_index) = ARRAY_SIZE(file_defs);
item = (FolderItem*)0xdeadbeef;
r = FolderItems_Item(items, int_index, &item);
ok(r == S_FALSE, "expected S_FALSE, got %08x\n", r);
@@ -975,7 +975,7 @@ if (0) /* crashes on pre-vista */ {
IShellView_Release(view);
/* Try with some other folder, that's not a desktop */
- GetTempPathW(sizeof(pathW)/sizeof(pathW[0]), pathW);
+ GetTempPathW(ARRAY_SIZE(pathW), pathW);
hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, pathW, NULL, &pidl, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -1218,7 +1218,7 @@ static void test_ParseName(void)
&IID_IShellDispatch, (void**)&sd);
ok(hr == S_OK, "got 0x%08x\n", hr);
- GetTempPathW(sizeof(pathW)/sizeof(pathW[0]), pathW);
+ GetTempPathW(ARRAY_SIZE(pathW), pathW);
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = SysAllocString(pathW);
hr = IShellDispatch_NameSpace(sd, v, &folder);
@@ -1287,7 +1287,7 @@ static void test_Verbs(void)
&IID_IShellDispatch, (void**)&sd);
ok(hr == S_OK, "got 0x%08x\n", hr);
- GetTempPathW(sizeof(pathW)/sizeof(pathW[0]), pathW);
+ GetTempPathW(ARRAY_SIZE(pathW), pathW);
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = SysAllocString(pathW);
hr = IShellDispatch_NameSpace(sd, v, &folder);
diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c
index 1e07090dc4..65e9a6dd55 100644
--- a/dlls/shell32/tests/shelllink.c
+++ b/dlls/shell32/tests/shelllink.c
@@ -1287,7 +1287,7 @@ if (0)
ok(hicon == NULL, "Got icon %p\n", hicon);
/* Create a temporary non-executable file */
- GetTempPathW(sizeof(pathW)/sizeof(pathW[0]), pathW);
+ GetTempPathW(ARRAY_SIZE(pathW), pathW);
lstrcatW(pathW, nameW);
file = CreateFileW(pathW, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
ok(file != INVALID_HANDLE_VALUE, "Failed to create a test file\n");
diff --git a/dlls/shell32/tests/shellole.c b/dlls/shell32/tests/shellole.c
index 4144f18155..4b91302a15 100644
--- a/dlls/shell32/tests/shellole.c
+++ b/dlls/shell32/tests/shellole.c
@@ -869,7 +869,7 @@ static void test_SHCreateSessionKey(void)
HKEY hkey, hkey2;
HRESULT hr;
DWORD session;
- WCHAR sessionW[(sizeof(session_format)/sizeof(WCHAR)) + 16];
+ WCHAR sessionW[ARRAY_SIZE(session_format) + 16];
LONG ret;
if (!pSHCreateSessionKey)
diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c
index 613c4eb15d..505da2778e 100644
--- a/dlls/shell32/tests/shellpath.c
+++ b/dlls/shell32/tests/shellpath.c
@@ -114,7 +114,7 @@ static const BYTE printersType[] = { PT_YAGUID, PT_SHELLEXT, 0x71 };
static const BYTE ieSpecialType[] = { PT_IESPECIAL2 };
static const BYTE shellExtType[] = { PT_SHELLEXT };
static const BYTE workgroupType[] = { PT_WORKGRP };
-#define DECLARE_TYPE(x, y) { x, sizeof(y) / sizeof(y[0]), y }
+#define DECLARE_TYPE(x, y) { x, ARRAY_SIZE(y), y }
static const struct shellExpectedValues requiredShellValues[] = {
DECLARE_TYPE(CSIDL_BITBUCKET, guidType),
DECLARE_TYPE(CSIDL_CONTROLS, controlPanelType),
@@ -2545,7 +2545,7 @@ static void test_DoEnvironmentSubst(void)
"%HOMEDRIVE%%HOMEPATH%",
"%OS% %windir%"}; /* always the last entry in the table */
- for (i = 0; i < (sizeof(names)/sizeof(LPSTR)); i++)
+ for (i = 0; i < (ARRAY_SIZE(names)); i++)
{
memset(bufferA, '#', MAX_PATH - 1);
bufferA[MAX_PATH - 1] = 0;
diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
index 7cdae878db..c67cc46a46 100644
--- a/dlls/shell32/tests/shlexec.c
+++ b/dlls/shell32/tests/shlexec.c
@@ -758,7 +758,7 @@ static LSTATUS myRegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
dwMaxSubkeyLen++;
dwMaxValueLen++;
dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
- if (dwMaxLen > sizeof(szNameBuf)/sizeof(CHAR))
+ if (dwMaxLen > ARRAY_SIZE(szNameBuf))
{
/* Name too big: alloc a buffer for it */
if (!(lpszName = heap_alloc(dwMaxLen*sizeof(CHAR))))
@@ -1329,7 +1329,7 @@ static BOOL test_one_cmdline(const cmdline_tests_t* test)
int i, count;
/* trace("----- cmd='%s'\n", test->cmd); */
- MultiByteToWideChar(CP_ACP, 0, test->cmd, -1, cmdW, sizeof(cmdW)/sizeof(*cmdW));
+ MultiByteToWideChar(CP_ACP, 0, test->cmd, -1, cmdW, ARRAY_SIZE(cmdW));
argsW = cl2a = CommandLineToArgvW(cmdW, &cl2a_count);
if (argsW == NULL && cl2a_count == -1)
{
@@ -1349,7 +1349,7 @@ static BOOL test_one_cmdline(const cmdline_tests_t* test)
{
if (i < count)
{
- MultiByteToWideChar(CP_ACP, 0, test->args[i], -1, argW, sizeof(argW)/sizeof(*argW));
+ MultiByteToWideChar(CP_ACP, 0, test->args[i], -1, argW, ARRAY_SIZE(argW));
todo_wine_if(test->todo & (1 << (i+4)))
ok(!lstrcmpW(*argsW, argW), "%s: arg[%d] expected %s but got %s\n", test->cmd, i, wine_dbgstr_w(argW), wine_dbgstr_w(*argsW));
}
@@ -1395,7 +1395,7 @@ static void test_commandline2argv(void)
"expected NULL-terminated list of commandline arguments\n");
if (numargs == 1)
{
- GetModuleFileNameW(NULL, strW, sizeof(strW)/sizeof(*strW));
+ GetModuleFileNameW(NULL, strW, ARRAY_SIZE(strW));
ok(!lstrcmpW(args[0], strW), "wrong path to the current executable: %s instead of %s\n", wine_dbgstr_w(args[0]), wine_dbgstr_w(strW));
}
if (args) LocalFree(args);
@@ -1859,7 +1859,7 @@ static void test_fileurls(void)
return;
}
- get_long_path_name(tmpdir, longtmpdir, sizeof(longtmpdir)/sizeof(*longtmpdir));
+ get_long_path_name(tmpdir, longtmpdir, ARRAY_SIZE(longtmpdir));
SetEnvironmentVariableA("urlprefix", "file:///");
test=fileurl_tests;
@@ -2779,7 +2779,7 @@ static void init_test(void)
/* Setup the test shortcuts */
sprintf(filename, "%s\\test_shortcut_shlexec.lnk", tmpdir);
- MultiByteToWideChar(CP_ACP, 0, filename, -1, lnkfile, sizeof(lnkfile)/sizeof(*lnkfile));
+ MultiByteToWideChar(CP_ACP, 0, filename, -1, lnkfile, ARRAY_SIZE(lnkfile));
desc.description=NULL;
desc.workdir=NULL;
sprintf(filename, "%s\\test file.shlexec", tmpdir);
@@ -2793,7 +2793,7 @@ static void init_test(void)
create_lnk(lnkfile, &desc, 0);
sprintf(filename, "%s\\test_shortcut_exe.lnk", tmpdir);
- MultiByteToWideChar(CP_ACP, 0, filename, -1, lnkfile, sizeof(lnkfile)/sizeof(*lnkfile));
+ MultiByteToWideChar(CP_ACP, 0, filename, -1, lnkfile, ARRAY_SIZE(lnkfile));
desc.description=NULL;
desc.workdir=NULL;
desc.path=argv0;
diff --git a/dlls/shell32/tests/string.c b/dlls/shell32/tests/string.c
index 6cdb386eba..5fd589300b 100644
--- a/dlls/shell32/tests/string.c
+++ b/dlls/shell32/tests/string.c
@@ -67,14 +67,14 @@ static void test_StrRetToStringNW(void)
strret.uType = STRRET_WSTR;
U(strret).pOleStr = CoDupStrW("Test");
memset(buff, 0xff, sizeof(buff));
- ret = pStrRetToStrNAW(buff, sizeof(buff)/sizeof(WCHAR), &strret, NULL);
+ ret = pStrRetToStrNAW(buff, ARRAY_SIZE(buff), &strret, NULL);
ok(ret == TRUE && !strcmpW(buff, szTestW),
"STRRET_WSTR: dup failed, ret=%d\n", ret);
strret.uType = STRRET_CSTR;
lstrcpyA(U(strret).cStr, "Test");
memset(buff, 0xff, sizeof(buff));
- ret = pStrRetToStrNAW(buff, sizeof(buff)/sizeof(WCHAR), &strret, NULL);
+ ret = pStrRetToStrNAW(buff, ARRAY_SIZE(buff), &strret, NULL);
ok(ret == TRUE && !strcmpW(buff, szTestW),
"STRRET_CSTR: dup failed, ret=%d\n", ret);
@@ -82,7 +82,7 @@ static void test_StrRetToStringNW(void)
U(strret).uOffset = 1;
strcpy((char*)&iidl, " Test");
memset(buff, 0xff, sizeof(buff));
- ret = pStrRetToStrNAW(buff, sizeof(buff)/sizeof(WCHAR), &strret, iidl);
+ ret = pStrRetToStrNAW(buff, ARRAY_SIZE(buff), &strret, iidl);
ok(ret == TRUE && !strcmpW(buff, szTestW),
"STRRET_OFFSET: dup failed, ret=%d\n", ret);
@@ -92,7 +92,7 @@ if (0)
/* Invalid dest - should return FALSE, except NT4 does not, so we don't check. */
strret.uType = STRRET_WSTR;
U(strret).pOleStr = CoDupStrW("Test");
- pStrRetToStrNAW(NULL, sizeof(buff)/sizeof(WCHAR), &strret, NULL);
+ pStrRetToStrNAW(NULL, ARRAY_SIZE(buff), &strret, NULL);
trace("NULL dest: ret=%d\n", ret);
}
}
--
2.14.4
June 14, 2018
[PATCH] shell32/tests: Avoid sizeof in a trace
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/shell32/tests/shelldispatch.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c
index cc00757840..ed109a9e17 100644
--- a/dlls/shell32/tests/shelldispatch.c
+++ b/dlls/shell32/tests/shelldispatch.c
@@ -541,8 +541,7 @@ static void test_items(void)
count = -1;
r = FolderItems_get_Count(items, &count);
ok(r == S_OK, "FolderItems::get_Count failed: %08x\n", r);
- ok(count == sizeof(file_defs)/sizeof(file_defs[0]),
- "expected %d files, got %d\n", (LONG)(sizeof(file_defs)/sizeof(file_defs[0])), count);
+ ok(count == ARRAY_SIZE(file_defs), "got %d files\n", count);
V_VT(&var) = VT_EMPTY;
item = (FolderItem*)0xdeadbeef;
--
2.14.4
June 14, 2018
[PATCH] setupapi/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/setupapi/tests/devinst.c | 4 ++--
dlls/setupapi/tests/misc.c | 4 ++--
dlls/setupapi/tests/parser.c | 8 ++++----
dlls/setupapi/tests/setupcab.c | 20 +++++++++-----------
4 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c
index 4df00b1855..420c65a142 100644
--- a/dlls/setupapi/tests/devinst.c
+++ b/dlls/setupapi/tests/devinst.c
@@ -121,7 +121,7 @@ static LSTATUS devinst_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
dwMaxSubkeyLen++;
dwMaxValueLen++;
dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
- if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
+ if (dwMaxLen > ARRAY_SIZE(szNameBuf))
{
/* Name too big: alloc a buffer for it */
if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
@@ -1259,7 +1259,7 @@ static void testSetupDiGetINFClassA(void)
retval = SetupDiGetINFClassA(filename, &guid, cn, MAX_PATH, &count);
ok(!retval, "expected SetupDiGetINFClassA to fail!\n");
- for(i=0; i < sizeof(signatures)/sizeof(char*); i++)
+ for(i=0; i < ARRAY_SIZE(signatures); i++)
{
trace("testing signature %s\n", signatures[i]);
h = CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
diff --git a/dlls/setupapi/tests/misc.c b/dlls/setupapi/tests/misc.c
index dbe684bb29..9143cd4bd3 100644
--- a/dlls/setupapi/tests/misc.c
+++ b/dlls/setupapi/tests/misc.c
@@ -594,7 +594,7 @@ static void test_SetupDecompressOrCopyFile(void)
create_source_file(source, uncompressed, sizeof(uncompressed));
- for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
{
type = FILE_COMPRESSION_NONE;
ret = SetupDecompressOrCopyFileA(invalid_parameters[i].source,
@@ -697,7 +697,7 @@ static void test_SetupDecompressOrCopyFile(void)
p = strrchr(target, '\\');
- for (i = 0; i < sizeof(zip_multi_tests)/sizeof(zip_multi_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(zip_multi_tests); i++)
{
lstrcpyA(p + 1, zip_multi_tests[i].filename);
diff --git a/dlls/setupapi/tests/parser.c b/dlls/setupapi/tests/parser.c
index 67c9887a61..f8d2c5de1c 100644
--- a/dlls/setupapi/tests/parser.c
+++ b/dlls/setupapi/tests/parser.c
@@ -154,7 +154,7 @@ static void test_invalid_files(void)
HINF hinf;
DWORD err;
- for (i = 0; i < sizeof(invalid_files)/sizeof(invalid_files[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(invalid_files); i++)
{
SetLastError( 0xdeadbeef );
err_line = 0xdeadbeef;
@@ -229,7 +229,7 @@ static void test_section_names(void)
DWORD err;
LONG ret;
- for (i = 0; i < sizeof(section_names)/sizeof(section_names[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(section_names); i++)
{
SetLastError( 0xdeadbeef );
hinf = test_file_contents( section_names[i].data, &err_line );
@@ -418,7 +418,7 @@ static void test_key_names(void)
BOOL ret;
INFCONTEXT context;
- for (i = 0; i < sizeof(key_names)/sizeof(key_names[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(key_names); i++)
{
strcpy( buffer, STD_HEADER "[Test]\n" );
strcat( buffer, key_names[i].data );
@@ -622,7 +622,7 @@ static void test_SetupGetIntField(void)
};
unsigned int i;
- for (i = 0; i < sizeof(keys)/sizeof(keys[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(keys); i++)
{
HINF hinf;
char buffer[MAX_INF_STRING_LENGTH];
diff --git a/dlls/setupapi/tests/setupcab.c b/dlls/setupapi/tests/setupcab.c
index 33daae922b..bb9add035d 100644
--- a/dlls/setupapi/tests/setupcab.c
+++ b/dlls/setupapi/tests/setupcab.c
@@ -109,7 +109,7 @@ static void test_invalid_parametersA(void)
create_source_fileA(source, NULL, 0);
- for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
{
SetLastError(0xdeadbeef);
ret = SetupIterateCabinetA(invalid_parameters[i].CabinetFile, 0,
@@ -170,12 +170,12 @@ static void test_invalid_parametersW(void)
return;
}
- GetTempPathW(sizeof(temp)/sizeof(WCHAR), temp);
+ GetTempPathW(ARRAY_SIZE(temp), temp);
GetTempFileNameW(temp, docW, 0, source);
create_source_fileW(source, NULL, 0);
- for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
{
SetLastError(0xdeadbeef);
ret = SetupIterateCabinetW(invalid_parameters[i].CabinetFile, 0,
@@ -275,7 +275,7 @@ static void test_invalid_callbackW(void)
return;
}
- GetTempPathW(sizeof(temp)/sizeof(WCHAR), temp);
+ GetTempPathW(ARRAY_SIZE(temp), temp);
GetTempFileNameW(temp, docW, 0, source);
create_source_fileW(source, comp_cab_zip_multi, sizeof(comp_cab_zip_multi));
@@ -316,7 +316,7 @@ static UINT CALLBACK simple_callbackA(PVOID Context, UINT Notification,
(*file_count)++;
- if (index < sizeof(expected_files)/sizeof(char *))
+ if (index < ARRAY_SIZE(expected_files))
{
ok(!strcmp(expected_files[index], info->NameInCabinet),
"[%d] Expected file \"%s\", got \"%s\"\n",
@@ -348,8 +348,7 @@ static void test_simple_enumerationA(void)
ret = SetupIterateCabinetA(source, 0, simple_callbackA, &enum_count);
ok(ret == 1, "Expected SetupIterateCabinetA to return 1, got %d\n", ret);
- ok(enum_count == sizeof(expected_files)/sizeof(char *),
- "Unexpectedly enumerated %d files\n", enum_count);
+ ok(enum_count == ARRAY_SIZE(expected_files), "Unexpectedly enumerated %d files\n", enum_count);
DeleteFileA(source);
}
@@ -376,7 +375,7 @@ static UINT CALLBACK simple_callbackW(PVOID Context, UINT Notification,
(*file_count)++;
- if (index < sizeof(expected_filesW)/sizeof(WCHAR *))
+ if (index < ARRAY_SIZE(expected_filesW))
{
ok(!lstrcmpW(expected_filesW[index], info->NameInCabinet),
"[%d] Expected file %s, got %s\n",
@@ -408,15 +407,14 @@ static void test_simple_enumerationW(void)
return;
}
- GetTempPathW(sizeof(temp)/sizeof(WCHAR), temp);
+ GetTempPathW(ARRAY_SIZE(temp), temp);
GetTempFileNameW(temp, docW, 0, source);
create_source_fileW(source, comp_cab_zip_multi, sizeof(comp_cab_zip_multi));
ret = SetupIterateCabinetW(source, 0, simple_callbackW, &enum_count);
ok(ret == 1, "Expected SetupIterateCabinetW to return 1, got %d\n", ret);
- ok(enum_count == sizeof(expected_files)/sizeof(WCHAR *),
- "Unexpectedly enumerated %d files\n", enum_count);
+ ok(enum_count == ARRAY_SIZE(expected_files), "Unexpectedly enumerated %d files\n", enum_count);
DeleteFileW(source);
}
--
2.14.4
June 14, 2018
[PATCH] winedbg/gdbproxy: Handle VS thread renaming.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
programs/winedbg/gdbproxy.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c
index 869d56b..7f59ce1 100644
--- a/programs/winedbg/gdbproxy.c
+++ b/programs/winedbg/gdbproxy.c
@@ -339,6 +339,30 @@ static BOOL handle_exception(struct gdb_context* gdbctx, EXCEPTION_DEBUG_INFO* e
ret = TRUE;
/* FIXME: we could also add here a O packet with additional information */
break;
+ case EXCEPTION_NAME_THREAD:
+ {
+ const THREADNAME_INFO *threadname = (const THREADNAME_INFO *)rec->ExceptionInformation;
+ struct dbg_thread *thread;
+ char name[9];
+ SIZE_T read;
+
+ if (threadname->dwThreadID == -1)
+ thread = dbg_curr_thread;
+ else
+ thread = dbg_get_thread(gdbctx->process, threadname->dwThreadID);
+ if (thread)
+ {
+ if (gdbctx->process->process_io->read( gdbctx->process->handle,
+ threadname->szName, name, sizeof(name), &read) && read == sizeof(name))
+ {
+ fprintf(stderr, "Thread ID=%04x renamed to \"%.9s\"\n",
+ threadname->dwThreadID, name);
+ }
+ }
+ else
+ fprintf(stderr, "Cannot set name of thread %04x\n", threadname->dwThreadID);
+ return DBG_CONTINUE;
+ }
default:
if (gdbctx->trace & GDBPXY_TRC_WIN32_EVENT)
fprintf(stderr, "Unhandled exception code 0x%08x\n", rec->ExceptionCode);
--
2.7.4
June 14, 2018
[PATCH 6/6] dbghelp: Read the stabs nlist entry corresponding to the target's architecture.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/dbghelp/dbghelp_private.h | 2 +-
dlls/dbghelp/macho_module.c | 16 +++------
dlls/dbghelp/stabs.c | 73 ++++++++++++++++++++++++------------------
3 files changed, 47 insertions(+), 44 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index 0963f1e..76f5d00 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -676,7 +676,7 @@ typedef void (*stabs_def_cb)(struct module* module, unsigned long load_offset,
BOOL is_public, BOOL is_global, unsigned char other,
struct symt_compiland* compiland, void* user);
extern BOOL stabs_parse(struct module* module, unsigned long load_offset,
- const void* stabs, int stablen,
+ const char* stabs, int stablen,
const char* strs, int strtablen,
stabs_def_cb callback, void* user) DECLSPEC_HIDDEN;
diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c
index b8f5967..52c8e69 100644
--- a/dlls/dbghelp/macho_module.c
+++ b/dlls/dbghelp/macho_module.c
@@ -88,13 +88,6 @@ struct dyld_all_image_infos {
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_macho);
-#ifdef _WIN64
-typedef struct nlist_64 macho_nlist;
-#else
-typedef struct nlist macho_nlist;
-#endif
-
-
/* Bitmask for Mach-O image header flags indicating that the image is in dyld's
shared cached. That implies that its segments are mapped non-contiguously.
This value isn't defined anywhere in headers. It's used in dyld and in
@@ -913,24 +906,25 @@ static int macho_parse_symtab(struct image_file_map* ifm,
struct macho_file_map* fmap = &ifm->u.macho;
const struct symtab_command* sc = (const struct symtab_command*)lc;
struct macho_debug_info* mdi = user;
- const macho_nlist* stab;
const char* stabstr;
int ret = 0;
+ size_t stabsize = (ifm->addr_size == 32) ? sizeof(struct nlist) : sizeof(struct nlist_64);
+ const char *stab;
TRACE("(%p/%d, %p, %p) %u syms at 0x%08x, strings 0x%08x - 0x%08x\n", fmap, fmap->fd, lc,
user, sc->nsyms, sc->symoff, sc->stroff, sc->stroff + sc->strsize);
- if (!macho_map_ranges(fmap, sc->symoff, sc->nsyms * sizeof(macho_nlist),
+ if (!macho_map_ranges(fmap, sc->symoff, sc->nsyms * stabsize,
sc->stroff, sc->strsize, (const void**)&stab, (const void**)&stabstr))
return 0;
if (!stabs_parse(mdi->module,
mdi->module->format_info[DFI_MACHO]->u.macho_info->load_addr - fmap->segs_start,
- stab, sc->nsyms * sizeof(macho_nlist),
+ stab, sc->nsyms * stabsize,
stabstr, sc->strsize, macho_stabs_def_cb, mdi))
ret = -1;
- macho_unmap_ranges(fmap, sc->symoff, sc->nsyms * sizeof(macho_nlist),
+ macho_unmap_ranges(fmap, sc->symoff, sc->nsyms * stabsize,
sc->stroff, sc->strsize, (const void**)&stab, (const void**)&stabstr);
return ret;
diff --git a/dlls/dbghelp/stabs.c b/dlls/dbghelp/stabs.c
index 177c6bc..846a935 100644
--- a/dlls/dbghelp/stabs.c
+++ b/dlls/dbghelp/stabs.c
@@ -41,6 +41,7 @@
#include <sys/mman.h>
#endif
#include <limits.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
@@ -111,11 +112,7 @@ struct stab_nlist
unsigned char n_type;
char n_other;
short n_desc;
-#if defined(__APPLE__) && defined(_WIN64)
- unsigned long n_value;
-#else
unsigned n_value;
-#endif
};
static void stab_strcpy(char* dest, int sz, const char* source)
@@ -1265,7 +1262,7 @@ static inline void stabbuf_append(char **buf, unsigned *buf_size, const char *st
}
BOOL stabs_parse(struct module* module, unsigned long load_offset,
- const void* pv_stab_ptr, int stablen,
+ const char* pv_stab_ptr, int stablen,
const char* strs, int strtablen,
stabs_def_cb callback, void* user)
{
@@ -1278,7 +1275,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
const char* ptr;
char* stabbuff;
unsigned int stabbufflen;
- const struct stab_nlist* stab_ptr = pv_stab_ptr;
+ const struct stab_nlist* stab_ptr;
const char* strs_end;
int strtabinc;
char symname[4096];
@@ -1290,8 +1287,14 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
BOOL ret = TRUE;
struct location loc;
unsigned char type;
+ size_t stabsize = sizeof(struct stab_nlist);
+ uint64_t n_value;
- nstab = stablen / sizeof(struct stab_nlist);
+#ifdef __APPLE__
+ if (module->process->is_64bit)
+ stabsize = sizeof(struct nlist_64);
+#endif
+ nstab = stablen / stabsize;
strs_end = strs + strtablen;
memset(stabs_basic, 0, sizeof(stabs_basic));
@@ -1307,8 +1310,14 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
strtabinc = 0;
stabbuff[0] = '\0';
- for (i = 0; i < nstab; i++, stab_ptr++)
+ for (i = 0; i < nstab; i++)
{
+ stab_ptr = (struct stab_nlist *)(pv_stab_ptr + i * stabsize);
+ n_value = stab_ptr->n_value;
+#ifdef __APPLE__
+ if (module->process->is_64bit)
+ n_value = ((struct nlist_64 *)stab_ptr)->n_value;
+#endif
ptr = strs + stab_ptr->n_strx;
if ((ptr > strs_end) || (ptr + strlen(ptr) > strs_end))
{
@@ -1382,7 +1391,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
stab_strcpy(symname, sizeof(symname), ptr);
loc.kind = loc_absolute;
loc.reg = 0;
- loc.offset = load_offset + stab_ptr->n_value;
+ loc.offset = load_offset + n_value;
symt_new_global_variable(module, compiland, symname, TRUE /* FIXME */,
loc, 0, stabs_parse_type(ptr));
break;
@@ -1392,7 +1401,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
stab_strcpy(symname, sizeof(symname), ptr);
loc.kind = loc_absolute;
loc.reg = 0;
- loc.offset = load_offset + stab_ptr->n_value;
+ loc.offset = load_offset + n_value;
symt_new_global_variable(module, compiland, symname, TRUE /* FIXME */,
loc, 0, stabs_parse_type(ptr));
break;
@@ -1400,14 +1409,14 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
if (curr_func)
{
block = symt_open_func_block(module, curr_func, block,
- stab_ptr->n_value, 0);
+ n_value, 0);
pending_flush(&pending_block, module, curr_func, block);
}
break;
case N_RBRAC:
if (curr_func)
block = symt_close_func_block(module, curr_func, block,
- stab_ptr->n_value);
+ n_value);
break;
case N_PSYM:
/* These are function parameters. */
@@ -1417,9 +1426,9 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
stab_strcpy(symname, sizeof(symname), ptr);
loc.kind = loc_regrel;
loc.reg = dbghelp_current_cpu->frame_regno;
- loc.offset = stab_ptr->n_value;
+ loc.offset = n_value;
symt_add_func_local(module, curr_func,
- (int)stab_ptr->n_value >= 0 ? DataIsParam : DataIsLocal,
+ (int)n_value >= 0 ? DataIsParam : DataIsLocal,
&loc, NULL, param_type, symname);
symt_add_function_signature_parameter(module,
(struct symt_function_signature*)curr_func->type,
@@ -1433,7 +1442,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
loc.kind = loc_register;
loc.offset = 0;
- switch (stab_ptr->n_value)
+ switch (n_value)
{
case 0: loc.reg = CV_REG_EAX; break;
case 1: loc.reg = CV_REG_ECX; break;
@@ -1451,7 +1460,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
case 16:
case 17:
case 18:
- case 19: loc.reg = CV_REG_ST0 + stab_ptr->n_value - 12; break;
+ case 19: loc.reg = CV_REG_ST0 + n_value - 12; break;
case 21:
case 22:
case 23:
@@ -1459,7 +1468,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
case 25:
case 26:
case 27:
- case 28: loc.reg = CV_REG_XMM0 + stab_ptr->n_value - 21; break;
+ case 28: loc.reg = CV_REG_XMM0 + n_value - 21; break;
case 29:
case 30:
case 31:
@@ -1467,9 +1476,9 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
case 33:
case 34:
case 35:
- case 36: loc.reg = CV_REG_MM0 + stab_ptr->n_value - 29; break;
+ case 36: loc.reg = CV_REG_MM0 + n_value - 29; break;
default:
- FIXME("Unknown register value (%lu)\n", (unsigned long)stab_ptr->n_value);
+ FIXME("Unknown register value (%lu)\n", (unsigned long)n_value);
loc.reg = CV_REG_NONE;
break;
}
@@ -1492,7 +1501,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
/* These are local variables */
loc.kind = loc_regrel;
loc.reg = dbghelp_current_cpu->frame_regno;
- loc.offset = stab_ptr->n_value;
+ loc.offset = n_value;
if (curr_func != NULL) pending_add_var(&pending_block, ptr, DataIsLocal, &loc);
break;
case N_SLINE:
@@ -1503,14 +1512,14 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
assert(source_idx >= 0);
if (curr_func != NULL)
{
- unsigned long offset = stab_ptr->n_value;
+ unsigned long offset = n_value;
if (module->type == DMT_MACHO)
offset -= curr_func->address - load_offset;
symt_add_func_line(module, curr_func, source_idx,
stab_ptr->n_desc, offset);
}
else pending_add_line(&pending_func, source_idx, stab_ptr->n_desc,
- stab_ptr->n_value, load_offset);
+ n_value, load_offset);
break;
case N_FUN:
/*
@@ -1537,13 +1546,13 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
* and offset of last function
*/
stabs_finalize_function(module, curr_func,
- stab_ptr->n_value ?
- (load_offset + stab_ptr->n_value - curr_func->address) : 0);
+ n_value ?
+ (load_offset + n_value - curr_func->address) : 0);
}
func_type = symt_new_function_signature(module,
stabs_parse_type(ptr), -1);
curr_func = symt_new_function(module, compiland, symname,
- load_offset + stab_ptr->n_value, 0,
+ load_offset + n_value, 0,
&func_type->symt);
pending_flush(&pending_func, module, curr_func, NULL);
}
@@ -1552,7 +1561,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
/* some versions of GCC to use a N_FUN "" to mark the end of a function
* and n_value contains the size of the func
*/
- stabs_finalize_function(module, curr_func, stab_ptr->n_value);
+ stabs_finalize_function(module, curr_func, n_value);
curr_func = NULL;
}
break;
@@ -1594,7 +1603,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
break;
case N_UNDF:
strs += strtabinc;
- strtabinc = stab_ptr->n_value;
+ strtabinc = n_value;
/* I'm not sure this is needed, so trace it before we obsolete it */
if (curr_func)
{
@@ -1607,7 +1616,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
/* Ignore this. We don't care what it points to. */
break;
case N_BINCL:
- stabs_add_include(stabs_new_include(ptr, stab_ptr->n_value));
+ stabs_add_include(stabs_new_include(ptr, n_value));
assert(incl_stk < (int)(sizeof(incl) / sizeof(incl[0])) - 1);
incl[++incl_stk] = source_idx;
source_idx = source_new(module, NULL, ptr);
@@ -1617,9 +1626,9 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
source_idx = incl[incl_stk--];
break;
case N_EXCL:
- if (stabs_add_include(stabs_find_include(ptr, stab_ptr->n_value)) < 0)
+ if (stabs_add_include(stabs_find_include(ptr, n_value)) < 0)
{
- ERR("Excluded header not found (%s,%ld)\n", ptr, (unsigned long)stab_ptr->n_value);
+ ERR("Excluded header not found (%s,%ld)\n", ptr, (unsigned long)n_value);
module_reset_debug_info(module);
ret = FALSE;
goto done;
@@ -1656,7 +1665,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
if (*ptr == '_') ptr++;
stab_strcpy(symname, sizeof(symname), ptr);
- callback(module, load_offset, symname, stab_ptr->n_value,
+ callback(module, load_offset, symname, n_value,
is_public, is_global, stab_ptr->n_other, compiland, user);
}
break;
@@ -1666,7 +1675,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
}
stabbuff[0] = '\0';
TRACE("0x%02x %lx %s\n",
- stab_ptr->n_type, (unsigned long)stab_ptr->n_value, debugstr_a(strs + stab_ptr->n_strx));
+ stab_ptr->n_type, (unsigned long)n_value, debugstr_a(strs + stab_ptr->n_strx));
}
module->module.SymType = SymDia;
module->module.CVSig = 'S' | ('T' << 8) | ('A' << 16) | ('B' << 24);
--
2.7.4
June 14, 2018
[PATCH 5/6] dbghelp: Translate the 32-bit Mach-O section header to the 64-bit one.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/dbghelp/image_private.h | 8 +-------
dlls/dbghelp/macho_module.c | 43 +++++++++++++++++++++++++++++--------------
2 files changed, 30 insertions(+), 21 deletions(-)
diff --git a/dlls/dbghelp/image_private.h b/dlls/dbghelp/image_private.h
index 60cdd35..9990850 100644
--- a/dlls/dbghelp/image_private.h
+++ b/dlls/dbghelp/image_private.h
@@ -44,12 +44,6 @@
#endif
#ifdef HAVE_MACH_O_LOADER_H
#include <mach-o/loader.h>
-
-#ifdef _WIN64
-typedef struct section_64 macho_section;
-#else
-typedef struct section macho_section;
-#endif
#endif
#define IMAGE_NO_MAP ((void*)-1)
@@ -105,7 +99,7 @@ struct image_file_map
int num_sections;
struct
{
- const macho_section* section;
+ struct section_64 section;
const char* mapped;
unsigned int ignored : 1;
}* sect;
diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c
index 52ea739..b8f5967 100644
--- a/dlls/dbghelp/macho_module.c
+++ b/dlls/dbghelp/macho_module.c
@@ -328,7 +328,7 @@ BOOL macho_find_section(struct image_file_map* ifm, const char* segname, const c
{
struct macho_file_map* fmap;
unsigned i;
- char tmp[sizeof(fmap->sect[0].section->sectname)];
+ char tmp[sizeof(fmap->sect[0].section.sectname)];
/* Other parts of dbghelp use section names like ".eh_frame". Mach-O uses
names like "__eh_frame". Convert those. */
@@ -345,8 +345,8 @@ BOOL macho_find_section(struct image_file_map* ifm, const char* segname, const c
for (i = 0; i < fmap->num_sections; i++)
{
if (!fmap->sect[i].ignored &&
- strcmp(fmap->sect[i].section->sectname, sectname) == 0 &&
- (!segname || strcmp(fmap->sect[i].section->segname, segname) == 0))
+ strcmp(fmap->sect[i].section.sectname, sectname) == 0 &&
+ (!segname || strcmp(fmap->sect[i].section.segname, segname) == 0))
{
ism->fmap = ifm;
ism->sidx = i;
@@ -372,7 +372,7 @@ const char* macho_map_section(struct image_section_map* ism)
if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.macho.num_sections || fmap->sect[ism->sidx].ignored)
return IMAGE_NO_MAP;
- return macho_map_range(fmap, fmap->sect[ism->sidx].section->offset, fmap->sect[ism->sidx].section->size,
+ return macho_map_range(fmap, fmap->sect[ism->sidx].section.offset, fmap->sect[ism->sidx].section.size,
&fmap->sect[ism->sidx].mapped);
}
@@ -385,8 +385,8 @@ void macho_unmap_section(struct image_section_map* ism)
if (ism->sidx >= 0 && ism->sidx < fmap->num_sections && fmap->sect[ism->sidx].mapped != IMAGE_NO_MAP)
{
- macho_unmap_range(&fmap->sect[ism->sidx].mapped, NULL, fmap, fmap->sect[ism->sidx].section->offset,
- fmap->sect[ism->sidx].section->size);
+ macho_unmap_range(&fmap->sect[ism->sidx].mapped, NULL, fmap, fmap->sect[ism->sidx].section.offset,
+ fmap->sect[ism->sidx].section.size);
}
}
@@ -398,7 +398,7 @@ DWORD_PTR macho_get_map_rva(const struct image_section_map* ism)
if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.macho.num_sections ||
ism->fmap->u.macho.sect[ism->sidx].ignored)
return 0;
- return ism->fmap->u.macho.sect[ism->sidx].section->addr - ism->fmap->u.macho.segs_start;
+ return ism->fmap->u.macho.sect[ism->sidx].section.addr - ism->fmap->u.macho.segs_start;
}
/******************************************************************
@@ -409,7 +409,7 @@ unsigned macho_get_map_size(const struct image_section_map* ism)
if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.macho.num_sections ||
ism->fmap->u.macho.sect[ism->sidx].ignored)
return 0;
- return ism->fmap->u.macho.sect[ism->sidx].section->size;
+ return ism->fmap->u.macho.sect[ism->sidx].section.size;
}
/******************************************************************
@@ -539,12 +539,12 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load
struct macho_file_map* fmap = &ifm->u.macho;
struct section_info* info = user;
BOOL ignore;
- const macho_section* section;
int i;
unsigned long tmp, page_mask = sysconf( _SC_PAGESIZE ) - 1;
uint64_t vmaddr, vmsize;
char segname[16];
uint32_t nsects;
+ const void *sections;
if (ifm->addr_size == 32)
{
@@ -553,7 +553,7 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load
vmsize = sc->vmsize;
memcpy(segname, sc->segname, sizeof(segname));
nsects = sc->nsects;
- section = (const macho_section*)(sc + 1);
+ sections = (const void *)(sc + 1);
}
else
{
@@ -562,7 +562,7 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load
vmsize = sc->vmsize;
memcpy(segname, sc->segname, sizeof(segname));
nsects = sc->nsects;
- section = (const macho_section*)(sc + 1);
+ sections = (const void *)(sc + 1);
}
TRACE("(%p/%d, %p, %p) before: 0x%08lx - 0x%08lx\n", fmap, fmap->fd, lc, user,
@@ -596,7 +596,22 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load
for (i = 0; i < nsects; i++)
{
- fmap->sect[info->section_index].section = §ion[i];
+ if (ifm->addr_size == 32)
+ {
+ const struct section *section = &((const struct section *)sections)[i];
+ memcpy(fmap->sect[info->section_index].section.sectname, section->sectname, sizeof(section->sectname));
+ memcpy(fmap->sect[info->section_index].section.segname, section->segname, sizeof(section->segname));
+ fmap->sect[info->section_index].section.addr = section->addr;
+ fmap->sect[info->section_index].section.size = section->size;
+ fmap->sect[info->section_index].section.offset = section->offset;
+ fmap->sect[info->section_index].section.align = section->align;
+ fmap->sect[info->section_index].section.reloff = section->reloff;
+ fmap->sect[info->section_index].section.nreloc = section->nreloc;
+ fmap->sect[info->section_index].section.flags = section->flags;
+ }
+ else
+ fmap->sect[info->section_index].section = ((const struct section_64 *)sections)[i];
+
fmap->sect[info->section_index].mapped = IMAGE_NO_MAP;
fmap->sect[info->section_index].ignored = ignore;
info->section_index++;
@@ -831,8 +846,8 @@ static BOOL macho_sect_is_code(struct macho_file_map* fmap, unsigned char sectid
sectidx--; /* convert from 1-based to 0-based */
if (sectidx >= fmap->num_sections || fmap->sect[sectidx].ignored) return FALSE;
- ret = (!(fmap->sect[sectidx].section->flags & SECTION_TYPE) &&
- (fmap->sect[sectidx].section->flags & (S_ATTR_PURE_INSTRUCTIONS|S_ATTR_SOME_INSTRUCTIONS)));
+ ret = (!(fmap->sect[sectidx].section.flags & SECTION_TYPE) &&
+ (fmap->sect[sectidx].section.flags & (S_ATTR_PURE_INSTRUCTIONS|S_ATTR_SOME_INSTRUCTIONS)));
TRACE("-> %d\n", ret);
return ret;
}
--
2.7.4
June 14, 2018
[PATCH 4/6] dbghelp: Read the Mach-O segment command corresponding to the target's architecture.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/dbghelp/macho_module.c | 68 +++++++++++++++++++++++++++++++++------------
1 file changed, 50 insertions(+), 18 deletions(-)
diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c
index 50fcca4..52ea739 100644
--- a/dlls/dbghelp/macho_module.c
+++ b/dlls/dbghelp/macho_module.c
@@ -89,10 +89,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_macho);
#ifdef _WIN64
-typedef struct segment_command_64 macho_segment_command;
typedef struct nlist_64 macho_nlist;
#else
-typedef struct segment_command macho_segment_command;
typedef struct nlist macho_nlist;
#endif
@@ -506,12 +504,26 @@ static int macho_enum_load_commands(struct image_file_map *ifm, unsigned cmd,
*/
static int macho_count_sections(struct image_file_map* ifm, const struct load_command* lc, void* user)
{
- const macho_segment_command* sc = (const macho_segment_command*)lc;
+ char segname[16];
+ uint32_t nsects;
+
+ if (ifm->addr_size == 32)
+ {
+ const struct segment_command *sc = (const struct segment_command *)lc;
+ memcpy(segname, sc->segname, sizeof(segname));
+ nsects = sc->nsects;
+ }
+ else
+ {
+ const struct segment_command_64 *sc = (const struct segment_command_64 *)lc;
+ memcpy(segname, sc->segname, sizeof(segname));
+ nsects = sc->nsects;
+ }
TRACE("(%p/%d, %p, %p) segment %s\n", ifm, ifm->u.macho.fd, lc, user,
- debugstr_an(sc->segname, sizeof(sc->segname)));
+ debugstr_an(segname, sizeof(segname)));
- ifm->u.macho.num_sections += sc->nsects;
+ ifm->u.macho.num_sections += nsects;
return 0;
}
@@ -525,44 +537,64 @@ static int macho_count_sections(struct image_file_map* ifm, const struct load_co
static int macho_load_section_info(struct image_file_map* ifm, const struct load_command* lc, void* user)
{
struct macho_file_map* fmap = &ifm->u.macho;
- const macho_segment_command* sc = (const macho_segment_command*)lc;
struct section_info* info = user;
BOOL ignore;
const macho_section* section;
int i;
unsigned long tmp, page_mask = sysconf( _SC_PAGESIZE ) - 1;
+ uint64_t vmaddr, vmsize;
+ char segname[16];
+ uint32_t nsects;
+
+ if (ifm->addr_size == 32)
+ {
+ const struct segment_command *sc = (const struct segment_command *)lc;
+ vmaddr = sc->vmaddr;
+ vmsize = sc->vmsize;
+ memcpy(segname, sc->segname, sizeof(segname));
+ nsects = sc->nsects;
+ section = (const macho_section*)(sc + 1);
+ }
+ else
+ {
+ const struct segment_command_64 *sc = (const struct segment_command_64 *)lc;
+ vmaddr = sc->vmaddr;
+ vmsize = sc->vmsize;
+ memcpy(segname, sc->segname, sizeof(segname));
+ nsects = sc->nsects;
+ section = (const macho_section*)(sc + 1);
+ }
TRACE("(%p/%d, %p, %p) before: 0x%08lx - 0x%08lx\n", fmap, fmap->fd, lc, user,
(unsigned long)fmap->segs_start, (unsigned long)fmap->segs_size);
- TRACE("Segment command vm: 0x%08lx - 0x%08lx\n", (unsigned long)sc->vmaddr,
- (unsigned long)(sc->vmaddr + sc->vmsize));
+ TRACE("Segment command vm: 0x%08lx - 0x%08lx\n", (unsigned long)vmaddr,
+ (unsigned long)(vmaddr + vmsize));
/* Images in the dyld shared cache have their segments mapped non-contiguously.
We don't know how to properly locate any of the segments other than __TEXT,
so ignore them. */
- ignore = (info->split_segs && strcmp(sc->segname, SEG_TEXT));
+ ignore = (info->split_segs && strcmp(segname, SEG_TEXT));
- if (!strncmp(sc->segname, "WINE_", 5))
- TRACE("Ignoring special Wine segment %s\n", debugstr_an(sc->segname, sizeof(sc->segname)));
- else if (!strncmp(sc->segname, "__PAGEZERO", 10))
+ if (!strncmp(segname, "WINE_", 5))
+ TRACE("Ignoring special Wine segment %s\n", debugstr_an(segname, sizeof(segname)));
+ else if (!strncmp(segname, "__PAGEZERO", 10))
TRACE("Ignoring __PAGEZERO segment\n");
else if (ignore)
- TRACE("Ignoring %s segment because image has split segments\n", sc->segname);
+ TRACE("Ignoring %s segment because image has split segments\n", segname);
else
{
/* If this segment starts before previously-known earliest, record new earliest. */
- if (sc->vmaddr < fmap->segs_start)
- fmap->segs_start = sc->vmaddr;
+ if (vmaddr < fmap->segs_start)
+ fmap->segs_start = vmaddr;
/* If this segment extends beyond previously-known furthest, record new furthest. */
- tmp = (sc->vmaddr + sc->vmsize + page_mask) & ~page_mask;
+ tmp = (vmaddr + vmsize + page_mask) & ~page_mask;
if (fmap->segs_size < tmp) fmap->segs_size = tmp;
TRACE("after: 0x%08lx - 0x%08lx\n", (unsigned long)fmap->segs_start, (unsigned long)fmap->segs_size);
}
- section = (const macho_section*)(sc + 1);
- for (i = 0; i < sc->nsects; i++)
+ for (i = 0; i < nsects; i++)
{
fmap->sect[info->section_index].section = §ion[i];
fmap->sect[info->section_index].mapped = IMAGE_NO_MAP;
--
2.7.4
June 14, 2018
[PATCH 3/6] dbghelp: Pass an image_file_map to macho_enum_load_commands().
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/dbghelp/macho_module.c | 38 ++++++++++++++++++++++----------------
1 file changed, 22 insertions(+), 16 deletions(-)
diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c
index 679c203..50fcca4 100644
--- a/dlls/dbghelp/macho_module.c
+++ b/dlls/dbghelp/macho_module.c
@@ -467,10 +467,11 @@ static const struct load_command* macho_next_load_command(const struct load_comm
* callback. If >=0, that's the count of load commands successfully
* processed.
*/
-static int macho_enum_load_commands(struct macho_file_map* fmap, unsigned cmd,
- int (*cb)(struct macho_file_map*, const struct load_command*, void*),
+static int macho_enum_load_commands(struct image_file_map *ifm, unsigned cmd,
+ int (*cb)(struct image_file_map*, const struct load_command*, void*),
void* user)
{
+ struct macho_file_map* fmap = &ifm->u.macho;
const struct load_command* lc;
int i;
int count = 0;
@@ -488,7 +489,7 @@ static int macho_enum_load_commands(struct macho_file_map* fmap, unsigned cmd,
if (cmd && cmd != lc->cmd) continue;
count++;
- result = cb(fmap, lc, user);
+ result = cb(ifm, lc, user);
TRACE("load_command[%d] (%p), cmd %u; callback => %d\n", i, lc, lc->cmd, result);
if (result) return (result < 0) ? result : count;
}
@@ -503,13 +504,14 @@ static int macho_enum_load_commands(struct macho_file_map* fmap, unsigned cmd,
* significant sections in a Mach-O file. All commands are
* expected to be of LC_SEGMENT[_64] type.
*/
-static int macho_count_sections(struct macho_file_map* fmap, const struct load_command* lc, void* user)
+static int macho_count_sections(struct image_file_map* ifm, const struct load_command* lc, void* user)
{
const macho_segment_command* sc = (const macho_segment_command*)lc;
- TRACE("(%p/%d, %p, %p) segment %s\n", fmap, fmap->fd, lc, user, debugstr_an(sc->segname, sizeof(sc->segname)));
+ TRACE("(%p/%d, %p, %p) segment %s\n", ifm, ifm->u.macho.fd, lc, user,
+ debugstr_an(sc->segname, sizeof(sc->segname)));
- fmap->num_sections += sc->nsects;
+ ifm->u.macho.num_sections += sc->nsects;
return 0;
}
@@ -520,8 +522,9 @@ static int macho_count_sections(struct macho_file_map* fmap, const struct load_c
* range covered by the segments of a Mach-O file and builds the
* section map. All commands are expected to be of LC_SEGMENT[_64] type.
*/
-static int macho_load_section_info(struct macho_file_map* fmap, const struct load_command* lc, void* user)
+static int macho_load_section_info(struct image_file_map* ifm, const struct load_command* lc, void* user)
{
+ struct macho_file_map* fmap = &ifm->u.macho;
const macho_segment_command* sc = (const macho_segment_command*)lc;
struct section_info* info = user;
BOOL ignore;
@@ -576,9 +579,9 @@ static int macho_load_section_info(struct macho_file_map* fmap, const struct loa
* Callback for macho_enum_load_commands. Records the UUID load
* command of a Mach-O file.
*/
-static int find_uuid(struct macho_file_map* fmap, const struct load_command* lc, void* user)
+static int find_uuid(struct image_file_map* ifm, const struct load_command* lc, void* user)
{
- fmap->uuid = (const struct uuid_command*)lc;
+ ifm->u.macho.uuid = (const struct uuid_command*)lc;
return 1;
}
@@ -700,7 +703,7 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW,
TRACE("... verified Mach header\n");
fmap->num_sections = 0;
- if (macho_enum_load_commands(fmap, target_cmd, macho_count_sections, NULL) < 0)
+ if (macho_enum_load_commands(ifm, target_cmd, macho_count_sections, NULL) < 0)
goto done;
TRACE("%d sections\n", fmap->num_sections);
@@ -713,7 +716,7 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW,
info.split_segs = split_segs;
info.section_index = 0;
- if (macho_enum_load_commands(fmap, target_cmd, macho_load_section_info, &info) < 0)
+ if (macho_enum_load_commands(ifm, target_cmd, macho_load_section_info, &info) < 0)
{
fmap->num_sections = 0;
goto done;
@@ -723,7 +726,7 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW,
TRACE("segs_start: 0x%08lx, segs_size: 0x%08lx\n", (unsigned long)fmap->segs_start,
(unsigned long)fmap->segs_size);
- if (macho_enum_load_commands(fmap, LC_UUID, find_uuid, NULL) < 0)
+ if (macho_enum_load_commands(ifm, LC_UUID, find_uuid, NULL) < 0)
goto done;
if (fmap->uuid)
{
@@ -857,9 +860,10 @@ static void macho_stabs_def_cb(struct module* module, unsigned long load_offset,
* Callback for macho_enum_load_commands. Processes the LC_SYMTAB
* load commands from the Mach-O file.
*/
-static int macho_parse_symtab(struct macho_file_map* fmap,
+static int macho_parse_symtab(struct image_file_map* ifm,
const struct load_command* lc, void* user)
{
+ struct macho_file_map* fmap = &ifm->u.macho;
const struct symtab_command* sc = (const struct symtab_command*)lc;
struct macho_debug_info* mdi = user;
const macho_nlist* stab;
@@ -1219,6 +1223,7 @@ BOOL macho_load_debug_info(struct process *pcs, struct module* module)
BOOL ret = FALSE;
struct macho_debug_info mdi;
int result;
+ struct image_file_map *ifm;
struct macho_file_map *fmap;
if (module->type != DMT_MACHO || !module->format_info[DFI_MACHO]->u.macho_info)
@@ -1227,7 +1232,8 @@ BOOL macho_load_debug_info(struct process *pcs, struct module* module)
return FALSE;
}
- fmap = &module->format_info[DFI_MACHO]->u.macho_info->file_map.u.macho;
+ ifm = &module->format_info[DFI_MACHO]->u.macho_info->file_map;
+ fmap = &ifm->u.macho;
TRACE("(%p, %p/%d)\n", module, fmap, fmap->fd);
@@ -1246,7 +1252,7 @@ BOOL macho_load_debug_info(struct process *pcs, struct module* module)
mdi.module = module;
pool_init(&mdi.pool, 65536);
hash_table_init(&mdi.pool, &mdi.ht_symtab, 256);
- result = macho_enum_load_commands(fmap, LC_SYMTAB, macho_parse_symtab, &mdi);
+ result = macho_enum_load_commands(ifm, LC_SYMTAB, macho_parse_symtab, &mdi);
if (result > 0)
ret = TRUE;
else if (result < 0)
@@ -1255,7 +1261,7 @@ BOOL macho_load_debug_info(struct process *pcs, struct module* module)
if (!(dbghelp_options & SYMOPT_PUBLICS_ONLY) && fmap->dsym)
{
mdi.fmap = &fmap->dsym->u.macho;
- result = macho_enum_load_commands(mdi.fmap, LC_SYMTAB, macho_parse_symtab, &mdi);
+ result = macho_enum_load_commands(fmap->dsym, LC_SYMTAB, macho_parse_symtab, &mdi);
if (result > 0)
ret = TRUE;
else if (result < 0)
--
2.7.4
June 14, 2018