[PATCH] dinput8/tests: Use the available ARRAY_SIZE() macro
Michael Stefaniuc
mstefani at winehq.org
Thu Jun 7 16:44:38 CDT 2018
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/dinput8/tests/device.c | 12 ++++++------
dlls/dinput8/tests/dinput.c | 18 +++++++++---------
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/dlls/dinput8/tests/device.c b/dlls/dinput8/tests/device.c
index 2b06f624c2..aaeddd9b7b 100644
--- a/dlls/dinput8/tests/device.c
+++ b/dlls/dinput8/tests/device.c
@@ -317,8 +317,8 @@ static void test_action_mapping(void)
memset (&af, 0, sizeof(af));
af.dwSize = sizeof(af);
af.dwActionSize = sizeof(DIACTIONA);
- af.dwDataSize = 4 * sizeof(actionMapping) / sizeof(actionMapping[0]);
- af.dwNumActions = sizeof(actionMapping) / sizeof(actionMapping[0]);
+ af.dwDataSize = 4 * ARRAY_SIZE(actionMapping);
+ af.dwNumActions = ARRAY_SIZE(actionMapping);
af.rgoAction = actionMapping;
af.guidActionMap = ACTION_MAPPING_GUID;
af.dwGenre = 0x01000000; /* DIVIRTUAL_DRIVING_RACE */
@@ -357,8 +357,8 @@ static void test_action_mapping(void)
hr = IDirectInputDevice8_SetActionMap(data.keyboard, data.lpdiaf, NULL, 0);
ok (hr == DI_NOEFFECT, "SetActionMap should have no effect with no actions to map hr=%08x\n", hr);
- af.dwDataSize = 4 * sizeof(actionMapping) / sizeof(actionMapping[0]);
- af.dwNumActions = sizeof(actionMapping) / sizeof(actionMapping[0]);
+ af.dwDataSize = 4 * ARRAY_SIZE(actionMapping);
+ af.dwNumActions = ARRAY_SIZE(actionMapping);
/* test DIDSAM_NOUSER */
dps.diph.dwSize = sizeof(dps);
@@ -448,8 +448,8 @@ static void test_save_settings(void)
memset (&af, 0, sizeof(af));
af.dwSize = sizeof(af);
af.dwActionSize = sizeof(DIACTIONA);
- af.dwDataSize = 4 * sizeof(actions) / sizeof(actions[0]);
- af.dwNumActions = sizeof(actions) / sizeof(actions[0]);
+ af.dwDataSize = 4 * ARRAY_SIZE(actions);
+ af.dwNumActions = ARRAY_SIZE(actions);
af.rgoAction = actions;
af.guidActionMap = mapping_guid;
af.dwGenre = 0x01000000; /* DIVIRTUAL_DRIVING_RACE */
diff --git a/dlls/dinput8/tests/dinput.c b/dlls/dinput8/tests/dinput.c
index e16542ab13..b093437096 100644
--- a/dlls/dinput8/tests/dinput.c
+++ b/dlls/dinput8/tests/dinput.c
@@ -82,7 +82,7 @@ static void test_preinitialization(void)
return;
}
- for (i = 0; i < sizeof(create_device_tests)/sizeof(create_device_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(create_device_tests); i++)
{
if (create_device_tests[i].pdev) pDID = (void *)0xdeadbeef;
hr = IDirectInput8_CreateDevice(pDI, create_device_tests[i].rguid,
@@ -93,7 +93,7 @@ static void test_preinitialization(void)
ok(pDID == NULL, "[%d] Output interface pointer is %p\n", i, pDID);
}
- for (i = 0; i < sizeof(enum_devices_tests)/sizeof(enum_devices_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(enum_devices_tests); i++)
{
hr = IDirectInput8_EnumDevices(pDI, enum_devices_tests[i].dwDevType,
enum_devices_tests[i].lpCallback,
@@ -186,7 +186,7 @@ static void test_DirectInput8Create(void)
IUnknown *pUnk;
HRESULT hr;
- for (i = 0; i < sizeof(invalid_param_list)/sizeof(invalid_param_list[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(invalid_param_list); i++)
{
if (invalid_param_list[i].ppdi) pUnk = (void *)0xdeadbeef;
hr = DirectInput8Create(invalid_param_list[i].hinst ? hInstance : NULL,
@@ -199,7 +199,7 @@ static void test_DirectInput8Create(void)
ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk);
}
- for (i = 0; i < sizeof(no_interface_list)/sizeof(no_interface_list[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(no_interface_list); i++)
{
pUnk = (void *)0xdeadbeef;
hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, no_interface_list[i], (void **)&pUnk, NULL);
@@ -207,7 +207,7 @@ static void test_DirectInput8Create(void)
ok(pUnk == NULL, "[%d] Output interface pointer is %p\n", i, pUnk);
}
- for (i = 0; i < sizeof(iid_list)/sizeof(iid_list[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(iid_list); i++)
{
pUnk = NULL;
hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, iid_list[i], (void **)&pUnk, NULL);
@@ -268,7 +268,7 @@ static void test_QueryInterface(void)
hr = IDirectInput8_QueryInterface(pDI, &IID_IUnknown, NULL);
ok(hr == E_POINTER, "IDirectInput8_QueryInterface returned 0x%08x\n", hr);
- for (i = 0; i < sizeof(iid_list)/sizeof(iid_list[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(iid_list); i++)
{
pUnk = NULL;
hr = IDirectInput8_QueryInterface(pDI, iid_list[i], (void **)&pUnk);
@@ -277,7 +277,7 @@ static void test_QueryInterface(void)
if (pUnk)
{
int j;
- for (j = 0; j < sizeof(iid_list)/sizeof(iid_list[0]); j++)
+ for (j = 0; j < ARRAY_SIZE(iid_list); j++)
{
IUnknown *pUnk1 = NULL;
hr = IDirectInput8_QueryInterface(pUnk, iid_list[j], (void **)&pUnk1);
@@ -289,7 +289,7 @@ static void test_QueryInterface(void)
}
}
- for (i = 0; i < sizeof(no_interface_list)/sizeof(no_interface_list[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(no_interface_list); i++)
{
pUnk = (void *)0xdeadbeef;
hr = IDirectInput8_QueryInterface(pDI, no_interface_list[i].riid, (void **)&pUnk);
@@ -527,7 +527,7 @@ static void test_EnumDevicesBySemantics(void)
memset (&diaf, 0, sizeof(diaf));
diaf.dwSize = sizeof(diaf);
diaf.dwActionSize = sizeof(DIACTIONA);
- diaf.dwNumActions = sizeof(actionMapping) / sizeof(actionMapping[0]);
+ diaf.dwNumActions = ARRAY_SIZE(actionMapping);
diaf.dwDataSize = 4 * diaf.dwNumActions;
diaf.rgoAction = actionMapping;
diaf.guidActionMap = ACTION_MAPPING_GUID;
--
2.14.4
More information about the wine-devel
mailing list