oleview: Use the ARRAY_SIZE() macro.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2018-07-09 20:59:15 +02:00 committed by Alexandre Julliard
parent e9e96bc39a
commit 4341c4495f
5 changed files with 39 additions and 49 deletions

View File

@ -51,7 +51,7 @@ static void CreateRegRec(HKEY hKey, HTREEITEM parent, WCHAR *wszKeyName, BOOL ad
while(TRUE)
{
lenName = sizeof(wszName)/sizeof(WCHAR);
lenName = ARRAY_SIZE(wszName);
lenData = sizeof(wszData);
retEnum = RegEnumValueW(hKey, i, wszName, &lenName,
@ -120,7 +120,7 @@ static void CreateRegRec(HKEY hKey, HTREEITEM parent, WCHAR *wszKeyName, BOOL ad
{
i++;
if(RegEnumKeyW(hKey, i, wszName, sizeof(wszName)/sizeof(WCHAR)) != ERROR_SUCCESS) break;
if(RegEnumKeyW(hKey, i, wszName, ARRAY_SIZE(wszName)) != ERROR_SUCCESS) break;
if(RegOpenKeyW(hKey, wszName, &hCurKey) != ERROR_SUCCESS) continue;
@ -296,14 +296,12 @@ void RefreshDetails(HTREEITEM item)
memset(&tci, 0, sizeof(TCITEMW));
tci.mask = TCIF_TEXT;
tci.pszText = wszBuf;
tci.cchTextMax = sizeof(wszBuf)/sizeof(wszBuf[0]);
tci.cchTextMax = ARRAY_SIZE(wszBuf);
LoadStringW(globals.hMainInst, IDS_TAB_IMPL,
wszBuf, sizeof(wszBuf)/sizeof(wszBuf[0]));
LoadStringW(globals.hMainInst, IDS_TAB_IMPL, wszBuf, ARRAY_SIZE(wszBuf));
SendMessageW(details.hTab, TCM_INSERTITEMW, 1, (LPARAM)&tci);
LoadStringW(globals.hMainInst, IDS_TAB_ACTIV,
wszBuf, sizeof(wszBuf)/sizeof(wszBuf[0]));
LoadStringW(globals.hMainInst, IDS_TAB_ACTIV, wszBuf, ARRAY_SIZE(wszBuf));
SendMessageW(details.hTab, TCM_INSERTITEMW, 2, (LPARAM)&tci);
}
}
@ -331,13 +329,13 @@ static void CreateTabCtrl(HWND hWnd)
memset(&tci, 0, sizeof(TCITEMW));
tci.mask = TCIF_TEXT;
tci.pszText = buffer;
tci.cchTextMax = sizeof(buffer)/sizeof(buffer[0]);
tci.cchTextMax = ARRAY_SIZE(buffer);
details.hTab = CreateWindowW(WC_TABCONTROLW, NULL, WS_CHILD|WS_VISIBLE,
0, 0, 0, 0, hWnd, (HMENU)TAB_WINDOW, globals.hMainInst, NULL);
ShowWindow(details.hTab, SW_HIDE);
LoadStringW(globals.hMainInst, IDS_TAB_REG, buffer, sizeof(buffer)/sizeof(buffer[0]));
LoadStringW(globals.hMainInst, IDS_TAB_REG, buffer, ARRAY_SIZE(buffer));
SendMessageW(details.hTab, TCM_INSERTITEMW, 0, (LPARAM)&tci);
details.hReg = CreateWindowExW(WS_EX_CLIENTEDGE, WC_TREEVIEWW, NULL,

View File

@ -96,10 +96,9 @@ static INT_PTR CALLBACK InterfaceViewerProc(HWND hDlgWnd, UINT uMsg,
hRes = IPersistStream_IsDirty((IPersistStream *)unk);
IUnknown_Release(unk);
if(hRes == S_OK)
LoadStringW(globals.hMainInst, IDS_FALSE, wszBuf,
sizeof(wszBuf)/sizeof(wszBuf[0]));
else LoadStringW(globals.hMainInst, IDS_TRUE, wszBuf,
sizeof(wszBuf)/sizeof(wszBuf[0]));
LoadStringW(globals.hMainInst, IDS_FALSE, wszBuf, ARRAY_SIZE(wszBuf));
else
LoadStringW(globals.hMainInst, IDS_TRUE, wszBuf, ARRAY_SIZE(wszBuf));
hObject = GetDlgItem(hDlgWnd, IDC_ISDIRTY);
SetWindowTextW(hObject, wszBuf);
return TRUE;
@ -107,8 +106,7 @@ static INT_PTR CALLBACK InterfaceViewerProc(HWND hDlgWnd, UINT uMsg,
unk = GetInterface();
IPersistStream_GetSizeMax((IPersistStream *)unk, &size);
IUnknown_Release(unk);
LoadStringW(globals.hMainInst, IDS_BYTES, wszBuf,
sizeof(wszBuf)/sizeof(wszBuf[0]));
LoadStringW(globals.hMainInst, IDS_BYTES, wszBuf, ARRAY_SIZE(wszBuf));
wsprintfW(wszSize, wszFormat, U(size).LowPart, wszBuf);
hObject = GetDlgItem(hDlgWnd, IDC_GETSIZEMAX);
SetWindowTextW(hObject, wszSize);

View File

@ -286,8 +286,7 @@ static int MenuCommand(WPARAM wParam, HWND hWnd)
switch(wParam)
{
case IDM_ABOUT:
LoadStringW(globals.hMainInst, IDS_ABOUT, wszAbout,
sizeof(wszAbout)/sizeof(wszAbout[0]));
LoadStringW(globals.hMainInst, IDS_ABOUT, wszAbout, ARRAY_SIZE(wszAbout));
ShellAboutW(hWnd, wszAbout, NULL, NULL);
break;
case IDM_COPYCLSID:
@ -380,7 +379,7 @@ static int MenuCommand(WPARAM wParam, HWND hWnd)
PROCESS_INFORMATION pi;
WCHAR app[MAX_PATH];
GetWindowsDirectoryW( app, MAX_PATH - sizeof(wszRegEdit)/sizeof(WCHAR) );
GetWindowsDirectoryW(app, MAX_PATH - ARRAY_SIZE(wszRegEdit));
lstrcatW( app, wszRegEdit );
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
@ -416,9 +415,9 @@ static int MenuCommand(WPARAM wParam, HWND hWnd)
static WCHAR wszName[MAX_LOAD_STRING];
WCHAR filter_typelib[MAX_LOAD_STRING], filter_all[MAX_LOAD_STRING], filter[MAX_PATH];
LoadStringW(globals.hMainInst, IDS_OPEN, wszTitle, sizeof(wszTitle)/sizeof(wszTitle[0]));
LoadStringW(globals.hMainInst, IDS_OPEN_FILTER_TYPELIB, filter_typelib, sizeof(filter_typelib)/sizeof(WCHAR));
LoadStringW(globals.hMainInst, IDS_OPEN_FILTER_ALL, filter_all, sizeof(filter_all)/sizeof(WCHAR));
LoadStringW(globals.hMainInst, IDS_OPEN, wszTitle, ARRAY_SIZE(wszTitle));
LoadStringW(globals.hMainInst, IDS_OPEN_FILTER_TYPELIB, filter_typelib, ARRAY_SIZE(filter_typelib));
LoadStringW(globals.hMainInst, IDS_OPEN_FILTER_ALL, filter_all, ARRAY_SIZE(filter_all));
wsprintfW( filter, filterW, filter_typelib, 0, 0, filter_all, 0, 0 );
InitOpenFileName(hWnd, &ofn, filter, wszTitle, wszName);
if(GetOpenFileNameW(&ofn)) CreateTypeLibWindow(globals.hMainInst, wszName);
@ -441,8 +440,8 @@ static void UpdateStatusBar(int itemID)
{
WCHAR info[MAX_LOAD_STRING];
if(!LoadStringW(globals.hMainInst, itemID, info, sizeof(info)/sizeof(info[0])))
LoadStringW(globals.hMainInst, IDS_READY, info, sizeof(info)/sizeof(info[0]));
if(!LoadStringW(globals.hMainInst, itemID, info, ARRAY_SIZE(info)))
LoadStringW(globals.hMainInst, IDS_READY, info, ARRAY_SIZE(info));
SendMessageW(globals.hStatusBar, SB_SETTEXTW, 0, (LPARAM)info);
}
@ -491,7 +490,7 @@ static BOOL InitApplication(HINSTANCE hInst)
WNDCLASSW wc;
WCHAR wszAppName[MAX_LOAD_STRING];
LoadStringW(hInst, IDS_APPNAME, wszAppName, sizeof(wszAppName)/sizeof(wszAppName[0]));
LoadStringW(hInst, IDS_APPNAME, wszAppName, ARRAY_SIZE(wszAppName));
memset(&wc, 0, sizeof(WNDCLASSW));
wc.lpfnWndProc = WndProc;
@ -524,8 +523,8 @@ static BOOL InitInstance(HINSTANCE hInst, int nCmdShow)
{5, IDM_VIEW, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0}
};
LoadStringW(hInst, IDS_APPNAME, wszAppName, sizeof(wszAppName)/sizeof(wszAppName[0]));
LoadStringW(hInst, IDS_APPTITLE, wszTitle, sizeof(wszTitle)/sizeof(wszTitle[0]));
LoadStringW(hInst, IDS_APPNAME, wszAppName, ARRAY_SIZE(wszAppName));
LoadStringW(hInst, IDS_APPTITLE, wszTitle, ARRAY_SIZE(wszTitle));
hWnd = CreateWindowW(wszAppName, wszTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL);

View File

@ -108,10 +108,8 @@ void CreateInst(HTREEITEM item, WCHAR *wszMachineName)
if(FAILED(hRes))
{
LoadStringW(globals.hMainInst, IDS_CGCOFAIL, wszMessage,
sizeof(wszMessage)/sizeof(wszMessage[0]));
LoadStringW(globals.hMainInst, IDS_ABOUT, wszTitle,
sizeof(wszTitle)/sizeof(wszTitle[0]));
LoadStringW(globals.hMainInst, IDS_CGCOFAIL, wszMessage, ARRAY_SIZE(wszMessage));
LoadStringW(globals.hMainInst, IDS_ABOUT, wszTitle, ARRAY_SIZE(wszTitle));
#define CASE_ERR(i) case i: \
MultiByteToWideChar(CP_ACP, 0, #i, -1, wszFlagName, MAX_LOAD_STRING); \
@ -130,7 +128,7 @@ void CreateInst(HTREEITEM item, WCHAR *wszMachineName)
CASE_ERR(CO_E_APPDIDNTREG);
CASE_ERR(CLASS_E_CLASSNOTAVAILABLE);
default:
LoadStringW(globals.hMainInst, IDS_ERROR_UNKN, wszFlagName, sizeof(wszFlagName)/sizeof(wszFlagName[0]));
LoadStringW(globals.hMainInst, IDS_ERROR_UNKN, wszFlagName, ARRAY_SIZE(wszFlagName));
}
wsprintfW(&wszMessage[lstrlenW(wszMessage)], wszFormat,
@ -273,7 +271,7 @@ static void AddCOMandAll(void)
{
i++;
if(RegEnumKeyW(hKey, i, valName, sizeof(valName)/sizeof(valName[0])) != ERROR_SUCCESS) break;
if(RegEnumKeyW(hKey, i, valName, ARRAY_SIZE(valName)) != ERROR_SUCCESS) break;
if(RegOpenKeyW(hKey, valName, &hCurKey) != ERROR_SUCCESS) continue;
@ -302,7 +300,7 @@ static void AddCOMandAll(void)
if(RegOpenKeyW(hCurKey, wszImplementedCategories, &hInfo) == ERROR_SUCCESS)
{
if(RegEnumKeyW(hInfo, 0, wszComp, sizeof(wszComp)/sizeof(wszComp[0])) != ERROR_SUCCESS) break;
if(RegEnumKeyW(hInfo, 0, wszComp, ARRAY_SIZE(wszComp)) != ERROR_SUCCESS) break;
RegCloseKey(hInfo);
@ -360,7 +358,7 @@ static void AddApplicationID(void)
{
i++;
if(RegEnumKeyW(hKey, i, valName, sizeof(valName)/sizeof(valName[0])) != ERROR_SUCCESS) break;
if(RegEnumKeyW(hKey, i, valName, ARRAY_SIZE(valName)) != ERROR_SUCCESS) break;
if(RegOpenKeyW(hKey, valName, &hCurKey) != ERROR_SUCCESS) continue;
@ -405,7 +403,7 @@ static void AddTypeLib(void)
{
i++;
if(RegEnumKeyW(hKey, i, valParent, sizeof(valParent)/sizeof(valParent[0])) != ERROR_SUCCESS) break;
if(RegEnumKeyW(hKey, i, valParent, ARRAY_SIZE(valParent)) != ERROR_SUCCESS) break;
if(RegOpenKeyW(hKey, valParent, &hCurKey) != ERROR_SUCCESS) continue;
@ -414,7 +412,7 @@ static void AddTypeLib(void)
{
j++;
if(RegEnumKeyW(hCurKey, j, valName, sizeof(valName)/sizeof(valName[0])) != ERROR_SUCCESS) break;
if(RegEnumKeyW(hCurKey, j, valName, ARRAY_SIZE(valName)) != ERROR_SUCCESS) break;
if(RegOpenKeyW(hCurKey, valName, &hInfoKey) != ERROR_SUCCESS) continue;
@ -423,8 +421,7 @@ static void AddTypeLib(void)
if(RegQueryValueW(hInfoKey, NULL, buffer, &lenBuffer) == ERROR_SUCCESS
&& *buffer)
{
LoadStringW(globals.hMainInst, IDS_TL_VER, wszVer,
sizeof(wszVer)/sizeof(wszVer[0]));
LoadStringW(globals.hMainInst, IDS_TL_VER, wszVer, ARRAY_SIZE(wszVer));
wsprintfW(&buffer[lstrlenW(buffer)], wszFormat, wszVer, valName);
U(tvis).item.pszText = buffer;
@ -471,7 +468,7 @@ static void AddInterfaces(void)
{
i++;
if(RegEnumKeyW(hKey, i, valName, sizeof(valName)/sizeof(valName[0])) != ERROR_SUCCESS) break;
if(RegEnumKeyW(hKey, i, valName, ARRAY_SIZE(valName)) != ERROR_SUCCESS) break;
if(RegOpenKeyW(hKey, valName, &hCurKey) != ERROR_SUCCESS) continue;
@ -518,7 +515,7 @@ static void AddComponentCategories(void)
{
i++;
if(RegEnumKeyW(hKey, i, keyName, sizeof(keyName)/sizeof(keyName[0])) != ERROR_SUCCESS) break;
if(RegEnumKeyW(hKey, i, keyName, ARRAY_SIZE(keyName)) != ERROR_SUCCESS) break;
if(RegOpenKeyW(hKey, keyName, &hCurKey) != ERROR_SUCCESS) continue;

View File

@ -104,8 +104,7 @@ static void ShowLastError(void)
LPWSTR lpMsgBuf;
WCHAR wszTitle[MAX_LOAD_STRING];
LoadStringW(globals.hMainInst, IDS_TYPELIBTITLE, wszTitle,
sizeof(wszTitle)/sizeof(wszTitle[0]));
LoadStringW(globals.hMainInst, IDS_TYPELIBTITLE, wszTitle, ARRAY_SIZE(wszTitle));
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, error, 0, (LPWSTR)&lpMsgBuf, 0, NULL);
MessageBoxW(NULL, lpMsgBuf, wszTitle, MB_OK | MB_ICONERROR);
@ -737,7 +736,7 @@ static int EnumImplTypes(ITypeInfo *pTypeInfo, int cImplTypes, HTREEITEM hParent
if(!cImplTypes) return 0;
LoadStringW(globals.hMainInst, IDS_INHERITINTERFACES, wszInheritedInterfaces,
sizeof(wszInheritedInterfaces)/sizeof(wszInheritedInterfaces[0]));
ARRAY_SIZE(wszInheritedInterfaces));
U(tvis).item.mask = TVIF_TEXT;
U(tvis).item.cchTextMax = MAX_LOAD_STRING;
@ -1200,12 +1199,11 @@ static int PopulateTree(void)
WCHAR wszError[MAX_LOAD_STRING];
DWORD_PTR args[2];
LoadStringW(globals.hMainInst, IDS_ERROR_LOADTYPELIB,
wszError, sizeof(wszError)/sizeof(wszError[0]));
LoadStringW(globals.hMainInst, IDS_ERROR_LOADTYPELIB, wszError, ARRAY_SIZE(wszError));
args[0] = (DWORD_PTR)typelib.wszFileName;
args[1] = hRes;
FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
wszError, 0, 0, wszMessage, sizeof(wszMessage)/sizeof(*wszMessage), (__ms_va_list*)args);
wszError, 0, 0, wszMessage, ARRAY_SIZE(wszMessage), (__ms_va_list*)args);
MessageBoxW(globals.hMainWnd, wszMessage, NULL, MB_OK|MB_ICONEXCLAMATION);
return 1;
}
@ -1535,8 +1533,8 @@ static void UpdateTypeLibStatusBar(int itemID)
{
WCHAR info[MAX_LOAD_STRING];
if(!LoadStringW(globals.hMainInst, itemID, info, sizeof(info)/sizeof(info[0])))
LoadStringW(globals.hMainInst, IDS_READY, info, sizeof(info)/sizeof(info[0]));
if(!LoadStringW(globals.hMainInst, itemID, info, ARRAY_SIZE(info)))
LoadStringW(globals.hMainInst, IDS_READY, info, ARRAY_SIZE(info));
SendMessageW(typelib.hStatusBar, SB_SETTEXTW, 0, (LPARAM)info);
}
@ -1639,7 +1637,7 @@ BOOL TypeLibRegisterClassW(void)
BOOL CreateTypeLibWindow(HINSTANCE hInst, WCHAR *wszFileName)
{
WCHAR wszTitle[MAX_LOAD_STRING];
LoadStringW(hInst, IDS_TYPELIBTITLE, wszTitle, sizeof(wszTitle)/sizeof(wszTitle[0]));
LoadStringW(hInst, IDS_TYPELIBTITLE, wszTitle, ARRAY_SIZE(wszTitle));
if(wszFileName) lstrcpyW(typelib.wszFileName, wszFileName);
else