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
Re: [PATCH v2] shellpath.c: Fix creation of HOME directory symbolic links
by Bob Wya
On 8 June 2018 at 12:52, Huw Davies <huw(a)codeweavers.com> wrote:
> On Fri, Jun 08, 2018 at 10:58:23AM +0100, Rob Walker wrote:
> > Fixes: https://bugs.winehq.org/show_bug.cgi?id=41668
> >
> > The Shell Folders, that Wine symlinks to the user's HOME directory, are
> > only re-created on each Wine boot if they: do not pre-exist or are broken
> > symbolic links.
> >
> > Handling the DESKTOP Shell Folder is a special case as this is created
> twice
> > (during a standard boot), early in the Wine boot process. This is
> handled by
> > 2 separate processes, loading shell32.dll, in sequence. This makes it
> hard to determine
> > if the DESKTOP folder was created before the Wine boot (either from a
> previous Wine boot
> > or by the end user).
> >
> > The final (implemented) solution determines the exact start time of the
> Wine boot process
> > (using the current system time and tick-count). If the DESKTOP directory
> was last written
> > after this Wine boot time, we can assume that "we" (Wine) automatically
> created the
> > directory. Only in this instance do we attempt to set a symlink to the
> DESKTOP directory
> > (subdirectory of HOME).
>
> There's still too much going on here.
>
> Do you really need to refactor the code to make your change?
> If not, then just send in the change to the current code.
> If you need to refactor, then do the refactoring first
> (I could imagine taking 3-4 patches to do the refactoring[1])
> then make the change as a final patch in the series.
>
> The file-time / boot-time thing seems hacky, I'm not exactly
> sure what you're trying do to, but this doesn't sound right.
> Hopefully that will become clearer as you tidy things up.
>
> Huw.
>
> [1] For example move the creation of My Pictures/My Videos/etc
> first, then move My Documents and finally Desktop. These
> final two are special cases in the current code, we'd need
> to see that in any new code.
>
Sorry I forgot to update the commit message! I'd updated the code (in the
v2 patch), for handling the
special case of the User profile Desktop directory, without testing file
times / boot times (the latter
didn't work as GetTickTime64 was returning the host system uptime anyway).
--------------------------------------------------------------------------------------------------------------------------------
I have a number of concerns with the existing implementation of
_SHCreateSymbolicLinks():
1) The function is far too long, in it's present form - it's currently 165
lines long!
2) The comments should be far more terse and precise.
3) Using infinite while (1) loops to de-mark code blocks only serves to
obscure the functionality of the code.
4)
4487- /* '$HOME' doesn't exist. Create 'My Pictures', 'My Videos'
and 'My Music' subdirs
4488- * in '%USERPROFILE%\\My Documents' or fail silently if they
already exist. */
4489- pszHome = NULL;
4490- strcpy(szPersonalTarget, pszPersonal);
4491- for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++) {
4492- strcpy(szMyStuffTarget, szPersonalTarget);
4493- if (_SHAppendToUnixPath(szMyStuffTarget,
MAKEINTRESOURCEW(aidsMyStuff[i])))
4494- mkdir(szMyStuffTarget, 0777);
4495- }
Windows Vista (and newer) do not nest the User profile directories. Since
Wine is targeting Windows 7 by default - this
legacy behaviour should be removed. (As an end user, who used to use
Windows XP, this was simply an annoying default
layout anyway.)
5)
4447- /* '$HOME/My Documents' exists. Create 'My Pictures',
4448- * 'My Videos' and 'My Music' subfolders or fail
silently if
4449- * they already exist.
4450- */
4451- for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++)
4452- {
4453- strcpy(szMyStuffTarget, szPersonalTarget);
4454- if (_SHAppendToUnixPath(szMyStuffTarget,
MAKEINTRESOURCEW(aidsMyStuff[i])))
4455- mkdir(szMyStuffTarget, 0777);
4456- }
4457- break;
Ditto as per (4). This is an obsolete User Profile directory layout
(pre-Vista).
Also if "${HOME}/My Documents" exists then this block of code will start
creating subdirectories in this
folder. I don't think that Wine should be making the rather arbitrary
assumption that a Wine user wants
their "${HOME}" directory spammed with new subdirectories.
I often read online, comments from Wine users, complaining about this sort
of behaviour...
6)
4543- /* Last but not least, the Desktop folder */
4544- if (pszHome)
4545- strcpy(szDesktopTarget, pszHome);
4546- else
4547- strcpy(szDesktopTarget, pszPersonal);
4548- heap_free(pszPersonal);
4549-
4550- xdg_desktop_dir = xdg_results ? xdg_results[num - 1] : NULL;
4551- if (xdg_desktop_dir ||
4552- (_SHAppendToUnixPath(szDesktopTarget, DesktopW) &&
4553- !stat(szDesktopTarget, &statFolder) &&
S_ISDIR(statFolder.st_mode)))
4554- {
4555- hr = SHGetFolderPathW(NULL,
CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE,
NULL,
4556- SHGFP_TYPE_DEFAULT, wszTempPath);
4557- if (SUCCEEDED(hr) && (pszDesktop =
wine_get_unix_file_name(wszTempPath)))
4558- {
4559- remove(pszDesktop);
4560- if (xdg_desktop_dir)
4561- symlink(xdg_desktop_dir, pszDesktop);
4562- else
4563- symlink(szDesktopTarget, pszDesktop);
4564- heap_free(pszDesktop);
4565- }
4566- }
This code uses pszPersonal as a fallback target for when HOME is unset.
This will be the equivalent of:
"${WINEPREFIX}/dosdevices/c:/users/${USER}/My Documents"
Say the XDG_DESKTOP_DIR check fails. Then Wine tries to find the directory:
"${WINEPREFIX}/dosdevices/c:/users/${USER}/My Documents/Desktop"
as a symlink target. Which never succeeds because Wine never creates this
directory...
This extra path appears to be redundant (HOME unset / XDG_DESKTOP_DIR
unset).
--------------------------------------------------------------------------------------------------------------------------------
I can of course leave the variable names unchanged and the function name.
I was "told off" for not using snake case on a previous Wine commit - so I
assumed
I had to follow this standard if I wanted to refactor existing code. :-)
I'd like to tidy this function up and make it more readable (including the
comments).
Which I can do in staged patches, as you suggested.
But obviously I'd like to feel that we are both on the "same page" about
the changes
I discussed (above). Before I email in a v3 staged patchset.
June 8, 2018
Re: [PATCH] d3dcompiler/tests: Use the available ARRAY_SIZE() macro
by Matteo Bruni
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
June 8, 2018
[PATCH] ntprint/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/ntprint/tests/ntprint.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/ntprint/tests/ntprint.c b/dlls/ntprint/tests/ntprint.c
index 1710220def..57caa49ab2 100644
--- a/dlls/ntprint/tests/ntprint.c
+++ b/dlls/ntprint/tests/ntprint.c
@@ -67,7 +67,7 @@ static void test_PSetupCreateMonitorInfo(VOID)
{
HANDLE mi;
WCHAR buffer[1024] = {'\\','\\'};
- UINT len = sizeof(buffer) / sizeof(buffer[0]) - 2;
+ UINT len = ARRAY_SIZE(buffer) - 2;
GetComputerNameW(buffer + 2, &len);
SetLastError(0xdeadbeef);
@@ -155,7 +155,7 @@ static void test_PSetupEnumMonitor(VOID)
"and '> 0')\n", res, GetLastError(), minsize);
- size = sizeof(buffer) / sizeof(buffer[0]);
+ size = ARRAY_SIZE(buffer);
if ((minsize + 1) > size) {
skip("overflow: %u\n", minsize);
pPSetupDestroyMonitorInfo(mi);
@@ -165,7 +165,7 @@ static void test_PSetupEnumMonitor(VOID)
if (0) {
/* XP: ERROR_INVALID_PARAMETER, w2k: Crash */
SetLastError(0xdeadbeef);
- size = sizeof(buffer) / sizeof(buffer[0]);
+ size = ARRAY_SIZE(buffer);
res = pPSetupEnumMonitor(NULL, 0, buffer, &size);
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
"got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
@@ -175,7 +175,7 @@ static void test_PSetupEnumMonitor(VOID)
if (0) {
/* XP: Crash, w2k: Success (how can that work?) */
SetLastError(0xdeadbeef);
- size = sizeof(buffer) / sizeof(buffer[0]);
+ size = ARRAY_SIZE(buffer);
res = pPSetupEnumMonitor(mi, 0, NULL, &size);
trace("got %u with %u and %u\n", res, GetLastError(), size);
}
@@ -213,7 +213,7 @@ static void test_PSetupEnumMonitor(VOID)
while (res && (index < 20)) {
SetLastError(0xdeadbeef);
buffer[0] = '\0';
- size = sizeof(buffer) / sizeof(buffer[0]);
+ size = ARRAY_SIZE(buffer);
res = pPSetupEnumMonitor(mi, index, buffer, &size);
ok( res || (GetLastError() == ERROR_NO_MORE_ITEMS),
"(%u) got %u with %u and %u (expected '!=0' or: '0' with "
--
2.14.4
June 8, 2018
[PATCH] oleacc/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/oleacc/tests/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/oleacc/tests/main.c b/dlls/oleacc/tests/main.c
index 7a0737caff..c62fa79556 100644
--- a/dlls/oleacc/tests/main.c
+++ b/dlls/oleacc/tests/main.c
@@ -410,7 +410,7 @@ static void test_getroletext(void)
memset(buff2W, 0, sizeof(buff2W));
ret = GetRoleTextW(role, NULL, 0);
- GetRoleTextW(role, buff2W, sizeof(buff2W)/sizeof(WCHAR));
+ GetRoleTextW(role, buff2W, ARRAY_SIZE(buff2W));
ok(ret == lstrlenW(buff2W),
"GetRoleTextW: returned length doesn't match returned buffer for role %d\n", role);
}
--
2.14.4
June 8, 2018
[PATCH] psapi/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/psapi/tests/psapi_main.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c
index 4adc82619b..0ff212c766 100644
--- a/dlls/psapi/tests/psapi_main.c
+++ b/dlls/psapi/tests/psapi_main.c
@@ -536,12 +536,12 @@ todo_wine {
}
SetLastError(0xdeadbeef);
- ret = pGetMappedFileNameW(GetCurrentProcess(), base, map_nameW, sizeof(map_nameW)/sizeof(map_nameW[0]));
+ ret = pGetMappedFileNameW(GetCurrentProcess(), base, map_nameW, ARRAY_SIZE(map_nameW));
todo_wine {
ok(ret, "GetMappedFileNameW error %d\n", GetLastError());
ok(ret > strlen(device_name), "map_name should be longer than device_name\n");
}
- if (nt_get_mapped_file_name(GetCurrentProcess(), base, nt_map_name, sizeof(nt_map_name)/sizeof(nt_map_name[0])))
+ if (nt_get_mapped_file_name(GetCurrentProcess(), base, nt_map_name, ARRAY_SIZE(nt_map_name)))
{
ok(memcmp(map_nameW, nt_map_name, lstrlenW(map_nameW)) == 0, "map name does not start with a device name: %s\n", map_name);
WideCharToMultiByte(CP_ACP, 0, map_nameW, -1, map_name, MAX_PATH, NULL, NULL);
@@ -658,7 +658,7 @@ static void test_GetProcessImageFileName(void)
/* correct call */
memset(szImgPathW, 0xff, sizeof(szImgPathW));
- ret = pGetProcessImageFileNameW(hpQI, szImgPathW, sizeof(szImgPathW)/sizeof(WCHAR));
+ ret = pGetProcessImageFileNameW(hpQI, szImgPathW, ARRAY_SIZE(szImgPathW));
ok(ret > 0, "GetProcessImageFileNameW should have succeeded.\n");
ok(szImgPathW[0] == '\\', "GetProcessImageFileNameW should have returned an NT path.\n");
ok(lstrlenW(szImgPathW) == ret, "Expected length to be %d, got %d\n", ret, lstrlenW(szImgPathW));
--
2.14.4
June 8, 2018
[PATCH] quartz/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/quartz/tests/avisplitter.c | 4 ++--
dlls/quartz/tests/filtergraph.c | 6 +++---
dlls/quartz/tests/misc.c | 8 ++++----
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/dlls/quartz/tests/avisplitter.c b/dlls/quartz/tests/avisplitter.c
index 8bafb14157..bc933d148d 100644
--- a/dlls/quartz/tests/avisplitter.c
+++ b/dlls/quartz/tests/avisplitter.c
@@ -210,7 +210,7 @@ static void test_filesourcefilter(void)
ret = GetTempFileNameW(temp, prefix, 0, path);
ok(ret, "GetTempFileNameW failed with error %u\n", GetLastError());
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
trace("Running test for %s\n", tests[i].label);
@@ -280,7 +280,7 @@ static WCHAR *load_resource(const WCHAR *name)
HRSRC res;
void *ptr;
- GetTempPathW(sizeof(pathW)/sizeof(WCHAR), pathW);
+ GetTempPathW(ARRAY_SIZE(pathW), pathW);
lstrcatW(pathW, name);
file = CreateFileW(pathW, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c
index a1ece9489f..85079d982d 100644
--- a/dlls/quartz/tests/filtergraph.c
+++ b/dlls/quartz/tests/filtergraph.c
@@ -50,7 +50,7 @@ static WCHAR *load_resource(const WCHAR *name)
HRSRC res;
void *ptr;
- GetTempPathW(sizeof(pathW)/sizeof(WCHAR), pathW);
+ GetTempPathW(ARRAY_SIZE(pathW), pathW);
lstrcatW(pathW, name);
file = CreateFileW(pathW, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
@@ -1500,14 +1500,14 @@ static HRESULT createtestfilter(const CLSID* pClsid, const TestFilterPinData *pi
pinInfo.pFilter = &pTestFilter->IBaseFilter_iface;
if (pinInfo.dir == PINDIR_INPUT)
{
- lstrcpynW(pinInfo.achName, wcsInputPinName, sizeof(pinInfo.achName) / sizeof(pinInfo.achName[0]));
+ lstrcpynW(pinInfo.achName, wcsInputPinName, ARRAY_SIZE(pinInfo.achName));
hr = TestFilter_Pin_Construct(&TestFilter_InputPin_Vtbl, &pinInfo, &mt, &pTestFilter->csFilter,
&pTestFilter->ppPins[i]);
}
else
{
- lstrcpynW(pinInfo.achName, wcsOutputPinName, sizeof(pinInfo.achName) / sizeof(pinInfo.achName[0]));
+ lstrcpynW(pinInfo.achName, wcsOutputPinName, ARRAY_SIZE(pinInfo.achName));
hr = TestFilter_Pin_Construct(&TestFilter_OutputPin_Vtbl, &pinInfo, &mt, &pTestFilter->csFilter,
&pTestFilter->ppPins[i]);
}
diff --git a/dlls/quartz/tests/misc.c b/dlls/quartz/tests/misc.c
index 748c0f2cfd..16b6d40ce4 100644
--- a/dlls/quartz/tests/misc.c
+++ b/dlls/quartz/tests/misc.c
@@ -169,7 +169,7 @@ static void test_null_renderer_aggregations(void)
};
int i;
- for (i = 0; i < sizeof(iids) / sizeof(iids[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(iids); i++)
{
test_aggregation(CLSID_SystemClock, CLSID_NullRenderer, IID_IReferenceClock, *iids[i]);
}
@@ -182,7 +182,7 @@ static void test_video_renderer_aggregations(void)
};
int i;
- for (i = 0; i < sizeof(iids) / sizeof(iids[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(iids); i++)
{
test_aggregation(CLSID_SystemClock, CLSID_VideoRenderer,
IID_IReferenceClock, *iids[i]);
@@ -199,7 +199,7 @@ static void test_filter_graph_aggregations(void)
};
int i;
- for (i = 0; i < sizeof(iids) / sizeof(iids[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(iids); i++)
{
test_aggregation(CLSID_SystemClock, CLSID_FilterGraph,
IID_IReferenceClock, *iids[i]);
@@ -213,7 +213,7 @@ static void test_filter_mapper_aggregations(void)
};
int i;
- for (i = 0; i < sizeof(iids) / sizeof(iids[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(iids); i++)
{
test_aggregation(CLSID_SystemClock, CLSID_FilterMapper2,
IID_IReferenceClock, *iids[i]);
--
2.14.4
June 8, 2018
[PATCH] rpcrt4/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/rpcrt4/tests/cstub.c | 2 +-
dlls/rpcrt4/tests/rpc.c | 6 ++----
dlls/rpcrt4/tests/server.c | 2 +-
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/dlls/rpcrt4/tests/cstub.c b/dlls/rpcrt4/tests/cstub.c
index 606107fcfd..7bed308807 100644
--- a/dlls/rpcrt4/tests/cstub.c
+++ b/dlls/rpcrt4/tests/cstub.c
@@ -596,7 +596,7 @@ static IPSFactoryBuffer *test_NdrDllGetClassObject(void)
#undef VTBL_PROXY_TEST
#undef VTBL_PROXY_TEST_NOT_ZERO
- for (i = 0; i < sizeof(interfaces)/sizeof(interfaces[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(interfaces); i++)
ok( proxy_vtbl[i]->header.piid == interfaces[i],
"wrong proxy %u iid %p/%p\n", i, proxy_vtbl[i]->header.piid, interfaces[i] );
diff --git a/dlls/rpcrt4/tests/rpc.c b/dlls/rpcrt4/tests/rpc.c
index f026e99de2..c9f2a4b721 100644
--- a/dlls/rpcrt4/tests/rpc.c
+++ b/dlls/rpcrt4/tests/rpc.c
@@ -149,10 +149,8 @@ static void TestDceErrorInqText (void)
*/
DWORD dwCount;
- dwCount = FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, RPC_S_NOT_RPC_ERROR, 0, bufferInvalid,
- sizeof(bufferInvalid)/sizeof(bufferInvalid[0]), NULL);
+ dwCount = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
+ RPC_S_NOT_RPC_ERROR, 0, bufferInvalid, ARRAY_SIZE(bufferInvalid), NULL);
/* A random sample of DceErrorInqText */
/* 0 is success */
diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c
index dfad1ed0f3..b35b71bcfd 100644
--- a/dlls/rpcrt4/tests/server.c
+++ b/dlls/rpcrt4/tests/server.c
@@ -313,7 +313,7 @@ void __cdecl s_get_number_array(int x[20], int *n)
{
int c[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
memcpy(x, c, sizeof(c));
- *n = sizeof(c)/sizeof(c[0]);
+ *n = ARRAY_SIZE(c);
}
int __cdecl s_sum_cs(cs_t *cs)
--
2.14.4
June 8, 2018
[PATCH] webservices/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/webservices/tests/channel.c | 12 ++++++------
dlls/webservices/tests/msg.c | 2 +-
dlls/webservices/tests/proxy.c | 8 ++++----
dlls/webservices/tests/reader.c | 20 ++++++++++----------
dlls/webservices/tests/url.c | 4 ++--
dlls/webservices/tests/writer.c | 38 +++++++++++++++++++-------------------
6 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/dlls/webservices/tests/channel.c b/dlls/webservices/tests/channel.c
index 17a0b58ac8..c995a08829 100644
--- a/dlls/webservices/tests/channel.c
+++ b/dlls/webservices/tests/channel.c
@@ -134,7 +134,7 @@ static void test_WsOpenChannel(void)
ok( hr == E_INVALIDARG, "got %08x\n", hr );
memset( &addr, 0, sizeof(addr) );
- addr.url.length = sizeof(url)/sizeof(url[0]);
+ addr.url.length = ARRAY_SIZE( url );
addr.url.chars = url;
hr = WsOpenChannel( NULL, &addr, NULL, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
@@ -179,7 +179,7 @@ static void test_WsResetChannel(void)
ok( hr == S_OK, "got %08x\n", hr );
memset( &addr, 0, sizeof(addr) );
- addr.url.length = sizeof(url)/sizeof(url[0]);
+ addr.url.length = ARRAY_SIZE( url );
addr.url.chars = url;
hr = WsOpenChannel( channel, &addr, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
@@ -301,7 +301,7 @@ static void test_WsOpenListener(void)
hr = WsOpenListener( listener, NULL, NULL, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
- url.length = sizeof(str)/sizeof(str[0]);
+ url.length = ARRAY_SIZE( str );
url.chars = str;
hr = WsOpenListener( NULL, &url, NULL, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
@@ -320,7 +320,7 @@ static void test_WsOpenListener(void)
hr = WsCreateListener( WS_CHANNEL_TYPE_DUPLEX_SESSION, WS_TCP_CHANNEL_BINDING, NULL, 0, NULL, &listener, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- url.length = sizeof(str2)/sizeof(str2[0]);
+ url.length = ARRAY_SIZE( str2 );
url.chars = str2;
hr = WsOpenListener( listener, &url, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
@@ -333,7 +333,7 @@ static void test_WsOpenListener(void)
hr = WsCreateListener( WS_CHANNEL_TYPE_DUPLEX_SESSION, WS_TCP_CHANNEL_BINDING, NULL, 0, NULL, &listener, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- url.length = sizeof(str3)/sizeof(str3[0]);
+ url.length = ARRAY_SIZE( str3 );
url.chars = str3;
hr = WsOpenListener( listener, &url, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
@@ -387,7 +387,7 @@ static void test_WsResetListener(void)
{
WCHAR str[] =
{'n','e','t','.','t','c','p',':','/','/','+',':','2','0','1','7','/','p','a','t','h'};
- WS_STRING url = { sizeof(str)/sizeof(str[0]), str };
+ WS_STRING url = { ARRAY_SIZE( str ), str };
WS_LISTENER *listener;
WS_LISTENER_STATE state;
WS_LISTENER_PROPERTY prop;
diff --git a/dlls/webservices/tests/msg.c b/dlls/webservices/tests/msg.c
index 550ae1dd0d..22d69ece2c 100644
--- a/dlls/webservices/tests/msg.c
+++ b/dlls/webservices/tests/msg.c
@@ -258,7 +258,7 @@ static void test_WsAddressMessage(void)
memset( &endpoint, 0, sizeof(endpoint) );
endpoint.url.chars = localhost;
- endpoint.url.length = sizeof(localhost)/sizeof(localhost[0]);
+ endpoint.url.length = ARRAY_SIZE( localhost );
hr = WsAddressMessage( msg, &endpoint, NULL );
ok( hr == S_OK, "got %08x\n", hr );
diff --git a/dlls/webservices/tests/proxy.c b/dlls/webservices/tests/proxy.c
index 95f980a2ff..f5297796b3 100644
--- a/dlls/webservices/tests/proxy.c
+++ b/dlls/webservices/tests/proxy.c
@@ -164,7 +164,7 @@ static void test_WsOpenServiceProxy(void)
ok( state == WS_SERVICE_PROXY_STATE_CREATED, "got %u\n", state );
memset( &addr, 0, sizeof(addr) );
- addr.url.length = sizeof(url)/sizeof(url[0]);
+ addr.url.length = ARRAY_SIZE( url );
addr.url.chars = url;
hr = WsOpenServiceProxy( proxy, &addr, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
@@ -206,7 +206,7 @@ static void test_WsResetServiceProxy(void)
ok( state == WS_SERVICE_PROXY_STATE_CREATED, "got %u\n", state );
memset( &addr, 0, sizeof(addr) );
- addr.url.length = sizeof(url)/sizeof(url[0]);
+ addr.url.length = ARRAY_SIZE( url );
addr.url.chars = url;
hr = WsOpenServiceProxy( proxy, &addr, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
@@ -385,7 +385,7 @@ static HRESULT create_proxy( int port, WS_SERVICE_PROXY **ret )
*ret = NULL;
hr = WsCreateServiceProxy( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, NULL,
- 0, prop, sizeof(prop)/sizeof(prop[0]), &proxy, NULL );
+ 0, prop, ARRAY_SIZE( prop ), &proxy, NULL );
if (hr != S_OK) return hr;
memset( &addr, 0, sizeof(addr) );
@@ -687,7 +687,7 @@ static DWORD CALLBACK server_proc( void *arg )
}
buf[i] = 0;
- for (j = 0; j < sizeof(tests)/sizeof(tests[0]); j++)
+ for (j = 0; j < ARRAY_SIZE( tests ); j++)
{
if (strstr( buf, tests[j].req_action ))
{
diff --git a/dlls/webservices/tests/reader.c b/dlls/webservices/tests/reader.c
index bd8a37cc52..b21e8396be 100644
--- a/dlls/webservices/tests/reader.c
+++ b/dlls/webservices/tests/reader.c
@@ -479,7 +479,7 @@ static void test_WsSetInput(void)
enc.encoding.encodingType = WS_XML_READER_ENCODING_TYPE_TEXT;
enc.charSet = WS_CHARSET_AUTO;
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
input.encodedData = tests[i].data;
input.encodedDataSize = tests[i].size;
@@ -1174,7 +1174,7 @@ static void test_WsReadNode(void)
hr = WsCreateReader( NULL, 0, &reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_input( reader, tests[i].text, strlen(tests[i].text) );
ok( hr == S_OK, "got %08x\n", hr );
@@ -1644,7 +1644,7 @@ static void test_WsReadType(void)
ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );
enum_desc.values = enum_values;
- enum_desc.valueCount = sizeof(enum_values)/sizeof(enum_values[0]);
+ enum_desc.valueCount = ARRAY_SIZE( enum_values );
enum_desc.maxByteCount = 3;
enum_desc.nameIndices = NULL;
@@ -3526,7 +3526,7 @@ static void test_datetime(void)
hr = WsCreateReader( NULL, 0, &reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
memset( &date, 0, sizeof(date) );
prepare_type_test( reader, tests[i].str, strlen(tests[i].str) );
@@ -3578,7 +3578,7 @@ static void test_WsDateTimeToFileTime(void)
hr = WsDateTimeToFileTime( NULL, &ft, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
memset( &ft, 0, sizeof(ft) );
hr = WsDateTimeToFileTime( &tests[i].dt, &ft, NULL );
@@ -3716,7 +3716,7 @@ static void test_double(void)
hr = WsCreateReader( NULL, 0, &reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
val = 0;
prepare_type_test( reader, tests[i].str, strlen(tests[i].str) );
@@ -4064,7 +4064,7 @@ static void test_entities(void)
hr = WsCreateReader( NULL, 0, &reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_input( reader, tests[i].str, strlen(tests[i].str) );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -4628,7 +4628,7 @@ static void test_WsReadQualifiedName(void)
hr = WsReadQualifiedName( reader, heap, NULL, &localname, NULL, NULL );
ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_input( reader, tests[i].str, strlen(tests[i].str) );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -5647,7 +5647,7 @@ static void test_dictionary(void)
UuidCreate( &dict.guid );
dict.strings = strings;
- dict.stringCount = sizeof(strings)/sizeof(strings[0]);
+ dict.stringCount = ARRAY_SIZE( strings );
dict.isConst = TRUE;
/* short dictionary element */
@@ -6385,7 +6385,7 @@ static void test_float(void)
hr = WsCreateReader( NULL, 0, &reader, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
val = 0;
prepare_type_test( reader, tests[i].str, strlen(tests[i].str) );
diff --git a/dlls/webservices/tests/url.c b/dlls/webservices/tests/url.c
index 82059a02bf..2b8dda482e 100644
--- a/dlls/webservices/tests/url.c
+++ b/dlls/webservices/tests/url.c
@@ -131,7 +131,7 @@ static void test_WsDecodeUrl(void)
hr = WsDecodeUrl( &str, 0, NULL, (WS_URL **)&url, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
static const WCHAR netpipe[] = {'n','e','t','.','p','i','p','e'};
@@ -271,7 +271,7 @@ static void test_WsEncodeUrl(void)
hr = WsEncodeUrl( (const WS_URL *)&url, 0, heap, NULL, NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
memset( &url, 0, sizeof(url) );
url.url.scheme = tests[i].scheme;
diff --git a/dlls/webservices/tests/writer.c b/dlls/webservices/tests/writer.c
index 15d4569662..e33c38951e 100644
--- a/dlls/webservices/tests/writer.c
+++ b/dlls/webservices/tests/writer.c
@@ -710,7 +710,7 @@ static void test_basic_type(void)
ok( hr == S_OK, "got %08x\n", hr );
/* element content type mapping */
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
prepare_basic_type_test( writer );
hr = WsWriteType( writer, WS_ELEMENT_CONTENT_TYPE_MAPPING, tests[i].type, NULL,
@@ -723,7 +723,7 @@ static void test_basic_type(void)
}
/* element type mapping is the same as element content type mapping for basic types */
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
const INT64 *ptr = &tests[i].val;
@@ -738,7 +738,7 @@ static void test_basic_type(void)
}
/* attribute type mapping */
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
prepare_basic_type_test( writer );
hr = WsWriteStartAttribute( writer, NULL, &localname, &ns, FALSE, NULL );
@@ -1103,7 +1103,7 @@ static void test_WsWriteValue(void)
ok( hr == E_INVALIDARG, "got %08x\n", hr );
/* element type mapping */
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "got %08x\n", hr );
@@ -1120,7 +1120,7 @@ static void test_WsWriteValue(void)
}
/* attribute type mapping */
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "got %08x\n", hr );
@@ -2170,7 +2170,7 @@ static void test_text_types(void)
hr = WsCreateWriter( NULL, 0, &writer, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "got %08x\n", hr );
@@ -2257,7 +2257,7 @@ static void test_double(void)
ok( hr == S_OK, "got %08x\n", hr );
text.text.textType = WS_XML_TEXT_TYPE_DOUBLE;
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "got %08x\n", hr );
@@ -2772,7 +2772,7 @@ static void test_escapes(void)
hr = WsCreateWriter( NULL, 0, &writer, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests_elem)/sizeof(tests_elem[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests_elem ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -2789,7 +2789,7 @@ static void test_escapes(void)
check_output( writer, tests_elem[i].result, __LINE__ );
}
- for (i = 0; i < sizeof(tests_attr)/sizeof(tests_attr[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests_attr ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -2812,7 +2812,7 @@ static void test_escapes(void)
check_output( writer, tests_attr[i].result, __LINE__ );
}
- for (i = 0; i < sizeof(tests_cdata)/sizeof(tests_cdata[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests_cdata ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -2835,7 +2835,7 @@ static void test_escapes(void)
check_output( writer, tests_cdata[i].result, __LINE__ );
}
- for (i = 0; i < sizeof(tests_comment)/sizeof(tests_comment[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests_comment ); i++)
{
WS_XML_COMMENT_NODE comment = {{WS_XML_NODE_TYPE_COMMENT}};
@@ -2954,7 +2954,7 @@ static void test_write_option(void)
hr = WsCreateWriter( NULL, 0, &writer, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -3041,7 +3041,7 @@ static void test_datetime(void)
hr = WsCreateWriter( NULL, 0, &writer, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
hr = set_output( writer );
ok( hr == S_OK, "got %08x\n", hr );
@@ -3231,7 +3231,7 @@ static void test_WsWriteQualifiedName(void)
hr = WsWriteQualifiedName( writer, NULL, NULL, NULL, NULL );
ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( tests ); i++)
{
WS_XML_STRING prefix2, localname2, ns2;
const WS_XML_STRING *prefix_ptr, *localname_ptr, *ns_ptr;
@@ -3551,7 +3551,7 @@ static void test_binary_encoding(void)
hr = WsCreateWriter( NULL, 0, &writer, NULL );
ok( hr == S_OK, "got %08x\n", hr );
- for (i = 0; i < sizeof(elem_tests)/sizeof(elem_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( elem_tests ); i++)
{
hr = WsSetOutput( writer, &bin.encoding, &buf.output, NULL, 0, NULL );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -3574,7 +3574,7 @@ static void test_binary_encoding(void)
if (hr == S_OK) check_output_bin( writer, elem_tests[i].result, elem_tests[i].len_result, __LINE__ );
}
- for (i = 0; i < sizeof(attr_tests)/sizeof(attr_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( attr_tests ); i++)
{
hr = WsSetOutput( writer, &bin.encoding, &buf.output, NULL, 0, NULL );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -3778,12 +3778,12 @@ static void test_dictionary(void)
UuidCreate( &dict.guid );
dict.strings = strings;
- dict.stringCount = sizeof(strings)/sizeof(strings[0]);
+ dict.stringCount = ARRAY_SIZE( strings );
dict.isConst = TRUE;
bin.staticDictionary = &dict;
- for (i = 0; i < sizeof(elem_tests)/sizeof(elem_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( elem_tests ); i++)
{
hr = WsSetOutput( writer, &bin.encoding, &buf.output, NULL, 0, NULL );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
@@ -3799,7 +3799,7 @@ static void test_dictionary(void)
if (hr == S_OK) check_output_bin( writer, elem_tests[i].result, elem_tests[i].len_result, __LINE__ );
}
- for (i = 0; i < sizeof(attr_tests)/sizeof(attr_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( attr_tests ); i++)
{
hr = WsSetOutput( writer, &bin.encoding, &buf.output, NULL, 0, NULL );
ok( hr == S_OK, "%u: got %08x\n", i, hr );
--
2.14.4
June 8, 2018
[PATCH] windowscodecs/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/windowscodecs/tests/info.c | 10 ++++----
dlls/windowscodecs/tests/metadata.c | 46 +++++++++++++++++------------------
dlls/windowscodecs/tests/palette.c | 2 +-
dlls/windowscodecs/tests/pngformat.c | 2 +-
dlls/windowscodecs/tests/tiffformat.c | 2 +-
5 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/dlls/windowscodecs/tests/info.c b/dlls/windowscodecs/tests/info.c
index d00e9d8338..b647601495 100644
--- a/dlls/windowscodecs/tests/info.c
+++ b/dlls/windowscodecs/tests/info.c
@@ -119,7 +119,7 @@ static void test_decoder_info(void)
UINT num_formats, count;
int i, j;
- for (i = 0; i < sizeof(decoder_info_tests)/sizeof(decoder_info_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(decoder_info_tests); i++)
{
struct decoder_info_test *test = &decoder_info_tests[i];
IWICBitmapDecoder *decoder, *decoder2;
@@ -149,8 +149,8 @@ static void test_decoder_info(void)
}
IWICBitmapDecoder_Release(decoder);
- MultiByteToWideChar(CP_ACP, 0, test->mimetype, -1, mimetypeW, sizeof(mimetypeW)/sizeof(mimetypeW[0]));
- MultiByteToWideChar(CP_ACP, 0, test->extensions, -1, extensionsW, sizeof(extensionsW)/sizeof(extensionsW[0]));
+ MultiByteToWideChar(CP_ACP, 0, test->mimetype, -1, mimetypeW, ARRAY_SIZE(mimetypeW));
+ MultiByteToWideChar(CP_ACP, 0, test->extensions, -1, extensionsW, ARRAY_SIZE(extensionsW));
hr = get_component_info(test->clsid, &info);
ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
@@ -234,8 +234,8 @@ static void test_decoder_info(void)
ok(hr == E_INVALIDARG, "GetPixelFormats failed, hr=%x\n", hr);
count = 0xdeadbeef;
- hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, sizeof(pixelformats)/sizeof(pixelformats[0]),
- pixelformats, &count);
+ hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, ARRAY_SIZE(pixelformats),
+ pixelformats, &count);
ok(hr == S_OK, "GetPixelFormats failed, hr=%x\n", hr);
ok(count == num_formats, "got %d formats, expected %d\n", count, num_formats);
diff --git a/dlls/windowscodecs/tests/metadata.c b/dlls/windowscodecs/tests/metadata.c
index c54d7dfe18..eb846db0b8 100644
--- a/dlls/windowscodecs/tests/metadata.c
+++ b/dlls/windowscodecs/tests/metadata.c
@@ -816,7 +816,7 @@ static void test_metadata_IFD(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count);
compare_metadata(reader, td, count);
@@ -832,7 +832,7 @@ static void test_metadata_IFD(void)
load_stream((IUnknown *)reader, IFD_data_swapped, sizeof(IFD_data), persist_options);
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count);
compare_metadata(reader, td, count);
HeapFree(GetProcessHeap(), 0, IFD_data_swapped);
@@ -1271,7 +1271,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(gif_LSD)/sizeof(gif_LSD[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(gif_LSD), "unexpected count %u\n", count);
compare_metadata(reader, gif_LSD, count);
@@ -1320,7 +1320,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(gif_IMD)/sizeof(gif_IMD[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(gif_IMD), "unexpected count %u\n", count);
compare_metadata(reader, gif_IMD, count);
@@ -1374,7 +1374,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_LSD)/sizeof(animated_gif_LSD[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_LSD), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_LSD, count);
@@ -1393,7 +1393,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_APE)/sizeof(animated_gif_APE[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_APE), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_APE, count);
@@ -1412,7 +1412,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_comment_1)/sizeof(animated_gif_comment_1[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_comment_1), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_comment_1, count);
@@ -1431,7 +1431,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_plain_1)/sizeof(animated_gif_plain_1[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_plain_1), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_plain_1, count);
@@ -1480,7 +1480,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_IMD)/sizeof(animated_gif_IMD[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_IMD), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_IMD, count);
@@ -1499,7 +1499,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_comment_2)/sizeof(animated_gif_comment_2[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_comment_2), "unexpected count %u\n", count);
if (count == 1)
compare_metadata(reader, animated_gif_comment_2, count);
@@ -1519,7 +1519,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_plain_2)/sizeof(animated_gif_plain_2[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_plain_2), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_plain_2, count);
@@ -1538,7 +1538,7 @@ static void test_metadata_gif(void)
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(animated_gif_GCE)/sizeof(animated_gif_GCE[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(animated_gif_GCE), "unexpected count %u\n", count);
compare_metadata(reader, animated_gif_GCE, count);
@@ -1599,7 +1599,7 @@ static void test_metadata_gif(void)
ok(len == 2, "expected 2, got %u\n", len);
ok(!lstrcmpW(name, rootW), "expected '/', got %s\n", wine_dbgstr_w(name));
- for (i = 0; i < sizeof(decoder_data)/sizeof(decoder_data[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(decoder_data); i++)
{
WCHAR queryW[256];
@@ -1622,7 +1622,7 @@ static void test_metadata_gif(void)
ok(len == lstrlenW(queryW) + 1, "expected %u, got %u\n", lstrlenW(queryW) + 1, len);
ok(!lstrcmpW(name, queryW), "expected %s, got %s\n", wine_dbgstr_w(queryW), wine_dbgstr_w(name));
- for (j = 0; j < sizeof(decoder_data)/sizeof(decoder_data[0]); j++)
+ for (j = 0; j < ARRAY_SIZE(decoder_data); j++)
{
MultiByteToWideChar(CP_ACP, 0, decoder_data[j].query, -1, queryW, 256);
@@ -1698,7 +1698,7 @@ static void test_metadata_gif(void)
ok(len == 2, "expected 2, got %u\n", len);
ok(!lstrcmpW(name, rootW), "expected '/', got %s\n", wine_dbgstr_w(name));
- for (i = 0; i < sizeof(frame_data)/sizeof(frame_data[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(frame_data); i++)
{
if (winetest_debug > 1)
trace("query: %s\n", frame_data[i].query);
@@ -1812,7 +1812,7 @@ static void test_metadata_LSD(void)
{
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count);
compare_metadata(reader, td, count);
@@ -1890,7 +1890,7 @@ static void test_metadata_IMD(void)
{
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count);
compare_metadata(reader, td, count);
@@ -1965,7 +1965,7 @@ static void test_metadata_GCE(void)
{
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count);
compare_metadata(reader, td, count);
@@ -2038,7 +2038,7 @@ static void test_metadata_APE(void)
{
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count);
compare_metadata(reader, td, count);
@@ -2122,7 +2122,7 @@ static void test_metadata_GIF_comment(void)
{
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount error %#x\n", hr);
- ok(count == sizeof(td)/sizeof(td[0]), "unexpected count %u\n", count);
+ ok(count == ARRAY_SIZE(td), "unexpected count %u\n", count);
compare_metadata(reader, td, count);
@@ -2425,9 +2425,9 @@ static void test_WICMapSchemaToName(void)
return;
}
- for (i = 0; i < sizeof(guid_list)/sizeof(guid_list[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(guid_list); i++)
{
- for (j = 0; j < sizeof(schema_list)/sizeof(schema_list[0]); j++)
+ for (j = 0; j < ARRAY_SIZE(schema_list); j++)
{
hr = WICMapSchemaToName(guid_list[i], schema_list[j], 0, NULL, &len);
if (IsEqualGUID(guid_list[i], &GUID_MetadataFormatXMP) ||
@@ -2959,7 +2959,7 @@ static void test_queryreader(void)
hr = IWICComponentFactory_CreateQueryReaderFromBlockReader(factory, &mdbr, &reader);
ok(hr == S_OK, "CreateQueryReaderFromBlockReader error %#x\n", hr);
- for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(test_data); i++)
{
current_metadata = test_data[i].data;
diff --git a/dlls/windowscodecs/tests/palette.c b/dlls/windowscodecs/tests/palette.c
index e3b9a313f6..27bf7c80d1 100644
--- a/dlls/windowscodecs/tests/palette.c
+++ b/dlls/windowscodecs/tests/palette.c
@@ -473,7 +473,7 @@ static void test_predefined_palette(void)
ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
IWICPalette_Release(palette);
- for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(td); i++)
{
hr = IWICImagingFactory_CreatePalette(factory, &palette);
ok(hr == S_OK, "%u: CreatePalette error %#x\n", i, hr);
diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c
index 4b84ccebb1..c798ea438d 100644
--- a/dlls/windowscodecs/tests/pngformat.c
+++ b/dlls/windowscodecs/tests/pngformat.c
@@ -717,7 +717,7 @@ static void test_color_formats(void)
* with tEXt id.
*/
- for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(td); i++)
{
/* with the tRNS and PLTE chunks */
memcpy(buf, png_1x1_data, sizeof(png_1x1_data));
diff --git a/dlls/windowscodecs/tests/tiffformat.c b/dlls/windowscodecs/tests/tiffformat.c
index a7b6f5b594..c6ec21ada1 100644
--- a/dlls/windowscodecs/tests/tiffformat.c
+++ b/dlls/windowscodecs/tests/tiffformat.c
@@ -454,7 +454,7 @@ static void test_tiff_resolution(void)
double dpi_x, dpi_y;
int i;
- for (i = 0; i < sizeof(tiff_resolution_test_data)/sizeof(tiff_resolution_test_data[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tiff_resolution_test_data); i++)
{
const struct tiff_resolution_test_data *test_data = &tiff_resolution_test_data[i];
tiff_resolution_image_data.resx = test_data->resx;
--
2.14.4
June 8, 2018
Re: [PATCH] gdiplus/tests: Use the available ARRAY_SIZE() macro
by Vincent Povirk
Signed-off-by: Vincent Povirk <vincent(a)codeweavers.com>
June 8, 2018