[PATCH] d3dcompiler/tests: Use the available ARRAY_SIZE() macro

Michael Stefaniuc mstefani at winehq.org
Thu Jun 7 16:44:35 CDT 2018


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
 dlls/d3dcompiler_43/tests/asm.c        | 27 ++++++++++++++-------------
 dlls/d3dcompiler_43/tests/blob.c       | 18 +++++++++---------
 dlls/d3dcompiler_43/tests/hlsl.c       | 14 +++++++-------
 dlls/d3dcompiler_43/tests/reflection.c | 18 +++++++++---------
 4 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/dlls/d3dcompiler_43/tests/asm.c b/dlls/d3dcompiler_43/tests/asm.c
index 6fd78c186e..f077369ba8 100644
--- a/dlls/d3dcompiler_43/tests/asm.c
+++ b/dlls/d3dcompiler_43/tests/asm.c
@@ -108,7 +108,7 @@ static void preproc_test(void) {
         },
     };
 
-    exec_tests("preproc", tests, sizeof(tests) / sizeof(tests[0]));
+    exec_tests("preproc", tests, ARRAY_SIZE(tests));
 }
 
 static void ps_1_1_test(void) {
@@ -134,7 +134,7 @@ static void ps_1_1_test(void) {
         },
     };
 
-    exec_tests("ps_1_1", tests, sizeof(tests) / sizeof(tests[0]));
+    exec_tests("ps_1_1", tests, ARRAY_SIZE(tests));
 }
 
 static void vs_1_1_test(void) {
@@ -277,7 +277,7 @@ static void vs_1_1_test(void) {
         },
     };
 
-    exec_tests("vs_1_1", tests, sizeof(tests) / sizeof(tests[0]));
+    exec_tests("vs_1_1", tests, ARRAY_SIZE(tests));
 }
 
 static void ps_1_3_test(void) {
@@ -517,7 +517,7 @@ static void ps_1_3_test(void) {
         },
     };
 
-    exec_tests("ps_1_3", tests, sizeof(tests) / sizeof(tests[0]));
+    exec_tests("ps_1_3", tests, ARRAY_SIZE(tests));
 }
 
 static void ps_1_4_test(void) {
@@ -627,7 +627,7 @@ static void ps_1_4_test(void) {
         },
     };
 
-    exec_tests("ps_1_4", tests, sizeof(tests) / sizeof(tests[0]));
+    exec_tests("ps_1_4", tests, ARRAY_SIZE(tests));
 }
 
 static void vs_2_0_test(void) {
@@ -818,7 +818,7 @@ static void vs_2_0_test(void) {
         },
     };
 
-    exec_tests("vs_2_0", tests, sizeof(tests) / sizeof(tests[0]));
+    exec_tests("vs_2_0", tests, ARRAY_SIZE(tests));
 }
 
 static void vs_2_x_test(void) {
@@ -879,7 +879,7 @@ static void vs_2_x_test(void) {
         },
     };
 
-    exec_tests("vs_2_x", tests, sizeof(tests) / sizeof(tests[0]));
+    exec_tests("vs_2_x", tests, ARRAY_SIZE(tests));
 }
 
 static void ps_2_0_test(void) {
@@ -952,7 +952,7 @@ static void ps_2_0_test(void) {
         },
     };
 
-    exec_tests("ps_2_0", tests, sizeof(tests) / sizeof(tests[0]));
+    exec_tests("ps_2_0", tests, ARRAY_SIZE(tests));
 }
 
 static void ps_2_x_test(void) {
@@ -1090,7 +1090,7 @@ static void ps_2_x_test(void) {
         },
     };
 
