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

Michael Stefaniuc mstefani at winehq.org
Wed Jun 20 16:35:09 CDT 2018


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
 dlls/msvcrt/tests/cpp.c    |  6 +++---
 dlls/msvcrt/tests/dir.c    | 16 ++++++++--------
 dlls/msvcrt/tests/file.c   | 23 +++++++++++-----------
 dlls/msvcrt/tests/locale.c |  6 +++---
 dlls/msvcrt/tests/misc.c   |  4 ++--
 dlls/msvcrt/tests/printf.c |  4 ++--
 dlls/msvcrt/tests/string.c | 48 +++++++++++++++++++++++-----------------------
 7 files changed, 53 insertions(+), 54 deletions(-)

diff --git a/dlls/msvcrt/tests/cpp.c b/dlls/msvcrt/tests/cpp.c
index cf5e4c7d60..07b49ae755 100644
--- a/dlls/msvcrt/tests/cpp.c
+++ b/dlls/msvcrt/tests/cpp.c
@@ -1108,8 +1108,8 @@ static void test_demangle_datatype(void)
 	{ "?AV?$CDB_GEN_BIG_ENUM_FLAG at W4CDB_WYSIWYG_BITS_ENUM@@$01@@@", "?AV?$CDB_GEN_BIG_ENUM_FLAG at W4CDB_WYSIWYG_BITS_ENUM@@$01@@@", FALSE},
 /*	{ "?AV?$CDB_GEN_BIG_ENUM_FLAG at W4CDB_WYSIWYG_BITS_ENUM@@$011@@@", "?AV?$CDB_GEN_BIG_ENUM_FLAG at W4CDB_WYSIWYG_BITS_ENUM@@$011@@@",FALSE}, */
     };
-    int i, num_test = (sizeof(demangle)/sizeof(struct _demangle));
-    
+    int i, num_test = ARRAY_SIZE(demangle);
+
     for (i = 0; i < num_test; i++)
     {
 	name = p__unDName(0, demangle[i].mangled, 0, pmalloc, pfree, 0x2800);
@@ -1326,7 +1326,7 @@ static void test_demangle(void)
 /* 130 */ {"??_E?$TStrArray@$$BY0BAA at D$0BA@@@UAEPAXI at Z",
            "public: virtual void * __thiscall TStrArray<char [256],16>::`vector deleting destructor'(unsigned int)"},
     };
-    int i, num_test = (sizeof(test)/sizeof(test[0]));
+    int i, num_test = ARRAY_SIZE(test);
     char* name;
 
     for (i = 0; i < num_test; i++)
diff --git a/dlls/msvcrt/tests/dir.c b/dlls/msvcrt/tests/dir.c
index a29d32b9d3..210cf3983c 100644
--- a/dlls/msvcrt/tests/dir.c
+++ b/dlls/msvcrt/tests/dir.c
@@ -97,7 +97,7 @@ static void test_makepath(void)
 
     unsigned int i, n;
 
