https://git.reactos.org/?p=reactos.git;a=commitdiff;h=516c8829eaa28553aac39…
commit 516c8829eaa28553aac397017becaa701521c99b
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Sep 26 02:38:37 2021 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Sep 26 02:38:37 2021 +0200
[IMAGESOFT] Use ARRAYSIZE / un-hardcode some sizeof(TYPE) where applicable.
---
modules/rosapps/applications/imagesoft/about.c | 2 +-
modules/rosapps/applications/imagesoft/adjust.c | 8 ++++----
modules/rosapps/applications/imagesoft/brightness.c | 2 +-
modules/rosapps/applications/imagesoft/contrast.c | 2 +-
modules/rosapps/applications/imagesoft/floatwindow.c | 7 +++----
modules/rosapps/applications/imagesoft/font.c | 2 +-
modules/rosapps/applications/imagesoft/imagesoft.c | 2 +-
modules/rosapps/applications/imagesoft/imgedwnd.c | 10 +++++-----
modules/rosapps/applications/imagesoft/mainwnd.c | 16 ++++++++--------
modules/rosapps/applications/imagesoft/opensave.c | 2 +-
modules/rosapps/applications/imagesoft/tooldock.c | 2 +-
11 files changed, 27 insertions(+), 28 deletions(-)
diff --git a/modules/rosapps/applications/imagesoft/about.c
b/modules/rosapps/applications/imagesoft/about.c
index a53af44d64e..32ba6a8a6de 100644
--- a/modules/rosapps/applications/imagesoft/about.c
+++ b/modules/rosapps/applications/imagesoft/about.c
@@ -32,7 +32,7 @@ AboutDialogProc(HWND hDlg,
LoadString(hInstance,
IDS_LICENSE,
strLicense,
- sizeof(strLicense) / sizeof(TCHAR));
+ ARRAYSIZE(strLicense));
SetWindowText(hLicenseEditWnd,
strLicense);
diff --git a/modules/rosapps/applications/imagesoft/adjust.c
b/modules/rosapps/applications/imagesoft/adjust.c
index 90ca2bf3f8a..f3ba1986e82 100644
--- a/modules/rosapps/applications/imagesoft/adjust.c
+++ b/modules/rosapps/applications/imagesoft/adjust.c
@@ -15,7 +15,7 @@ DisplayBlackAndWhite(HWND hwnd,
RECT rc;
GetObject(hBitmap,
- sizeof(BITMAP),
+ sizeof(bitmap),
&bitmap);
/* Bitmap header */
@@ -112,7 +112,7 @@ DisplayInvertedColors(HWND hwnd,
RECT rc;
GetObject(hBitmap,
- sizeof(BITMAP),
+ sizeof(bitmap),
&bitmap);
/* Bitmap header */
@@ -206,7 +206,7 @@ DisplayBlur(HWND hwnd,
RECT rc;
GetObject(hBitmap,
- sizeof(BITMAP),
+ sizeof(bitmap),
&bitmap);
/* Bitmap header */
@@ -367,7 +367,7 @@ DisplaySharpness(HWND hwnd,
RECT rc;
GetObject(hBitmap,
- sizeof(BITMAP),
+ sizeof(bitmap),
&bitmap);
/* Bitmap header */
diff --git a/modules/rosapps/applications/imagesoft/brightness.c
b/modules/rosapps/applications/imagesoft/brightness.c
index 265237ea446..d596e291189 100644
--- a/modules/rosapps/applications/imagesoft/brightness.c
+++ b/modules/rosapps/applications/imagesoft/brightness.c
@@ -21,7 +21,7 @@ AdjustBrightness(HBITMAP hOrigBitmap,
RECT rc;
GetObject(hNewBitmap,
- sizeof(BITMAP),
+ sizeof(bitmap),
&bitmap);
/* Bitmap header */
diff --git a/modules/rosapps/applications/imagesoft/contrast.c
b/modules/rosapps/applications/imagesoft/contrast.c
index 7a885358d99..defb31a68fa 100644
--- a/modules/rosapps/applications/imagesoft/contrast.c
+++ b/modules/rosapps/applications/imagesoft/contrast.c
@@ -21,7 +21,7 @@ AdjustContrast(HBITMAP hOrigBitmap,
RECT rc;
GetObject(hNewBitmap,
- sizeof(BITMAP),
+ sizeof(bitmap),
&bitmap);
/* Bitmap header */
diff --git a/modules/rosapps/applications/imagesoft/floatwindow.c
b/modules/rosapps/applications/imagesoft/floatwindow.c
index da831e1959a..71eceb6c7f5 100644
--- a/modules/rosapps/applications/imagesoft/floatwindow.c
+++ b/modules/rosapps/applications/imagesoft/floatwindow.c
@@ -58,8 +58,7 @@ FloatToolbarCreateToolsGui(PMAIN_WND_INFO Info)
HIMAGELIST hImageList;
UINT NumButtons;
- NumButtons = sizeof(ToolsButtons) / sizeof(ToolsButtons[0]);
-
+ NumButtons = ARRAYSIZE(ToolsButtons);
hTb = CreateWindowEx(0,
TOOLBARCLASSNAME,
NULL,
@@ -293,7 +292,7 @@ FloatToolbarCreateHistoryGui(PMAIN_WND_INFO Info)
if (hList == NULL)
return FALSE;
- NumButtons = sizeof(HistoryButtons) / sizeof(HistoryButtons[0]);
+ NumButtons = ARRAYSIZE(HistoryButtons);
hButtons = CreateWindowEx(0,
TOOLBARCLASSNAME,
NULL,
@@ -603,7 +602,7 @@ InitFloatWndClass(VOID)
{
WNDCLASSEX wc = {0};
- wc.cbSize = sizeof(WNDCLASSEX);
+ wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = FloatToolbarWndProc;
wc.hInstance = hInstance;
diff --git a/modules/rosapps/applications/imagesoft/font.c
b/modules/rosapps/applications/imagesoft/font.c
index e8540f65310..62d07e6879e 100644
--- a/modules/rosapps/applications/imagesoft/font.c
+++ b/modules/rosapps/applications/imagesoft/font.c
@@ -16,7 +16,7 @@ EnumFontSizes(ENUMLOGFONTEX *lpelfe,
if (fTrueType)
{
- for (i = 0; i < (sizeof(ttsizes) / sizeof(ttsizes[0])); i++)
+ for (i = 0; i < ARRAYSIZE(ttsizes); i++)
{
wsprintf(ach, _T("%d"), ttsizes[i]);
diff --git a/modules/rosapps/applications/imagesoft/imagesoft.c
b/modules/rosapps/applications/imagesoft/imagesoft.c
index e673a3405d2..c54300763e7 100644
--- a/modules/rosapps/applications/imagesoft/imagesoft.c
+++ b/modules/rosapps/applications/imagesoft/imagesoft.c
@@ -20,7 +20,7 @@ _tWinMain(HINSTANCE hThisInstance,
hInstance = hThisInstance;
ProcessHeap = GetProcessHeap();
- icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwSize = sizeof(icex);
icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES;
InitCommonControlsEx(&icex);
diff --git a/modules/rosapps/applications/imagesoft/imgedwnd.c
b/modules/rosapps/applications/imagesoft/imgedwnd.c
index c9342080461..846e50f294e 100644
--- a/modules/rosapps/applications/imagesoft/imgedwnd.c
+++ b/modules/rosapps/applications/imagesoft/imgedwnd.c
@@ -65,14 +65,14 @@ LoadDIBImage(PEDIT_WND_INFO Info)
bSuccess = ReadFile(hFile,
&bmfh,
- sizeof(BITMAPFILEHEADER),
+ sizeof(bmfh),
&BytesRead,
NULL);
- if (bSuccess && (BytesRead == sizeof(BITMAPFILEHEADER))
+ if (bSuccess && (BytesRead == sizeof(bmfh))
&& (bmfh.bfType == *(WORD *)"BM"))
{
- DWORD InfoSize = bmfh.bfOffBits - sizeof(BITMAPFILEHEADER);
+ DWORD InfoSize = bmfh.bfOffBits - sizeof(bmfh);
Info->pbmi = HeapAlloc(ProcessHeap,
0,
@@ -102,7 +102,7 @@ LoadDIBImage(PEDIT_WND_INFO Info)
NULL);
GetObject(Info->hBitmap,
- sizeof(BITMAP),
+ sizeof(bitmap),
&bitmap);
Info->Width = bitmap.bmWidth;
@@ -514,7 +514,7 @@ InitImageEditWindowImpl(VOID)
{
WNDCLASSEX wc = {0};
- wc.cbSize = sizeof(WNDCLASSEX);
+ wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = ImageEditWndProc;
wc.hInstance = hInstance;
diff --git a/modules/rosapps/applications/imagesoft/mainwnd.c
b/modules/rosapps/applications/imagesoft/mainwnd.c
index 551b53ab692..b3373af9cf3 100644
--- a/modules/rosapps/applications/imagesoft/mainwnd.c
+++ b/modules/rosapps/applications/imagesoft/mainwnd.c
@@ -129,7 +129,7 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
case ID_TOOLBAR_STANDARD:
{
Buttons = StdButtons;
- NumButtons = sizeof(StdButtons) / sizeof(StdButtons[0]);
+ NumButtons = ARRAYSIZE(StdButtons);
StartImageRes = IDB_MAINNEWICON;
NumImages = 10;
break;
@@ -138,7 +138,7 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
case ID_TOOLBAR_TEXT:
{
Buttons = TextButtons;
- NumButtons = sizeof(TextButtons) / sizeof(TextButtons[0]);
+ NumButtons = ARRAYSIZE(TextButtons);
StartImageRes = IDB_TEXTBOLD;
NumImages = 6;
break;
@@ -493,7 +493,7 @@ MainWndMoveFloatingWindows(PMAIN_WND_INFO Info,
CopyMemory(wndOldPos,
&wndNewPos,
- sizeof(RECT));
+ sizeof(wndOldPos));
}
}
@@ -665,7 +665,7 @@ CreateToolbars(PMAIN_WND_INFO Info)
{
UINT i;
- for (i = 0; i < sizeof(MainDockBars) / sizeof(MainDockBars[0]); i++)
+ for (i = 0; i < ARRAYSIZE(MainDockBars); i++)
{
/* FIXME - lookup whether to display the toolbar */
TbdAddToolbar(&Info->ToolDocks,
@@ -774,7 +774,7 @@ InitMainWnd(PMAIN_WND_INFO Info)
if (Info->hStatus != NULL)
SendMessage(Info->hStatus,
SB_SETPARTS,
- sizeof(statwidths)/sizeof(int),
+ ARRAYSIZE(statwidths),
(LPARAM)statwidths);
/* create the MDI client window */
@@ -1170,13 +1170,13 @@ MainWndProc(HWND hwnd,
if (!MainWndMenuHint(Info,
LOWORD(wParam),
MainMenuHintTable,
- sizeof(MainMenuHintTable) /
sizeof(MainMenuHintTable[0]),
+ ARRAYSIZE(MainMenuHintTable),
IDS_HINT_BLANK))
{
MainWndMenuHint(Info,
LOWORD(wParam),
SystemMenuHintTable,
- sizeof(SystemMenuHintTable) /
sizeof(SystemMenuHintTable[0]),
+ ARRAYSIZE(SystemMenuHintTable),
IDS_HINT_BLANK);
}
}
@@ -1428,7 +1428,7 @@ InitMainWindowImpl(VOID)
{
WNDCLASSEX wc = {0};
- wc.cbSize = sizeof(WNDCLASSEX);
+ wc.cbSize = sizeof(wc);
wc.lpfnWndProc = MainWndProc;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance,
diff --git a/modules/rosapps/applications/imagesoft/opensave.c
b/modules/rosapps/applications/imagesoft/opensave.c
index 9fccbb8b64b..1d668bfd894 100644
--- a/modules/rosapps/applications/imagesoft/opensave.c
+++ b/modules/rosapps/applications/imagesoft/opensave.c
@@ -8,7 +8,7 @@ static OPENFILENAME ofn;
VOID FileInitialize(HWND hwnd)
{
ZeroMemory(&ofn, sizeof(ofn));
- ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.nMaxFile = MAX_PATH;
ofn.nMaxFileTitle = MAX_PATH;
diff --git a/modules/rosapps/applications/imagesoft/tooldock.c
b/modules/rosapps/applications/imagesoft/tooldock.c
index 84c513b27a4..a4716b45866 100644
--- a/modules/rosapps/applications/imagesoft/tooldock.c
+++ b/modules/rosapps/applications/imagesoft/tooldock.c
@@ -1117,7 +1117,7 @@ TbdInitImpl(VOID)
{
WNDCLASSEX wc = {0};
- wc.cbSize = sizeof(WNDCLASSEX);
+ wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = ToolDockWndProc;
wc.cbWndExtra = TD_EXTRA_BYTES;