[PATCH 07/17] ucrtbase/tests: Use the available ARRAY_SIZE() macro

Michael Stefaniuc mstefani at winehq.org
Wed May 30 14:15:39 CDT 2018


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
 dlls/ucrtbase/tests/misc.c   |  6 +++---
 dlls/ucrtbase/tests/printf.c | 18 +++++++++---------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c
index 2bb221b84e..18838a3d77 100644
--- a/dlls/ucrtbase/tests/misc.c
+++ b/dlls/ucrtbase/tests/misc.c
@@ -703,7 +703,7 @@ static void test_math_errors(void)
     /* necessary so that exp(1e100)==INFINITY on glibc, we can remove this if we change our implementation */
     p_fesetround(FE_TONEAREST);
 
-    for(i = 0; i < sizeof(testsd)/sizeof(testsd[0]); i++) {
+    for(i = 0; i < ARRAY_SIZE(testsd); i++) {
         p_funcd = (void*)GetProcAddress(module, testsd[i].func);
         *p_errno() = -1;
         exception.type = -1;
@@ -717,7 +717,7 @@ static void test_math_errors(void)
            "%s(%f) got exception arg1 %f\n", testsd[i].func, testsd[i].x, exception.arg1);
     }
 
-    for(i = 0; i < sizeof(tests2d)/sizeof(tests2d[0]); i++) {
+    for(i = 0; i < ARRAY_SIZE(tests2d); i++) {
         p_func2d = (void*)GetProcAddress(module, tests2d[i].func);
         *p_errno() = -1;
         exception.type = -1;
@@ -733,7 +733,7 @@ static void test_math_errors(void)
            "%s(%f, %f) got exception arg2 %f\n", tests2d[i].func, tests2d[i].a, tests2d[i].b, exception.arg2);
     }
 
-    for(i = 0; i < sizeof(testsdl)/sizeof(testsdl[0]); i++) {
+    for(i = 0; i < ARRAY_SIZE(testsdl); i++) {
         p_funcdl = (void*)GetProcAddress(module, testsdl[i].func);
         *p_errno() = -1;
         exception.type = -1;
diff --git a/dlls/ucrtbase/tests/printf.c b/dlls/ucrtbase/tests/printf.c
index 0e3800371f..41bb6a335e 100644
--- a/dlls/ucrtbase/tests/printf.c
+++ b/dlls/ucrtbase/tests/printf.c
@@ -171,7 +171,7 @@ static void test_snprintf (void)
     unsigned int i;
 
     /* Legacy _snprintf style termination */
-    for (i = 0; i < sizeof tests / sizeof tests[0]; i++) {
+    for (i = 0; i < ARRAY_SIZE(tests); i++) {
         const char *fmt  = tests[i];
         const int expect = strlen(fmt) > bufsiz ? -1 : strlen(fmt);
         const int n      = vsprintf_wrapper (UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION, buffer, bufsiz, fmt);
@@ -184,7 +184,7 @@ static void test_snprintf (void)
     }
 
     /* C99 snprintf style termination */
-    for (i = 0; i < sizeof tests / sizeof tests[0]; i++) {
+    for (i = 0; i < ARRAY_SIZE(tests); i++) {
         const char *fmt  = tests[i];
         const int expect = strlen(fmt);
         const int n      = vsprintf_wrapper (UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR, buffer, bufsiz, fmt);
@@ -199,7 +199,7 @@ static void test_snprintf (void)
     }
 
     /* swprintf style termination */
-    for (i = 0; i < sizeof tests / sizeof tests[0]; i++) {
+    for (i = 0; i < ARRAY_SIZE(tests); i++) {
         const char *fmt  = tests[i];
         const int expect = strlen(fmt) >= bufsiz ? -2 : strlen(fmt);
         const int n      = vsprintf_wrapper (0, buffer, bufsiz, fmt);
@@ -242,11 +242,11 @@ static void test_swprintf (void)
 
     wchar_t buffer[8];
     char narrow[8], narrow_fmt[16];
-    const int bufsiz = sizeof buffer / sizeof buffer[0];
+    const int bufsiz = ARRAY_SIZE(buffer);
     unsigned int i;
 
     /* Legacy _snprintf style termination */
-    for (i = 0; i < sizeof tests / sizeof tests[0]; i++) {
+    for (i = 0; i < ARRAY_SIZE(tests); i++) {
         const wchar_t *fmt = tests[i];
         const int expect   = wcslen(fmt) > bufsiz ? -1 : wcslen(fmt);
         const int n        = vswprintf_wrapper (UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION, buffer, bufsiz, fmt);
@@ -261,7 +261,7 @@ static void test_swprintf (void)
     }
 
     /* C99 snprintf style termination */
-    for (i = 0; i < sizeof tests / sizeof tests[0]; i++) {
+    for (i = 0; i < ARRAY_SIZE(tests); i++) {
         const wchar_t *fmt = tests[i];
         const int expect   = wcslen(fmt);
         const int n        = vswprintf_wrapper (UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR, buffer, bufsiz, fmt);
@@ -278,7 +278,7 @@ static void test_swprintf (void)
     }
 
     /* swprintf style termination */
-    for (i = 0; i < sizeof tests / sizeof tests[0]; i++) {
+    for (i = 0; i < ARRAY_SIZE(tests); i++) {
         const wchar_t *fmt = tests[i];
         const int expect   = wcslen(fmt) >= bufsiz ? -2 : wcslen(fmt);
         const int n        = vswprintf_wrapper (0, buffer, bufsiz, fmt);
@@ -411,12 +411,12 @@ static void test_fwprintf(void)
     p_fclose(fp);
 
     fp = p_fopen(file_name, "rb");
-    p_fgetws(bufw, sizeof(bufw)/sizeof(bufw[0]), fp);
+    p_fgetws(bufw, ARRAY_SIZE(bufw), fp);
     ret = p_ftell(fp);
     ok(ret == 24, "ftell returned %d\n", ret);
     ok(!wcscmp(bufw, simple), "buf = %s\n", wine_dbgstr_w(bufw));
 
-    p_fgetws(bufw, sizeof(bufw)/sizeof(bufw[0]), fp);
+    p_fgetws(bufw, ARRAY_SIZE(bufw), fp);
     ret = p_ftell(fp);
     ok(ret == 52, "ret = %d\n", ret);
     ok(!memcmp(bufw, cont, 28), "buf = %s\n", wine_dbgstr_w(bufw));
-- 
2.14.3




More information about the wine-patches mailing list