https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4e89603929e46d964de30…
commit 4e89603929e46d964de3045b78bd8f7224ae94b0
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Fri Sep 11 13:16:15 2020 +0200
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Wed Sep 16 10:35:34 2020 +0200
[WINESYNC] dbghelp: Use the ARRAY_SIZE() macro.
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 053a7e225c8190fd7416b3f3c3186f1ac230eeb3 by Michael Stefaniuc
<mstefani(a)winehq.org>
---
dll/win32/dbghelp/compat.h | 1 +
dll/win32/dbghelp/cpu_i386.c | 4 ++--
dll/win32/dbghelp/dbghelp.c | 5 ++---
dll/win32/dbghelp/elf_module.c | 14 ++++++--------
dll/win32/dbghelp/macho_module.c | 2 +-
dll/win32/dbghelp/minidump.c | 4 ++--
dll/win32/dbghelp/module.c | 16 +++++++---------
dll/win32/dbghelp/msc.c | 2 +-
dll/win32/dbghelp/stabs.c | 6 +++---
dll/win32/dbghelp/symbol.c | 2 +-
sdk/tools/winesync/dbghelp.cfg | 2 +-
11 files changed, 27 insertions(+), 31 deletions(-)
diff --git a/dll/win32/dbghelp/compat.h b/dll/win32/dbghelp/compat.h
index cbd90edbe81..8f6047ea120 100644
--- a/dll/win32/dbghelp/compat.h
+++ b/dll/win32/dbghelp/compat.h
@@ -113,6 +113,7 @@ INT __WideCharToMultiByte( UINT page, DWORD flags, LPCWSTR src, INT
srclen, LPST
// #define toupperW(n) towupper((n))
// winnt.h
+# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define IMAGE_FILE_MACHINE_ARMNT 0x1c4
#define IMAGE_FILE_MACHINE_POWERPC 0x1f0
#define IMAGE_FILE_MACHINE_ARM64 0xaa64
diff --git a/dll/win32/dbghelp/cpu_i386.c b/dll/win32/dbghelp/cpu_i386.c
index 86e8fdbdbec..e8056a78a3c 100644
--- a/dll/win32/dbghelp/cpu_i386.c
+++ b/dll/win32/dbghelp/cpu_i386.c
@@ -458,7 +458,7 @@ static BOOL i386_stack_walk(struct cpu_stack_walk* csw, LPSTACKFRAME64
frame, CO
* work if the parameter is in fact bigger than 16bit, but
* there's no way to know that here
*/
- for (i = 0; i < sizeof(frame->Params) / sizeof(frame->Params[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(frame->Params); i++)
{
sw_read_mem(csw, p + (2 + i) * sizeof(WORD), &val16, sizeof(val16));
frame->Params[i] = val16;
@@ -491,7 +491,7 @@ static BOOL i386_stack_walk(struct cpu_stack_walk* csw, LPSTACKFRAME64
frame, CO
frame->AddrReturn.Mode = AddrModeFlat;
frame->AddrReturn.Offset = newctx.Eip;
#endif
- for (i = 0; i < sizeof(frame->Params) / sizeof(frame->Params[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(frame->Params); i++)
{
sw_read_mem(csw, frame->AddrFrame.Offset + (2 + i) * sizeof(DWORD),
&val32, sizeof(val32));
frame->Params[i] = val32;
diff --git a/dll/win32/dbghelp/dbghelp.c b/dll/win32/dbghelp/dbghelp.c
index 14eeb781637..732309567a9 100644
--- a/dll/win32/dbghelp/dbghelp.c
+++ b/dll/win32/dbghelp/dbghelp.c
@@ -257,9 +257,8 @@ static BOOL WINAPI process_invade_cb(PCWSTR name, ULONG64 base, ULONG
size, PVOI
WCHAR tmp[MAX_PATH];
HANDLE hProcess = user;
- if (!GetModuleFileNameExW(hProcess, (HMODULE)(DWORD_PTR)base,
- tmp, sizeof(tmp) / sizeof(WCHAR)))
- lstrcpynW(tmp, name, sizeof(tmp) / sizeof(WCHAR));
+ if (!GetModuleFileNameExW(hProcess, (HMODULE)(DWORD_PTR)base, tmp, ARRAY_SIZE(tmp)))
+ lstrcpynW(tmp, name, ARRAY_SIZE(tmp));
SymLoadModuleExW(hProcess, 0, tmp, name, base, size, NULL, 0);
return TRUE;
diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c
index 32ce3455db0..6b8d47a1e40 100644
--- a/dll/win32/dbghelp/elf_module.c
+++ b/dll/win32/dbghelp/elf_module.c
@@ -974,7 +974,7 @@ static BOOL elf_locate_debug_link(struct image_file_map* fmap, const
char* filen
{
static const WCHAR globalDebugDirW[] =
{'/','u','s','r','/','l','i','b','/','d','e','b','u','g','/'};
static const WCHAR dotDebugW[] =
{'.','d','e','b','u','g','/'};
- const size_t globalDebugDirLen = sizeof(globalDebugDirW) / sizeof(WCHAR);
+ const size_t globalDebugDirLen = ARRAY_SIZE(globalDebugDirW);
size_t filename_len;
WCHAR* p = NULL;
WCHAR* slash;
@@ -999,7 +999,7 @@ static BOOL elf_locate_debug_link(struct image_file_map* fmap, const
char* filen
/* testing execdir/.debug/filename */
memcpy(slash, dotDebugW, sizeof(dotDebugW));
- MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash + sizeof(dotDebugW) /
sizeof(WCHAR), filename_len);
+ MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash + ARRAY_SIZE(dotDebugW),
filename_len);
if (elf_check_debug_link(p, fmap_link, crc)) goto found;
/* testing globaldebugdir/execdir/filename */
@@ -1049,9 +1049,9 @@ static BOOL elf_locate_build_id_target(struct image_file_map* fmap,
const BYTE*
(idlen * 2 + 1) * sizeof(WCHAR) + sizeof(dotDebug0W));
z = p;
memcpy(z, globalDebugDirW, sizeof(globalDebugDirW));
- z += sizeof(globalDebugDirW) / sizeof(WCHAR);
+ z += ARRAY_SIZE(globalDebugDirW);
memcpy(z, buildidW, sizeof(buildidW));
- z += sizeof(buildidW) / sizeof(WCHAR);
+ z += ARRAY_SIZE(buildidW);
if (id < idend)
{
@@ -1694,8 +1694,7 @@ static BOOL elf_enum_modules_internal(const struct process* pcs,
ReadProcessMemory(pcs->handle, lm.l_name, bufstr, sizeof(bufstr),
NULL))
{
bufstr[sizeof(bufstr) - 1] = '\0';
- MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW,
- sizeof(bufstrW) / sizeof(WCHAR));
+ MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW,
ARRAY_SIZE(bufstrW));
if (main_name && !bufstrW[0]) strcpyW(bufstrW, main_name);
if (!cb(bufstrW, (unsigned long)lm.l_addr, (unsigned long)lm.l_ld, FALSE,
user))
break;
@@ -1729,8 +1728,7 @@ static BOOL elf_enum_modules_internal(const struct process* pcs,
bufstr, sizeof(bufstr), NULL))
{
bufstr[sizeof(bufstr) - 1] = '\0';
- MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW,
- sizeof(bufstrW) / sizeof(WCHAR));
+ MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW,
ARRAY_SIZE(bufstrW));
if (main_name && !bufstrW[0]) strcpyW(bufstrW, main_name);
if (!cb(bufstrW, (unsigned long)lm.l_addr, (unsigned long)lm.l_ld, FALSE,
user))
break;
diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c
index 52c8e69108c..9401dfb0c78 100644
--- a/dll/win32/dbghelp/macho_module.c
+++ b/dll/win32/dbghelp/macho_module.c
@@ -1672,7 +1672,7 @@ static BOOL macho_enum_modules_internal(const struct process* pcs,
{
bufstr[sizeof(bufstr) - 1] = '\0';
TRACE("[%d] image file %s\n", i, debugstr_a(bufstr));
- MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW, sizeof(bufstrW) /
sizeof(WCHAR));
+ MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW, ARRAY_SIZE(bufstrW));
if (main_name && !bufstrW[0]) strcpyW(bufstrW, main_name);
if (!cb(bufstrW, (unsigned long)info_array[i].imageLoadAddress, user))
break;
}
diff --git a/dll/win32/dbghelp/minidump.c b/dll/win32/dbghelp/minidump.c
index 4dead52b92e..1a5dca9de67 100644
--- a/dll/win32/dbghelp/minidump.c
+++ b/dll/win32/dbghelp/minidump.c
@@ -215,9 +215,9 @@ static BOOL add_module(struct dump_context* dc, const WCHAR* name,
if (is_elf ||
!GetModuleFileNameExW(dc->hProcess, (HMODULE)(DWORD_PTR)base,
dc->modules[dc->num_modules].name,
- sizeof(dc->modules[dc->num_modules].name) /
sizeof(WCHAR)))
+ ARRAY_SIZE(dc->modules[dc->num_modules].name)))
lstrcpynW(dc->modules[dc->num_modules].name, name,
- sizeof(dc->modules[dc->num_modules].name) / sizeof(WCHAR));
+ ARRAY_SIZE(dc->modules[dc->num_modules].name));
dc->modules[dc->num_modules].base = base;
dc->modules[dc->num_modules].size = size;
dc->modules[dc->num_modules].timestamp = timestamp;
diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c
index b47fbb2af66..8a47c152c25 100644
--- a/dll/win32/dbghelp/module.c
+++ b/dll/win32/dbghelp/module.c
@@ -144,9 +144,8 @@ static void module_fill_module(const WCHAR* in, WCHAR* out, size_t
size)
void module_set_module(struct module* module, const WCHAR* name)
{
- module_fill_module(name, module->module.ModuleName,
- sizeof(module->module.ModuleName) /
sizeof(module->module.ModuleName[0]));
- module_fill_module(name, module->modulename, sizeof(module->modulename) /
sizeof(module->modulename[0]));
+ module_fill_module(name, module->module.ModuleName,
ARRAY_SIZE(module->module.ModuleName));
+ module_fill_module(name, module->modulename, ARRAY_SIZE(module->modulename));
}
#ifndef __REACTOS__
@@ -227,7 +226,7 @@ struct module* module_new(struct process* pcs, const WCHAR* name,
module->module.ImageSize = size;
module_set_module(module, name);
module->module.ImageName[0] = '\0';
- lstrcpynW(module->module.LoadedImageName, name,
sizeof(module->module.LoadedImageName) / sizeof(WCHAR));
+ lstrcpynW(module->module.LoadedImageName, name,
ARRAY_SIZE(module->module.LoadedImageName));
module->module.SymType = SymNone;
module->module.NumSyms = 0;
module->module.TimeDateStamp = stamp;
@@ -296,7 +295,7 @@ struct module* module_find_by_nameA(const struct process* pcs, const
char* name)
{
WCHAR wname[MAX_PATH];
- MultiByteToWideChar(CP_ACP, 0, name, -1, wname, sizeof(wname) / sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, name, -1, wname, ARRAY_SIZE(wname));
return module_find_by_nameW(pcs, wname);
}
@@ -698,8 +697,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR
wImageNam
if (wModuleName)
module_set_module(module, wModuleName);
if (wImageName)
- lstrcpynW(module->module.ImageName, wImageName,
- sizeof(module->module.ImageName) / sizeof(WCHAR));
+ lstrcpynW(module->module.ImageName, wImageName,
ARRAY_SIZE(module->module.ImageName));
return module->module.BaseOfImage;
}
@@ -963,9 +961,9 @@ BOOL WINAPI EnumerateLoadedModulesW64(HANDLE hProcess,
for (i = 0; i < sz; i++)
{
if (!GetModuleInformation(hProcess, hMods[i], &mi, sizeof(mi)) ||
- !GetModuleBaseNameW(hProcess, hMods[i], baseW, sizeof(baseW) /
sizeof(WCHAR)))
+ !GetModuleBaseNameW(hProcess, hMods[i], baseW, ARRAY_SIZE(baseW)))
continue;
- module_fill_module(baseW, modW, sizeof(modW) / sizeof(modW[0]));
+ module_fill_module(baseW, modW, ARRAY_SIZE(modW));
EnumLoadedModulesCallback(modW, (DWORD_PTR)mi.lpBaseOfDll, mi.SizeOfImage,
UserContext);
}
diff --git a/dll/win32/dbghelp/msc.c b/dll/win32/dbghelp/msc.c
index 07f3e3a469f..62cd390ccd7 100644
--- a/dll/win32/dbghelp/msc.c
+++ b/dll/win32/dbghelp/msc.c
@@ -2896,7 +2896,7 @@ static BOOL pdb_process_file(const struct process* pcs,
msc_dbg->module->module.PdbAge = pdb_info->pdb_files[0].age;
MultiByteToWideChar(CP_ACP, 0, pdb_lookup->filename, -1,
msc_dbg->module->module.LoadedPdbName,
- sizeof(msc_dbg->module->module.LoadedPdbName) /
sizeof(WCHAR));
+ ARRAY_SIZE(msc_dbg->module->module.LoadedPdbName));
/* FIXME: we could have a finer grain here */
msc_dbg->module->module.LineNumbers = TRUE;
msc_dbg->module->module.GlobalSymbols = TRUE;
diff --git a/dll/win32/dbghelp/stabs.c b/dll/win32/dbghelp/stabs.c
index 9caf6f9d427..09e451c7d2f 100644
--- a/dll/win32/dbghelp/stabs.c
+++ b/dll/win32/dbghelp/stabs.c
@@ -345,7 +345,7 @@ struct ParseTypedefData
#ifdef PTS_DEBUG
static void stabs_pts_push(struct ParseTypedefData* ptd, unsigned line)
{
- assert(ptd->err_idx < sizeof(ptd->errors) / sizeof(ptd->errors[0]));
+ assert(ptd->err_idx < ARRAY_SIZE(ptd->errors));
ptd->errors[ptd->err_idx].line = line;
ptd->errors[ptd->err_idx].ptr = ptd->ptr;
ptd->err_idx++;
@@ -357,7 +357,7 @@ static void stabs_pts_push(struct ParseTypedefData* ptd, unsigned
line)
static int stabs_get_basic(struct ParseTypedefData* ptd, unsigned basic, struct symt**
symt)
{
- PTS_ABORTIF(ptd, basic >= sizeof(stabs_basic) / sizeof(stabs_basic[0]));
+ PTS_ABORTIF(ptd, basic >= ARRAY_SIZE(stabs_basic));
if (!stabs_basic[basic])
{
@@ -1625,7 +1625,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
break;
case N_BINCL:
stabs_add_include(stabs_new_include(ptr, n_value));
- assert(incl_stk < (int)(sizeof(incl) / sizeof(incl[0])) - 1);
+ assert(incl_stk < (int) ARRAY_SIZE(incl) - 1);
incl[++incl_stk] = source_idx;
source_idx = source_new(module, NULL, ptr);
break;
diff --git a/dll/win32/dbghelp/symbol.c b/dll/win32/dbghelp/symbol.c
index 5b0ad32cee3..15a0a9c378b 100644
--- a/dll/win32/dbghelp/symbol.c
+++ b/dll/win32/dbghelp/symbol.c
@@ -2130,7 +2130,7 @@ BOOL WINAPI SymAddSymbol(HANDLE hProcess, ULONG64 BaseOfDll, PCSTR
name,
{
WCHAR nameW[MAX_SYM_NAME];
- MultiByteToWideChar(CP_ACP, 0, name, -1, nameW, sizeof(nameW) / sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, name, -1, nameW, ARRAY_SIZE(nameW));
return SymAddSymbolW(hProcess, BaseOfDll, nameW, addr, size, flags);
}
diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg
index ee2961be708..a0a73e68571 100644
--- a/sdk/tools/winesync/dbghelp.cfg
+++ b/sdk/tools/winesync/dbghelp.cfg
@@ -3,4 +3,4 @@ directories:
files:
include/dbghelp.h: sdk/include/psdk/dbghelp.h
tags:
- wine: 3d482d3f9f0a3ffa69540af87594b3c1dc46e07b
+ wine: 053a7e225c8190fd7416b3f3c3186f1ac230eeb3