=?UTF-8?Q?Andr=C3=A9=20Hentschel=20?=: advpack: Use ARRAY_SIZE() macro.
Alexandre Julliard
julliard at winehq.org
Wed Jul 4 15:32:34 CDT 2018
Module: wine
Branch: master
Commit: e7f5dc194aeb586bb516b5fd191ad6924c4fcdd3
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e7f5dc194aeb586bb516b5fd191ad6924c4fcdd3
Author: André Hentschel <nerv at dawncrow.de>
Date: Mon Jun 11 21:22:35 2018 +0200
advpack: Use ARRAY_SIZE() macro.
Signed-off-by: André Hentschel <nerv at dawncrow.de>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/advpack/advpack.c | 18 ++++++------------
dlls/advpack/install.c | 26 +++++++++-----------------
dlls/advpack/reg.c | 6 +++---
3 files changed, 18 insertions(+), 32 deletions(-)
diff --git a/dlls/advpack/advpack.c b/dlls/advpack/advpack.c
index d2ce60e..2e8027f 100644
--- a/dlls/advpack/advpack.c
+++ b/dlls/advpack/advpack.c
@@ -530,18 +530,12 @@ HRESULT WINAPI SetPerUserSecValuesA(PERUSERSECTIONA* pPerUser)
if (!pPerUser)
return E_INVALIDARG;
- MultiByteToWideChar(CP_ACP, 0, pPerUser->szGUID, -1, perUserW.szGUID,
- sizeof(perUserW.szGUID) / sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, pPerUser->szDispName, -1, perUserW.szDispName,
- sizeof(perUserW.szDispName) / sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, pPerUser->szLocale, -1, perUserW.szLocale,
- sizeof(perUserW.szLocale) / sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, pPerUser->szStub, -1, perUserW.szStub,
- sizeof(perUserW.szStub) / sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, pPerUser->szVersion, -1, perUserW.szVersion,
- sizeof(perUserW.szVersion) / sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, pPerUser->szCompID, -1, perUserW.szCompID,
- sizeof(perUserW.szCompID) / sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, pPerUser->szGUID, -1, perUserW.szGUID, ARRAY_SIZE(perUserW.szGUID));
+ MultiByteToWideChar(CP_ACP, 0, pPerUser->szDispName, -1, perUserW.szDispName, ARRAY_SIZE(perUserW.szDispName));
+ MultiByteToWideChar(CP_ACP, 0, pPerUser->szLocale, -1, perUserW.szLocale, ARRAY_SIZE(perUserW.szLocale));
+ MultiByteToWideChar(CP_ACP, 0, pPerUser->szStub, -1, perUserW.szStub, ARRAY_SIZE(perUserW.szStub));
+ MultiByteToWideChar(CP_ACP, 0, pPerUser->szVersion, -1, perUserW.szVersion, ARRAY_SIZE(perUserW.szVersion));
+ MultiByteToWideChar(CP_ACP, 0, pPerUser->szCompID, -1, perUserW.szCompID, ARRAY_SIZE(perUserW.szCompID));
perUserW.dwIsInstalled = pPerUser->dwIsInstalled;
perUserW.bRollback = pPerUser->bRollback;
diff --git a/dlls/advpack/install.c b/dlls/advpack/install.c
index dcd1dd7..c3caf3a 100644
--- a/dlls/advpack/install.c
+++ b/dlls/advpack/install.c
@@ -115,28 +115,22 @@ static HRESULT per_user_install_callback(HINF hinf, PCWSTR field, const void *ar
per_user.bRollback = FALSE;
per_user.dwIsInstalled = 0;
- SetupGetLineTextW(NULL, hinf, field, disp_name, per_user.szDispName,
- sizeof(per_user.szDispName) / sizeof(WCHAR), &size);
+ SetupGetLineTextW(NULL, hinf, field, disp_name, per_user.szDispName, ARRAY_SIZE(per_user.szDispName), &size);
- SetupGetLineTextW(NULL, hinf, field, version, per_user.szVersion,
- sizeof(per_user.szVersion) / sizeof(WCHAR), &size);
+ SetupGetLineTextW(NULL, hinf, field, version, per_user.szVersion, ARRAY_SIZE(per_user.szVersion), &size);
if (SetupFindFirstLineW(hinf, field, is_installed, &context))
{
SetupGetIntField(&context, 1, (PINT)&per_user.dwIsInstalled);
}
- SetupGetLineTextW(NULL, hinf, field, comp_id, per_user.szCompID,
- sizeof(per_user.szCompID) / sizeof(WCHAR), &size);
+ SetupGetLineTextW(NULL, hinf, field, comp_id, per_user.szCompID, ARRAY_SIZE(per_user.szCompID), &size);
- SetupGetLineTextW(NULL, hinf, field, guid, per_user.szGUID,
- sizeof(per_user.szGUID) / sizeof(WCHAR), &size);
+ SetupGetLineTextW(NULL, hinf, field, guid, per_user.szGUID, ARRAY_SIZE(per_user.szGUID), &size);
- SetupGetLineTextW(NULL, hinf, field, locale, per_user.szLocale,
- sizeof(per_user.szLocale) / sizeof(WCHAR), &size);
+ SetupGetLineTextW(NULL, hinf, field, locale, per_user.szLocale, ARRAY_SIZE(per_user.szLocale), &size);
- SetupGetLineTextW(NULL, hinf, field, stub_path, per_user.szStub,
- sizeof(per_user.szStub) / sizeof(WCHAR), &size);
+ SetupGetLineTextW(NULL, hinf, field, stub_path, per_user.szStub, ARRAY_SIZE(per_user.szStub), &size);
return SetPerUserSecValuesW(&per_user);
}
@@ -154,8 +148,7 @@ static HRESULT register_ocxs_callback(HINF hinf, PCWSTR field, const void *arg)
WCHAR buffer[MAX_INF_STRING_LENGTH];
/* get OCX filename */
- if (!SetupGetStringFieldW(&context, 1, buffer,
- sizeof(buffer) / sizeof(WCHAR), NULL))
+ if (!SetupGetStringFieldW(&context, 1, buffer, ARRAY_SIZE(buffer), NULL))
continue;
hm = LoadLibraryExW(buffer, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
@@ -273,7 +266,7 @@ static HRESULT iterate_section_fields(HINF hinf, PCWSTR section, PCWSTR key,
{
WCHAR static_buffer[200];
WCHAR *buffer = static_buffer;
- DWORD size = sizeof(static_buffer) / sizeof(WCHAR);
+ DWORD size = ARRAY_SIZE(static_buffer);
INFCONTEXT context;
HRESULT hr = E_FAIL;
@@ -645,8 +638,7 @@ HRESULT WINAPI ExecuteCabA(HWND hwnd, CABINFOA* pCab, LPVOID pReserved)
RtlCreateUnicodeStringFromAsciiz(&inf, pCab->pszInf);
RtlCreateUnicodeStringFromAsciiz(§ion, pCab->pszSection);
- MultiByteToWideChar(CP_ACP, 0, pCab->szSrcPath, -1, cabinfo.szSrcPath,
- sizeof(cabinfo.szSrcPath) / sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, pCab->szSrcPath, -1, cabinfo.szSrcPath, ARRAY_SIZE(cabinfo.szSrcPath));
cabinfo.pszInf = inf.Buffer;
cabinfo.pszSection = section.Buffer;
diff --git a/dlls/advpack/reg.c b/dlls/advpack/reg.c
index 9a43015..fd0a199 100644
--- a/dlls/advpack/reg.c
+++ b/dlls/advpack/reg.c
@@ -44,7 +44,7 @@ static BOOL get_temp_ini_path(LPWSTR name)
WCHAR tmp_dir[MAX_PATH];
WCHAR prefix[] = {'a','v','p',0};
- if(!GetTempPathW(sizeof(tmp_dir)/sizeof(WCHAR), tmp_dir))
+ if(!GetTempPathW(ARRAY_SIZE(tmp_dir), tmp_dir))
return FALSE;
if(!GetTempFileNameW(tmp_dir, prefix, 0, name))
@@ -177,14 +177,14 @@ static HRESULT write_predefined_strings(HMODULE hm, LPCWSTR ini_path)
WCHAR sys_root[MAX_PATH];
*mod_path = '\"';
- if (!GetModuleFileNameW(hm, mod_path + 1, sizeof(mod_path) / sizeof(WCHAR) - 2))
+ if (!GetModuleFileNameW(hm, mod_path + 1, ARRAY_SIZE(mod_path) - 2))
return E_FAIL;
lstrcatW(mod_path, quote);
WritePrivateProfileStringW(Strings, MOD_PATH, mod_path, ini_path);
*sys_root = '\0';
- GetEnvironmentVariableW(SystemRoot, sys_root, sizeof(sys_root) / sizeof(WCHAR));
+ GetEnvironmentVariableW(SystemRoot, sys_root, ARRAY_SIZE(sys_root));
if(!strncmpiW(sys_root, mod_path + 1, strlenW(sys_root)))
{
More information about the wine-cvs
mailing list