-    exec_tests("ps_2_x", tests, sizeof(tests) / sizeof(tests[0]));
+    exec_tests("ps_2_x", tests, ARRAY_SIZE(tests));
 }
 
 static void vs_3_0_test(void) {
@@ -1175,7 +1175,7 @@ static void vs_3_0_test(void) {
 
     };
 
-    exec_tests("vs_3_0", tests, sizeof(tests) / sizeof(tests[0]));
+    exec_tests("vs_3_0", tests, ARRAY_SIZE(tests));
 }
 
 static void ps_3_0_test(void) {
@@ -1261,7 +1261,7 @@ static void ps_3_0_test(void) {
         },
     };
 
-    exec_tests("ps_3_0", tests, sizeof(tests) / sizeof(tests[0]));
+    exec_tests("ps_3_0", tests, ARRAY_SIZE(tests));
 }
 
 static void failure_test(void) {
@@ -1408,7 +1408,8 @@ static void failure_test(void) {
     unsigned int i;
     ID3DBlob *shader, *messages;
 
-    for(i = 0; i < (sizeof(tests) / sizeof(tests[0])); i++) {
+    for(i = 0; i < ARRAY_SIZE(tests); i++)
+    {
         shader = NULL;
         messages = NULL;
         hr = D3DAssemble(tests[i], strlen(tests[i]), NULL,
@@ -1689,7 +1690,7 @@ static void d3dpreprocess_test(void)
 
     /* pInclude tests */
     include.ID3DInclude_iface.lpVtbl = &D3DInclude_Vtbl;
-    for (i = 0; i < sizeof(include_test_shaders) / sizeof(include_test_shaders[0]); ++i)
+    for (i = 0; i < ARRAY_SIZE(include_test_shaders); ++i)
     {
         shader = NULL;
         messages = NULL;
diff --git a/dlls/d3dcompiler_43/tests/blob.c b/dlls/d3dcompiler_43/tests/blob.c
index ba69abfb60..d99df825ee 100644
--- a/dlls/d3dcompiler_43/tests/blob.c
+++ b/dlls/d3dcompiler_43/tests/blob.c
@@ -171,7 +171,7 @@ static void test_get_blob_part(void)
     ok(TAG_DXBC == *dword, "DXBC got %#x, expected %#x.\n", *dword, TAG_DXBC);
     ok(TAG_ISGN == *(dword+9), "ISGN got %#x, expected %#x.\n", *(dword+9), TAG_ISGN);
 
-    for (i = 0; i < sizeof(parts) / sizeof(parts[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(parts); i++)
     {
         hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
 
@@ -202,7 +202,7 @@ static void test_get_blob_part(void)
     ok(TAG_DXBC == *dword, "DXBC got %#x, expected %#x.\n", *dword, TAG_DXBC);
     ok(TAG_OSGN == *(dword+9), "OSGN got %#x, expected %#x.\n", *(dword+9), TAG_OSGN);
 
-    for (i = 0; i < sizeof(parts) / sizeof(parts[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(parts); i++)
     {
         hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
 
@@ -234,7 +234,7 @@ static void test_get_blob_part(void)
     ok(TAG_ISGN == *(dword+10), "ISGN got %#x, expected %#x.\n", *(dword+10), TAG_ISGN);
     ok(TAG_OSGN == *(dword+32), "OSGN got %#x, expected %#x.\n", *(dword+32), TAG_OSGN);
 
-    for (i = 0; i < sizeof(parts) / sizeof(parts[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(parts); i++)
     {
         hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
 
@@ -278,7 +278,7 @@ static void test_get_blob_part(void)
     dword = ((DWORD*)ID3D10Blob_GetBufferPointer(blob));
     ok(test_blob_part[0] != *dword, "DXBC failed got %#x.\n", *dword);
 
-    for (i = 0; i < sizeof(parts) / sizeof(parts[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(parts); i++)
     {
         /* There isn't a full DXBC blob returned for D3D_BLOB_LEGACY_SHADER */
         hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
@@ -298,7 +298,7 @@ static void test_get_blob_part(void)
     dword = ((DWORD*)ID3D10Blob_GetBufferPointer(blob));
     ok(test_blob_part[0] != *dword, "DXBC failed got %#x.\n", *dword);
 
-    for (i = 0; i < sizeof(parts) / sizeof(parts[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(parts); i++)
     {
         /* There isn't a full DXBC blob returned for D3D_BLOB_XNA_PREPASS_SHADER */
         hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
@@ -318,7 +318,7 @@ static void test_get_blob_part(void)
     dword = ((DWORD*)ID3D10Blob_GetBufferPointer(blob));
     ok(test_blob_part[0] != *dword, "DXBC failed got %#x.\n", *dword);
 
-    for (i = 0; i < sizeof(parts) / sizeof(parts[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(parts); i++)
     {
         /* There isn't a full DXBC blob returned for D3D_BLOB_XNA_SHADER */
         hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
@@ -606,7 +606,7 @@ static void test_get_blob_part2(void)
     ok(TAG_DXBC == *dword, "DXBC got %#x, expected %#x.\n", *dword, TAG_DXBC);
     ok(TAG_PCSG == *(dword+9), "PCSG got %#x, expected %#x.\n", *(dword+9), TAG_PCSG);
 
-    for (i = 0; i < sizeof(parts) / sizeof(parts[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(parts); i++)
     {
         hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
 
@@ -639,7 +639,7 @@ static void test_get_blob_part2(void)
     ok(TAG_OSGN == *(dword+24), "OSGN got %#x, expected %#x.\n", *(dword+24), TAG_OSGN);
     ok(TAG_PCSG == *(dword+37), "PCSG got %#x, expected %#x.\n", *(dword+37), TAG_PCSG);
 
-    for (i = 0; i < sizeof(parts) / sizeof(parts[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(parts); i++)
     {
         hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
 
@@ -673,7 +673,7 @@ static void test_get_blob_part2(void)
     dword = ((DWORD*)ID3D10Blob_GetBufferPointer(blob));
     ok(TAG_DXBC != *dword, "DXBC failed got %#x.\n", *dword);
 
-    for (i = 0; i < sizeof(parts) / sizeof(parts[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(parts); i++)
     {
         /* There isn't a full DXBC blob returned for D3D_BLOB_DEBUG_INFO */
         hr = D3DGetBlobPart(dword, size, parts[i], 0, &blob2);
diff --git a/dlls/d3dcompiler_43/tests/hlsl.c b/dlls/d3dcompiler_43/tests/hlsl.c
index 856a09c2c5..546a0e5d2e 100644
--- a/dlls/d3dcompiler_43/tests/hlsl.c
+++ b/dlls/d3dcompiler_43/tests/hlsl.c
@@ -320,7 +320,7 @@ static void test_swizzle(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_
         set_float4_d3d9(device, constants, "color", 0.0303f, 0.0f, 0.0f, 0.0202f);
 
         compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry,
-                probes, sizeof(probes) / sizeof(*probes), 1, 1, __LINE__);
+                probes, ARRAY_SIZE(probes), 1, 1, __LINE__);
 
         ID3DXConstantTable_Release(constants);
         IDirect3DPixelShader9_Release(pshader);
@@ -363,7 +363,7 @@ static void test_math(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_geo
         ID3DXConstantTable_SetFloat(constants, device, "$z", z);
 
         compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry,
-                probes, sizeof(probes) / sizeof(*probes), 1, 1, __LINE__);
+                probes, ARRAY_SIZE(probes), 1, 1, __LINE__);
 
         ID3DXConstantTable_Release(constants);
         IDirect3DPixelShader9_Release(pshader);
@@ -417,7 +417,7 @@ static void test_conditionals(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *
     if (pshader != NULL)
     {
         compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry, if_greater_probes,
-                sizeof(if_greater_probes) / sizeof(*if_greater_probes), 32, 1, __LINE__);
+                ARRAY_SIZE(if_greater_probes), 32, 1, __LINE__);
 
         ID3DXConstantTable_Release(constants);
         IDirect3DPixelShader9_Release(pshader);
@@ -427,7 +427,7 @@ static void test_conditionals(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *
     if (pshader != NULL)
     {
         compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry, ternary_operator_probes,
-                sizeof(ternary_operator_probes) / sizeof(*ternary_operator_probes), 8, 1, __LINE__);
+                ARRAY_SIZE(ternary_operator_probes), 8, 1, __LINE__);
 
         ID3DXConstantTable_Release(constants);
         IDirect3DPixelShader9_Release(pshader);
@@ -476,7 +476,7 @@ static void test_float_vectors(IDirect3DDevice9 *device, IDirect3DVertexBuffer9
     if (pshader != NULL)
     {
         compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry, vec4_indexing_test1_probes,
-                sizeof(vec4_indexing_test1_probes) / sizeof(*vec4_indexing_test1_probes), 1, 1, __LINE__);
+                ARRAY_SIZE(vec4_indexing_test1_probes), 1, 1, __LINE__);
 
         ID3DXConstantTable_Release(constants);
         IDirect3DPixelShader9_Release(pshader);
@@ -488,7 +488,7 @@ static void test_float_vectors(IDirect3DDevice9 *device, IDirect3DVertexBuffer9
         ID3DXConstantTable_SetInt(constants, device, "i", 2);
 
         compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry, vec4_indexing_test2_probes,
-                sizeof(vec4_indexing_test2_probes) / sizeof(*vec4_indexing_test2_probes), 32, 1, __LINE__);
+                ARRAY_SIZE(vec4_indexing_test2_probes), 32, 1, __LINE__);
 
         ID3DXConstantTable_Release(constants);
         IDirect3DPixelShader9_Release(pshader);
@@ -550,7 +550,7 @@ static void test_trig(IDirect3DDevice9 *device, IDirect3DVertexBuffer9 *quad_geo
     if (pshader != NULL)
     {
         compute_shader_probe9(device, vshader_passthru, pshader, quad_geometry, sincos_probes,
-                sizeof(sincos_probes) / sizeof(*sincos_probes), 32, 1, __LINE__);
+                ARRAY_SIZE(sincos_probes), 32, 1, __LINE__);
 
         ID3DXConstantTable_Release(constants);
         IDirect3DPixelShader9_Release(pshader);
diff --git a/dlls/d3dcompiler_43/tests/reflection.c b/dlls/d3dcompiler_43/tests/reflection.c
index 9d77d47938..5ca734e6bd 100644
--- a/dlls/d3dcompiler_43/tests/reflection.c
+++ b/dlls/d3dcompiler_43/tests/reflection.c
@@ -356,7 +356,7 @@ static void test_reflection_desc_vs(void)
     ok(ret == 0, "GetMovcInstructionCount failed, got %u, expected %u\n", ret, 0);
 
     /* GetIn/OutputParameterDesc */
-    for (i = 0; i < sizeof(test_reflection_desc_vs_resultin)/sizeof(*test_reflection_desc_vs_resultin); ++i)
+    for (i = 0; i < ARRAY_SIZE(test_reflection_desc_vs_resultin); ++i)
     {
         pdesc = &test_reflection_desc_vs_resultin[i];
 
@@ -381,7 +381,7 @@ static void test_reflection_desc_vs(void)
                 i, desc.Stream, pdesc->ReadWriteMask);
     }
 
-    for (i = 0; i < sizeof(test_reflection_desc_vs_resultout)/sizeof(*test_reflection_desc_vs_resultout); ++i)
+    for (i = 0; i < ARRAY_SIZE(test_reflection_desc_vs_resultout); ++i)
     {
         pdesc = &test_reflection_desc_vs_resultout[i];
 
@@ -656,7 +656,7 @@ static void test_reflection_desc_ps(void)
     ok(hr == E_INVALIDARG, "GetPatchConstantParameterDesc failed, got %x, expected %x\n", hr, E_INVALIDARG);
 
     /* GetIn/OutputParameterDesc */
-    for (i = 0; i < sizeof(test_reflection_desc_ps_resultin)/sizeof(*test_reflection_desc_ps_resultin); ++i)
+    for (i = 0; i < ARRAY_SIZE(test_reflection_desc_ps_resultin); ++i)
     {
         pdesc = &test_reflection_desc_ps_resultin[i];
 
@@ -681,7 +681,7 @@ static void test_reflection_desc_ps(void)
                 i, desc.Stream, pdesc->ReadWriteMask);
     }
 
-    for (i = 0; i < sizeof(test_reflection_desc_ps_resultout)/sizeof(*test_reflection_desc_ps_resultout); ++i)
+    for (i = 0; i < ARRAY_SIZE(test_reflection_desc_ps_resultout); ++i)
     {
         pdesc = &test_reflection_desc_ps_resultout[i];
 
@@ -899,7 +899,7 @@ static void test_reflection_desc_ps_output(void)
     const D3D11_SIGNATURE_PARAMETER_DESC *pdesc;
     unsigned int i;
 
-    for (i = 0; i < sizeof(test_reflection_desc_ps_output_result)/sizeof(*test_reflection_desc_ps_output_result); ++i)
+    for (i = 0; i < ARRAY_SIZE(test_reflection_desc_ps_output_result); ++i)
     {
         hr = D3DReflect(test_reflection_desc_ps_output_blob[i], test_reflection_desc_ps_output_blob[i][6], &IID_ID3D11ShaderReflection, (void **)&ref11);
         ok(hr == S_OK, "(%u): D3DReflect failed %x\n", i, hr);
@@ -1036,7 +1036,7 @@ static void test_reflection_bound_resources(void)
     ok(hr == E_INVALIDARG, "GetResourceBindingDescByName failed, got %x, expected %x\n", hr, E_INVALIDARG);
 
     /* GetResourceBindingDesc */
-    for (i = 0; i < sizeof(test_reflection_bound_resources_result)/sizeof(*test_reflection_bound_resources_result); ++i)
+    for (i = 0; i < ARRAY_SIZE(test_reflection_bound_resources_result); ++i)
     {
         pdesc = &test_reflection_bound_resources_result[i];
 
@@ -1062,7 +1062,7 @@ static void test_reflection_bound_resources(void)
     }
 
     /* GetResourceBindingDescByName */
-    for (i = 0; i < sizeof(test_reflection_bound_resources_result)/sizeof(*test_reflection_bound_resources_result); ++i)
+    for (i = 0; i < ARRAY_SIZE(test_reflection_bound_resources_result); ++i)
     {
         pdesc = &test_reflection_bound_resources_result[i];
 
@@ -1393,7 +1393,7 @@ static void test_reflection_constant_buffer(void)
     ok(hr == S_OK, "IsEqual failed, got %x, expected %x\n", hr, S_OK);
 
     /* constant buffers */
-    for (i = 0; i < sizeof(test_reflection_constant_buffer_cb_result)/sizeof(*test_reflection_constant_buffer_cb_result); ++i)
+    for (i = 0; i < ARRAY_SIZE(test_reflection_constant_buffer_cb_result); ++i)
     {
         pcbdesc = &test_reflection_constant_buffer_cb_result[i];
 
@@ -1416,7 +1416,7 @@ static void test_reflection_constant_buffer(void)
     }
 
     /* variables */
-    for (i = 0; i < sizeof(test_reflection_constant_buffer_variable_result)/sizeof(*test_reflection_constant_buffer_variable_result); ++i)
+    for (i = 0; i < ARRAY_SIZE(test_reflection_constant_buffer_variable_result); ++i)
     {
         pvdesc = &test_reflection_constant_buffer_variable_result[i].desc;
 
-- 
2.14.4




More information about the wine-devel mailing list