[PATCH] winhlp32: Use the ARRAY_SIZE() macro

Michael Stefaniuc mstefani at winehq.org
Fri Aug 10 05:27:55 CDT 2018


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
 programs/winhlp32/macro.c     | 2 +-
 programs/winhlp32/macro.lex.l | 8 ++++----
 programs/winhlp32/winhelp.c   | 6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/programs/winhlp32/macro.c b/programs/winhlp32/macro.c
index 5a25d6c944..280e618236 100644
--- a/programs/winhlp32/macro.c
+++ b/programs/winhlp32/macro.c
@@ -154,7 +154,7 @@ void CALLBACK MACRO_About(void)
     WCHAR name[256];
     HICON icon = LoadImageW( Globals.hInstance, MAKEINTRESOURCEW(IDI_WINHELP),
                              IMAGE_ICON, 48, 48, LR_SHARED );
-    LoadStringW( Globals.hInstance, STID_WINE_HELP, name, sizeof(name)/sizeof(WCHAR) );
+    LoadStringW( Globals.hInstance, STID_WINE_HELP, name, ARRAY_SIZE( name ));
     ShellAboutW( MACRO_CurrentWindow()->hMainWnd, name, NULL, icon );
 }
 
diff --git a/programs/winhlp32/macro.lex.l b/programs/winhlp32/macro.lex.l
index 8f6945ca98..eab7a795af 100644
--- a/programs/winhlp32/macro.lex.l
+++ b/programs/winhlp32/macro.lex.l
@@ -75,7 +75,7 @@ struct lexret  yylval;
         /* opening a new one */
         if (lex_data->quote_stk_idx == 0)
         {
-            assert(lex_data->cache_used < sizeof(lex_data->cache_string) / sizeof(lex_data->cache_string[0]));
+            assert(lex_data->cache_used < ARRAY_SIZE(lex_data->cache_string));
             lex_data->strptr = lex_data->cache_string[lex_data->cache_used] = HeapAlloc(GetProcessHeap(), 0, strlen(lex_data->macroptr) + 1);
             yylval.string = lex_data->strptr;
             lex_data->cache_used++;
@@ -83,7 +83,7 @@ struct lexret  yylval;
         }
         else *lex_data->strptr++ = yytext[0];
         lex_data->quote_stack[lex_data->quote_stk_idx++] = yytext[0];
-        assert(lex_data->quote_stk_idx < sizeof(lex_data->quote_stack) / sizeof(lex_data->quote_stack[0]));
+        assert(lex_data->quote_stk_idx < ARRAY_SIZE(lex_data->quote_stack));
     }
     else
     {
@@ -222,7 +222,7 @@ CheckArgs_end:
 static int MACRO_CallBoolFunc(void *fn, const char* args, void** ret)
 {
     void*       pa[2];
-    int         idx = MACRO_CheckArgs(pa, sizeof(pa)/sizeof(pa[0]), args);
+    int         idx = MACRO_CheckArgs(pa, ARRAY_SIZE(pa), args);
 
     if (idx < 0) return 0;
     if (!fn)     return 1;
@@ -257,7 +257,7 @@ static int MACRO_CallBoolFunc(void *fn, const char* args, void** ret)
 static int MACRO_CallVoidFunc(void *fn, const char* args)
 {
     void*       pa[6];
-    int         idx = MACRO_CheckArgs(pa, sizeof(pa)/sizeof(pa[0]), args);
+    int         idx = MACRO_CheckArgs(pa, ARRAY_SIZE(pa), args);
 
     if (idx < 0) return 0;
     if (!fn)     return 1;
diff --git a/programs/winhlp32/winhelp.c b/programs/winhlp32/winhelp.c
index 2ac3d2ff24..8ee3d0410e 100644
--- a/programs/winhlp32/winhelp.c
+++ b/programs/winhlp32/winhelp.c
@@ -595,7 +595,7 @@ static void WINHELP_RememberPage(WINHELP_WINDOW* win, WINHELP_WNDPAGE* wpage)
 
     if (!Globals.history.index || Globals.history.set[0].page != wpage->page)
     {
-        num = sizeof(Globals.history.set) / sizeof(Globals.history.set[0]);
+        num = ARRAY_SIZE(Globals.history.set);
         /* we're full, remove latest entry */
         if (Globals.history.index == num)
         {
@@ -610,7 +610,7 @@ static void WINHELP_RememberPage(WINHELP_WINDOW* win, WINHELP_WNDPAGE* wpage)
     }
     if (win->hHistoryWnd) InvalidateRect(win->hHistoryWnd, NULL, TRUE);
 
-    num = sizeof(win->back.set) / sizeof(win->back.set[0]);
+    num = ARRAY_SIZE(win->back.set);
     if (win->back.index == num)
     {
         /* we're full, remove latest entry */
@@ -1136,7 +1136,7 @@ static LRESULT CALLBACK WINHELP_HistoryWndProc(HWND hWnd, UINT msg, WPARAM wPara
         GetWindowRect(hWnd, &r);
 
         r.right = r.left + 30 * tm.tmAveCharWidth;
-        r.bottom = r.top + (sizeof(Globals.history.set) / sizeof(Globals.history.set[0])) * tm.tmHeight;
+        r.bottom = r.top + ARRAY_SIZE(Globals.history.set) * tm.tmHeight;
         AdjustWindowRect(&r, GetWindowLongW(hWnd, GWL_STYLE), FALSE);
         if (r.left < 0) {r.right -= r.left; r.left = 0;}
         if (r.top < 0) {r.bottom -= r.top; r.top = 0;}
-- 
2.14.4




More information about the wine-devel mailing list