-    for (i = 0; i < sizeof(makepath_cases)/sizeof(makepath_cases[0]); ++i)
+    for (i = 0; i < ARRAY_SIZE(makepath_cases); ++i)
     {
         const makepath_case* p = &makepath_cases[i];
 
@@ -253,7 +253,7 @@ static void test_makepath_s(void)
     ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
 
     /* Test with the normal _makepath cases. */
-    for (i = 0; i < sizeof(makepath_cases)/sizeof(makepath_cases[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(makepath_cases); i++)
     {
         const makepath_case *p = makepath_cases + i;
 
@@ -296,7 +296,7 @@ static void test_makepath_s(void)
     }
 
     /* Try insufficient length cases. */
-    for (i = 0; i < sizeof(makepath_s_cases)/sizeof(makepath_s_cases[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(makepath_s_cases); i++)
     {
         const makepath_s_case *p = makepath_s_cases + i;
 
@@ -457,12 +457,12 @@ static void test_searchenv(void)
     ok(path_len, "GetTempPath failed\n");
     memcpy(path, tmppath, path_len);
 
-    for(i=0; i<sizeof(dirs)/sizeof(*dirs); i++) {
+    for (i=0; i<ARRAY_SIZE(dirs); i++) {
         strcpy(path+path_len, dirs[i]);
 	ok(!mkdir(path), "mkdir failed (dir = %s)\n", path);
     }
 
-    for(i=0; i<sizeof(files)/sizeof(*files); i++) {
+    for (i=0; i<ARRAY_SIZE(files); i++) {
         strcpy(path+path_len, files[i]);
         tmp_file = fopen(path, "wb");
 	ok(tmp_file != NULL, "fopen failed (file = %s)\n", path);
@@ -471,7 +471,7 @@ static void test_searchenv(void)
 
     strcpy(env1, "TEST_PATH=");
     strcpy(env2, "TEST_PATH=;");
-    for(i=1; i<sizeof(dirs)/sizeof(*dirs); i++) {
+    for (i=1; i<ARRAY_SIZE(dirs); i++) {
         strcat(env1, tmppath);
         strcat(env1, dirs[i]);
         strcat(env1, ";");
@@ -599,12 +599,12 @@ static void test_searchenv(void)
 
     putenv("TEST_PATH=");
 
-    for(i=sizeof(files)/sizeof(*files)-1; i>=0; i--) {
+    for (i=ARRAY_SIZE(files)-1; i>=0; i--) {
         strcpy(path+path_len, files[i]);
         ok(!remove(path), "remove failed (file = %s)\n", path);
     }
 
-    for(i=sizeof(dirs)/sizeof(*dirs)-1; i>=0; i--) {
+    for (i=ARRAY_SIZE(dirs)-1; i>=0; i--) {
         strcpy(path+path_len, dirs[i]);
         ok(!rmdir(path), "rmdir failed (dir = %s)\n", path);
     }
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c
index 136ee1563e..fe62d5c385 100644
--- a/dlls/msvcrt/tests/file.c
+++ b/dlls/msvcrt/tests/file.c
@@ -144,7 +144,7 @@ static void test_fileops( void )
     write (fd, outbuffer, sizeof (outbuffer));
     close (fd);
 
-    for (bufmode=0; bufmode < sizeof(bufmodes)/sizeof(bufmodes[0]); bufmode++)
+    for (bufmode=0; bufmode < ARRAY_SIZE(bufmodes); bufmode++)
     {
         fd = open ("fdopen.tst", O_RDONLY | O_BINARY);
         file = fdopen (fd, "rb");
@@ -195,13 +195,13 @@ static void test_fileops( void )
     }
     fd = open ("fdopen.tst", O_RDONLY | O_TEXT);
     file = fdopen (fd, "rt"); /* open in TEXT mode */
-    ok(fgetws(wbuffer,sizeof(wbuffer)/sizeof(wbuffer[0]),file) !=0,"fgetws failed unexpected\n");
-    ok(fgetws(wbuffer,sizeof(wbuffer)/sizeof(wbuffer[0]),file) ==0,"fgetws didn't signal EOF\n");
+    ok(fgetws(wbuffer,ARRAY_SIZE(wbuffer),file) !=0,"fgetws failed unexpected\n");
+    ok(fgetws(wbuffer,ARRAY_SIZE(wbuffer),file) ==0,"fgetws didn't signal EOF\n");
     ok(feof(file) !=0,"feof doesn't signal EOF\n");
     rewind(file);
     ok(fgetws(wbuffer,strlen(outbuffer),file) !=0,"fgetws failed unexpected\n");
     ok(lstrlenW(wbuffer) == (lstrlenA(outbuffer) -1),"fgetws didn't read right size\n");
-    ok(fgetws(wbuffer,sizeof(outbuffer)/sizeof(outbuffer[0]),file) !=0,"fgets failed unexpected\n");
+    ok(fgetws(wbuffer,ARRAY_SIZE(outbuffer),file) !=0,"fgets failed unexpected\n");
     ok(lstrlenW(wbuffer) == 1,"fgets dropped chars\n");
     fclose (file);
 
@@ -624,7 +624,7 @@ static void test_flsbuf( void )
   static const int bufmodes[] = {_IOFBF,_IONBF};
 
   tempf=_tempnam(".","wne");
-  for (bufmode=0; bufmode < sizeof(bufmodes)/sizeof(bufmodes[0]); bufmode++)
+  for (bufmode=0; bufmode < ARRAY_SIZE(bufmodes); bufmode++)
   {
     tempfh = fopen(tempf,"wb");
     setvbuf(tempfh,NULL,bufmodes[bufmode],2048);
@@ -878,8 +878,7 @@ static void test_fgetwc_locale(const char* text, const char* locale, int codepag
     {
         /* mbstowcs rejects invalid multibyte sequence,
            so we use MultiByteToWideChar here. */
-        ret = MultiByteToWideChar(codepage, 0, text, -1,
-                                  wtextW, sizeof(wtextW)/sizeof(wtextW[0]));
+        ret = MultiByteToWideChar(codepage, 0, text, -1, wtextW, ARRAY_SIZE(wtextW));
         ok(ret > 0, "MultiByteToWideChar failed\n");
     }
     else
@@ -910,7 +909,7 @@ static void test_fgetwc_locale(const char* text, const char* locale, int codepag
 
     tempfh = fopen(tempfile, "rb");
     ok(tempfh != NULL, "can't open tempfile\n");
-    for (i = 0; i < sizeof(wchar_text)/sizeof(wchar_text[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(wchar_text); i++)
     {
         ch = fgetwc(tempfh);
         ok(ch == wchar_text[i], "got %04hx, expected %04x (cp%d[%d])\n", ch, wchar_text[i], codepage, i);
@@ -946,7 +945,7 @@ static void test_fgetwc_unicode(void)
 
     tempfh = fopen(tempfile, "rt,ccs=unicode");
     ok(tempfh != NULL, "can't open tempfile\n");
-    for (i = 1; i < sizeof(wchar_text)/sizeof(wchar_text[0]); i++)
+    for (i = 1; i < ARRAY_SIZE(wchar_text); i++)
     {
         ch = fgetwc(tempfh);
         ok(ch == wchar_text[i],
@@ -958,7 +957,7 @@ static void test_fgetwc_unicode(void)
 
     tempfh = fopen(tempfile, "wb");
     ok(tempfh != NULL, "can't open tempfile\n");
-    ret = WideCharToMultiByte(CP_UTF8, 0, wchar_text, sizeof(wchar_text)/sizeof(wchar_text[0]),
+    ret = WideCharToMultiByte(CP_UTF8, 0, wchar_text, ARRAY_SIZE(wchar_text),
                               utf8_text, sizeof(utf8_text), NULL, NULL);
     ok(ret > 0, "utf-8 conversion failed\n");
     fwrite(utf8_text, sizeof(char), ret, tempfh);
@@ -966,7 +965,7 @@ static void test_fgetwc_unicode(void)
 
     tempfh = fopen(tempfile, "rt, ccs=UTF-8");
     ok(tempfh != NULL, "can't open tempfile\n");
-    for (i = 1; i < sizeof(wchar_text)/sizeof(wchar_text[0]); i++)
+    for (i = 1; i < ARRAY_SIZE(wchar_text); i++)
     {
         ch = fgetwc(tempfh);
         ok(ch == wchar_text[i],
@@ -2659,5 +2658,5 @@ START_TEST(file)
     /* Wait for the (_P_NOWAIT) spawned processes to finish to make sure the report
      * file contains lines in the correct order
      */
-    WaitForMultipleObjects(sizeof(proc_handles)/sizeof(proc_handles[0]), proc_handles, TRUE, 5000);
+    WaitForMultipleObjects(ARRAY_SIZE(proc_handles), proc_handles, TRUE, 5000);
 }
diff --git a/dlls/msvcrt/tests/locale.c b/dlls/msvcrt/tests/locale.c
index 024afc15b3..ff777599aa 100644
--- a/dlls/msvcrt/tests/locale.c
+++ b/dlls/msvcrt/tests/locale.c
@@ -643,7 +643,7 @@ static void test_crtGetStringTypeW(void)
         return;
     }
 
-    for(i=0; i<sizeof(str)/sizeof(*str); i++) {
+    for(i=0; i<ARRAY_SIZE(str); i++) {
         ret_crt = p__crtGetStringTypeW(0, CT_CTYPE1, str[i], 1, &out_crt);
         ret = GetStringTypeW(CT_CTYPE1, str[i], 1, &out);
         ok(ret == ret_crt, "%d) ret_crt = %d\n", i, (int)ret_crt);
@@ -708,7 +708,7 @@ static void test__Gettnames(void)
     else
         ok(size==0x164 || broken(size==0xb8), "structure size: %x\n", size);
 
-    for (i = 0; i < sizeof(time_data)/sizeof(time_data[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(time_data); i++)
     {
         size = GetLocaleInfoA(MAKELCID(LANG_ENGLISH, SORT_DEFAULT),
                               time_data[i], buf, sizeof(buf));
@@ -722,7 +722,7 @@ static void test__Gettnames(void)
         return;
 
     ret = _Gettnames();
-    for (i = 0; i < sizeof(time_data)/sizeof(time_data[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(time_data); i++)
     {
         size = GetLocaleInfoA(MAKELCID(LANG_GERMAN, SORT_DEFAULT),
                               time_data[i], buf, sizeof(buf));
diff --git a/dlls/msvcrt/tests/misc.c b/dlls/msvcrt/tests/misc.c
index 017ae7758a..c170d23225 100644
--- a/dlls/msvcrt/tests/misc.c
+++ b/dlls/msvcrt/tests/misc.c
@@ -164,7 +164,7 @@ static void test_I10_OUTPUT(void)
     if (j != 12)
         trace("sizeof(long double) = %d on this machine\n", j);
 
-    for(i=0; i<sizeof(I10_OUTPUT_tests)/sizeof(I10_OUTPUT_test); i++) {
+    for(i=0; i<ARRAY_SIZE(I10_OUTPUT_tests); i++) {
         memset(out.str, '#', sizeof(out.str));
 
         if (sizeof(long double) == 12)
@@ -621,7 +621,7 @@ static void test__lfind_s(void)
     }
 
     key = 1234;
-    num = sizeof(tests)/sizeof(tests[0]);
+    num = ARRAY_SIZE(tests);
 
     errno = 0xdeadbeef;
     found = p_lfind_s(NULL, tests, &num, sizeof(int), _lfind_s_comp, NULL);
diff --git a/dlls/msvcrt/tests/printf.c b/dlls/msvcrt/tests/printf.c
index 64658ce25f..80180ff8b2 100644
--- a/dlls/msvcrt/tests/printf.c
+++ b/dlls/msvcrt/tests/printf.c
@@ -841,7 +841,7 @@ static void test_snprintf (void)
     const int bufsiz = sizeof buffer;
     unsigned int i;
 
-    for (i = 0; i < sizeof tests / sizeof tests[0]; i++) {
+    for (i = 0; i < ARRAY_SIZE(tests); i++) {
         const char *fmt  = tests[i].format;
         const int expect = tests[i].expected;
         const int n      = _snprintf (buffer, bufsiz, fmt);
@@ -1215,7 +1215,7 @@ static void test_vsnwprintf(void)
     wchar_t str[32];
     char buf[32];
 
-    ret = _vsnwprintf_wrapper( str, sizeof(str)/sizeof(str[0]), format, one, two, three );
+    ret = _vsnwprintf_wrapper( str, ARRAY_SIZE(str), format, one, two, three );
 
     ok( ret == 11, "got %d expected 11\n", ret );
     WideCharToMultiByte( CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL );
diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c
index 07458d4474..744035a1b8 100644
--- a/dlls/msvcrt/tests/string.c
+++ b/dlls/msvcrt/tests/string.c
@@ -1014,7 +1014,7 @@ static void test_wcscpy_s(void)
         return;
     }
 
-    ret = p_wcsncpy_s(NULL, 18, szLongText, sizeof(szLongText)/sizeof(WCHAR));
+    ret = p_wcsncpy_s(NULL, 18, szLongText, ARRAY_SIZE(szLongText));
     ok(ret == EINVAL, "p_wcsncpy_s expect EINVAL got %d\n", ret);
 
     szDest[0] = 'A';
@@ -1028,16 +1028,16 @@ static void test_wcscpy_s(void)
     ok(szDest[0] == 0, "szDest[0] not 0\n");
 
     szDest[0] = 'A';
-    ret = p_wcsncpy_s(szDest, 0, szLongText, sizeof(szLongText)/sizeof(WCHAR));
+    ret = p_wcsncpy_s(szDest, 0, szLongText, ARRAY_SIZE(szLongText));
     ok(ret == ERANGE || ret == EINVAL, "expected ERANGE/EINVAL got %d\n", ret);
     ok(szDest[0] == 0 || ret == EINVAL, "szDest[0] not 0\n");
 
-    ret = p_wcsncpy_s(szDest, 18, szLongText, sizeof(szLongText)/sizeof(WCHAR));
+    ret = p_wcsncpy_s(szDest, 18, szLongText, ARRAY_SIZE(szLongText));
     ok(ret == 0, "expected 0 got %d\n", ret);
     ok(lstrcmpW(szDest, szLongText) == 0, "szDest != szLongText\n");
 
     szDest[0] = 'A';
-    ret = p_wcsncpy_s(szDestShort, 8, szLongText, sizeof(szLongText)/sizeof(WCHAR));
+    ret = p_wcsncpy_s(szDestShort, 8, szLongText, ARRAY_SIZE(szLongText));
     ok(ret == ERANGE || ret == EINVAL, "expected ERANGE/EINVAL got %d\n", ret);
     ok(szDestShort[0] == 0, "szDestShort[0] not 0\n");
 
@@ -1065,7 +1065,7 @@ static void test__wcsupr_s(void)
     static const WCHAR expectedString[] = {'M', 'I', 'X', 'E', 'D', 'L', 'O',
                                            'W', 'E', 'R', 'U', 'P', 'P', 'E',
                                            'R', 0};
-    WCHAR testBuffer[2*sizeof(mixedString)/sizeof(WCHAR)];
+    WCHAR testBuffer[2*ARRAY_SIZE(mixedString)];
     int ret;
 
     if (!p_wcsupr_s)
@@ -1082,7 +1082,7 @@ static void test__wcsupr_s(void)
 
     /* Test NULL input string and valid size. */
     errno = EBADF;
-    ret = p_wcsupr_s(NULL, sizeof(testBuffer)/sizeof(WCHAR));
+    ret = p_wcsupr_s(NULL, ARRAY_SIZE(testBuffer));
     ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
     ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
 
@@ -1126,21 +1126,21 @@ static void test__wcsupr_s(void)
 
     /* Test normal string uppercasing. */
     wcscpy(testBuffer, mixedString);
-    ret = p_wcsupr_s(testBuffer, sizeof(mixedString)/sizeof(WCHAR));
+    ret = p_wcsupr_s(testBuffer, ARRAY_SIZE(mixedString));
     ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
     ok(!wcscmp(testBuffer, expectedString), "Expected the string to be fully upper-case\n");
 
     /* Test uppercasing with a shorter buffer size count. */
     wcscpy(testBuffer, mixedString);
     errno = EBADF;
-    ret = p_wcsupr_s(testBuffer, sizeof(mixedString)/sizeof(WCHAR) - 1);
+    ret = p_wcsupr_s(testBuffer, ARRAY_SIZE(mixedString) - 1);
     ok(ret == EINVAL, "Expected _wcsupr_s to fail with EINVAL, got %d\n", ret);
     ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
     ok(testBuffer[0] == '\0', "Expected the first buffer character to be null\n");
 
     /* Test uppercasing with a longer buffer size count. */
     wcscpy(testBuffer, mixedString);
-    ret = p_wcsupr_s(testBuffer, sizeof(testBuffer)/sizeof(WCHAR));
+    ret = p_wcsupr_s(testBuffer, ARRAY_SIZE(testBuffer));
     ok(ret == 0, "Expected _wcsupr_s to succeed, got %d\n", ret);
     ok(!wcscmp(testBuffer, expectedString), "Expected the string to be fully upper-case\n");
 }
@@ -1152,7 +1152,7 @@ static void test__wcslwr_s(void)
     static const WCHAR expectedString[] = {'m', 'i', 'x', 'e', 'd', 'l', 'o',
                                            'w', 'e', 'r', 'u', 'p', 'p', 'e',
                                            'r', 0};
-    WCHAR buffer[2*sizeof(mixedString)/sizeof(WCHAR)];
+    WCHAR buffer[2*ARRAY_SIZE(mixedString)];
     int ret;
 
     if (!p_wcslwr_s)
@@ -1169,7 +1169,7 @@ static void test__wcslwr_s(void)
 
     /* Test NULL input string and valid size. */
     errno = EBADF;
-    ret = p_wcslwr_s(NULL, sizeof(buffer)/sizeof(buffer[0]));
+    ret = p_wcslwr_s(NULL, ARRAY_SIZE(buffer));
     ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
     ok(errno == EINVAL, "expected errno EINVAL, got %d\n", errno);
 
@@ -1213,21 +1213,21 @@ static void test__wcslwr_s(void)
 
     /* Test normal string uppercasing. */
     wcscpy(buffer, mixedString);
-    ret = p_wcslwr_s(buffer, sizeof(mixedString)/sizeof(WCHAR));
+    ret = p_wcslwr_s(buffer, ARRAY_SIZE(mixedString));
     ok(ret == 0, "expected 0, got %d\n", ret);
     ok(!wcscmp(buffer, expectedString), "expected lowercase\n");
 
     /* Test uppercasing with a shorter buffer size count. */
     wcscpy(buffer, mixedString);
     errno = EBADF;
-    ret = p_wcslwr_s(buffer, sizeof(mixedString)/sizeof(WCHAR) - 1);
+    ret = p_wcslwr_s(buffer, ARRAY_SIZE(mixedString) - 1);
     ok(ret == EINVAL, "expected EINVAL, got %d\n", ret);
     ok(errno == EINVAL, "expected errno to be EINVAL, got %d\n", errno);
     ok(buffer[0] == '\0', "expected empty string\n");
 
     /* Test uppercasing with a longer buffer size count. */
     wcscpy(buffer, mixedString);
-    ret = p_wcslwr_s(buffer, sizeof(buffer)/sizeof(WCHAR));
+    ret = p_wcslwr_s(buffer, ARRAY_SIZE(buffer));
     ok(ret == 0, "expected 0, got %d\n", ret);
     ok(!wcscmp(buffer, expectedString), "expected lowercase\n");
 }
@@ -1243,7 +1243,7 @@ static void test_mbcjisjms(void)
     unsigned int i, j;
     int prev_cp = _getmbcp();
 
-    for (i = 0; i < sizeof(cp)/sizeof(cp[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(cp); i++)
     {
         _setmbcp(cp[i]);
         for (j = 0; jisjms[j][0] != 0; j++)
@@ -1271,7 +1271,7 @@ static void test_mbcjmsjis(void)
     unsigned int i, j;
     int prev_cp = _getmbcp();
 
-    for (i = 0; i < sizeof(cp)/sizeof(cp[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(cp); i++)
     {
         _setmbcp(cp[i]);
         for (j = 0; jmsjis[j][0] != 0; j++)
@@ -1298,7 +1298,7 @@ static void test_mbctohira(void)
     unsigned int prev_cp = _getmbcp();
 
     _setmbcp(_MB_CP_SBCS);
-    for (i = 0; i < sizeof(mbchira_932)/sizeof(mbchira_932[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(mbchira_932); i++)
     {
         int ret, exp = mbchira_932[i][0];
         ret = _mbctohira(mbchira_932[i][0]);
@@ -1306,7 +1306,7 @@ static void test_mbctohira(void)
     }
 
     _setmbcp(932);
-    for (i = 0; i < sizeof(mbchira_932)/sizeof(mbchira_932[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(mbchira_932); i++)
     {
         unsigned int ret, exp;
         ret = _mbctohira(mbchira_932[i][0]);
@@ -1327,7 +1327,7 @@ static void test_mbctokata(void)
     unsigned int prev_cp = _getmbcp();
 
     _setmbcp(_MB_CP_SBCS);
-    for (i = 0; i < sizeof(mbckata_932)/sizeof(mbckata_932[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(mbckata_932); i++)
     {
         int ret, exp = mbckata_932[i][0];
         ret = _mbctokata(mbckata_932[i][0]);
@@ -1335,7 +1335,7 @@ static void test_mbctokata(void)
     }
 
     _setmbcp(932);
-    for (i = 0; i < sizeof(mbckata_932)/sizeof(mbckata_932[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(mbckata_932); i++)
     {
         unsigned int ret, exp;
         ret = _mbctokata(mbckata_932[i][0]);
@@ -1356,7 +1356,7 @@ static void test_mbbtombc(void)
     int i, j;
     int prev_cp = _getmbcp();
 
-    for (i = 0; i < sizeof(cp)/sizeof(cp[0]); i++)
+    for (i = 0; i < ARRAY_SIZE(cp); i++)
     {
         _setmbcp(cp[i]);
         for (j = 0; mbbmbc[j][0] != 0; j++)
@@ -1409,13 +1409,13 @@ static void test_ismbckata(void) {
     unsigned int i;
 
     _setmbcp(_MB_CP_SBCS);
-    for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
+    for (i = 0; i < ARRAY_SIZE(tests); i++) {
         ret = _ismbckata(tests[i].c);
         ok(!ret, "expected 0, got %d for %04x\n", ret, tests[i].c);
     }
 
     _setmbcp(932);
-    for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
+    for (i = 0; i < ARRAY_SIZE(tests); i++) {
         ret = _ismbckata(tests[i].c);
         ok(!!ret == tests[i].exp, "expected %d, got %d for %04x\n",
            tests[i].exp, !!ret, tests[i].c);
@@ -2993,7 +2993,7 @@ static void test__wcstoi64(void)
     ok(ures == 071, "ures != 071\n");
 
     /* Test various unicode digits */
-    for (i = 0; i < sizeof(zeros) / sizeof(zeros[0]); ++i) {
+    for (i = 0; i < ARRAY_SIZE(zeros); ++i) {
         WCHAR tmp[] = {zeros[i] + 4, zeros[i], zeros[i] + 5, 0};
         res = p_wcstoi64(tmp, NULL, 0);
         ok(res == 405, "with zero = U+%04X: got %d, expected 405\n", zeros[i], (int)res);
-- 
2.14.4




More information about the wine-devel mailing list