Signed-off-by: Michael Stefaniuc mstefani@winehq.org --- dlls/dbghelp/cpu_i386.c | 4 ++-- dlls/dbghelp/dbghelp.c | 5 ++--- dlls/dbghelp/elf_module.c | 14 ++++++-------- dlls/dbghelp/macho_module.c | 2 +- dlls/dbghelp/minidump.c | 4 ++-- dlls/dbghelp/module.c | 16 +++++++--------- dlls/dbghelp/msc.c | 2 +- dlls/dbghelp/stabs.c | 6 +++--- dlls/dbghelp/symbol.c | 2 +- 9 files changed, 25 insertions(+), 30 deletions(-)
diff --git a/dlls/dbghelp/cpu_i386.c b/dlls/dbghelp/cpu_i386.c index 37b2e2586e..9e207bb0d1 100644 --- a/dlls/dbghelp/cpu_i386.c +++ b/dlls/dbghelp/cpu_i386.c @@ -449,7 +449,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; @@ -482,7 +482,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/dlls/dbghelp/dbghelp.c b/dlls/dbghelp/dbghelp.c index 0bb591babe..5685c25cd0 100644 --- a/dlls/dbghelp/dbghelp.c +++ b/dlls/dbghelp/dbghelp.c @@ -245,9 +245,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/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c index 32ce3455db..6b8d47a1e4 100644 --- a/dlls/dbghelp/elf_module.c +++ b/dlls/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/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c index 52c8e69108..9401dfb0c7 100644 --- a/dlls/dbghelp/macho_module.c +++ b/dlls/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/dlls/dbghelp/minidump.c b/dlls/dbghelp/minidump.c index 4dead52b92..1a5dca9de6 100644 --- a/dlls/dbghelp/minidump.c +++ b/dlls/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/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 040bf9b8ed..98fc10c029 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -134,9 +134,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)); }
/* Returned string must be freed by caller */ @@ -215,7 +214,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; @@ -281,7 +280,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); }
@@ -671,8 +670,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; } @@ -935,9 +933,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/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index eba26498cb..cc1259df18 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -2893,7 +2893,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/dlls/dbghelp/stabs.c b/dlls/dbghelp/stabs.c index 846a935a4b..bc5ef356e8 100644 --- a/dlls/dbghelp/stabs.c +++ b/dlls/dbghelp/stabs.c @@ -337,7 +337,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++; @@ -349,7 +349,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]) { @@ -1617,7 +1617,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/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 08ea834b57..de871ecdcd 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -2077,7 +2077,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); }