Commit 0c8e555e authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

winedbg: Use the available ARRAY_SIZE() macro.

parent 36449671
......@@ -38,8 +38,8 @@ int msgbox_res_id(HWND hwnd, UINT textId, UINT captionId, UINT uType)
{
WCHAR caption[256];
WCHAR text[256];
LoadStringW(GetModuleHandleW(NULL), captionId, caption, sizeof(caption)/sizeof(caption[0]));
LoadStringW(GetModuleHandleW(NULL), textId, text, sizeof(text)/sizeof(text[0]));
LoadStringW(GetModuleHandleW(NULL), captionId, caption, ARRAY_SIZE(caption));
LoadStringW(GetModuleHandleW(NULL), textId, text, ARRAY_SIZE(text));
return MessageBoxW(hwnd, text, caption, uType);
}
......@@ -116,8 +116,7 @@ static void set_message_with_filename(HWND hDlg)
WCHAR originalText[1000];
WCHAR newText[1000 + MAX_PROGRAM_NAME_LENGTH];
GetDlgItemTextW(hDlg, IDC_STATIC_TXT1, originalText,
sizeof(originalText)/sizeof(originalText[0]));
GetDlgItemTextW(hDlg, IDC_STATIC_TXT1, originalText, ARRAY_SIZE(originalText));
wsprintfW(newText, originalText, g_ProgramName);
SetDlgItemTextW(hDlg, IDC_STATIC_TXT1, newText);
}
......@@ -150,11 +149,11 @@ static void save_crash_log( HWND hwnd )
memset( &save, 0, sizeof(save) );
lstrcpyW( path, default_name );
LoadStringW( GetModuleHandleW(0), IDS_TEXT_FILES, buffer, sizeof(buffer)/sizeof(buffer[0]) );
LoadStringW( GetModuleHandleW(0), IDS_TEXT_FILES, buffer, ARRAY_SIZE(buffer));
p = buffer + lstrlenW(buffer) + 1;
lstrcpyW(p, txt_files);
p += lstrlenW(p) + 1;
LoadStringW( GetModuleHandleW(0), IDS_ALL_FILES, p, sizeof(buffer)/sizeof(buffer[0]) - (p - buffer) );
LoadStringW( GetModuleHandleW(0), IDS_ALL_FILES, p, ARRAY_SIZE(buffer) - (p - buffer) );
p += lstrlenW(p) + 1;
lstrcpyW(p, all_files);
p += lstrlenW(p) + 1;
......@@ -189,7 +188,7 @@ static void save_crash_log( HWND hwnd )
}
else err = GetLastError();
LoadStringW( GetModuleHandleW(0), IDS_SAVE_ERROR, buffer, sizeof(buffer)/sizeof(WCHAR) );
LoadStringW( GetModuleHandleW(0), IDS_SAVE_ERROR, buffer, ARRAY_SIZE(buffer));
FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, err, 0, (LPWSTR)&p, 0, NULL);
MessageBoxW( 0, p, buffer, MB_OK | MB_ICONERROR);
......
......@@ -391,7 +391,7 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
memory_get_string_indirect(gdbctx->process,
de->u.CreateProcessInfo.lpImageName,
de->u.CreateProcessInfo.fUnicode,
u.buffer, sizeof(u.buffer) / sizeof(WCHAR));
u.buffer, ARRAY_SIZE(u.buffer));
dbg_set_process_name(gdbctx->process, u.buffer);
if (gdbctx->trace & GDBPXY_TRC_WIN32_EVENT)
......@@ -423,7 +423,7 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
memory_get_string_indirect(gdbctx->process,
de->u.LoadDll.lpImageName,
de->u.LoadDll.fUnicode,
u.buffer, sizeof(u.buffer) / sizeof(WCHAR));
u.buffer, ARRAY_SIZE(u.buffer));
if (gdbctx->trace & GDBPXY_TRC_WIN32_EVENT)
fprintf(stderr, "%04x:%04x: loads DLL %s @%p (%u<%u>)\n",
de->dwProcessId, de->dwThreadId,
......@@ -1146,7 +1146,7 @@ static enum packet_return packet_verbose(struct gdb_context* gdbctx)
if (gdbctx->trace & GDBPXY_TRC_COMMAND)
fprintf(stderr, "trying to process a verbose packet %*.*s\n",
gdbctx->in_packet_len, gdbctx->in_packet_len, gdbctx->in_packet);
for (i = 0; i < sizeof(verbose_details)/sizeof(verbose_details[0]); i++)
for (i = 0; i < ARRAY_SIZE(verbose_details); i++)
{
if (klen == verbose_details[i].len &&
!memcmp(gdbctx->in_packet, verbose_details[i].name, verbose_details[i].len))
......@@ -1934,11 +1934,11 @@ static BOOL extract_packets(struct gdb_context* gdbctx)
assert(plen);
/* FIXME: should use bsearch if packet_entries was sorted */
for (i = 0; i < sizeof(packet_entries)/sizeof(packet_entries[0]); i++)
for (i = 0; i < ARRAY_SIZE(packet_entries); i++)
{
if (packet_entries[i].key == gdbctx->in_buf[1]) break;
}
if (i == sizeof(packet_entries)/sizeof(packet_entries[0]))
if (i == ARRAY_SIZE(packet_entries))
{
if (gdbctx->trace & GDBPXY_TRC_COMMAND_ERROR)
fprintf(stderr, "Unknown packet request %*.*s\n",
......@@ -2178,7 +2178,7 @@ static BOOL gdb_init_context(struct gdb_context* gdbctx, unsigned flags, unsigne
gdbctx->in_trap = FALSE;
gdbctx->trace = /*GDBPXY_TRC_PACKET | GDBPXY_TRC_COMMAND |*/ GDBPXY_TRC_COMMAND_ERROR | GDBPXY_TRC_COMMAND_FIXME | GDBPXY_TRC_WIN32_EVENT;
gdbctx->process = NULL;
for (i = 0; i < sizeof(gdbctx->wine_segs) / sizeof(gdbctx->wine_segs[0]); i++)
for (i = 0; i < ARRAY_SIZE(gdbctx->wine_segs); i++)
gdbctx->wine_segs[i] = 0;
/* wait for first trap */
......
......@@ -360,7 +360,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
fetch_module_name(de->u.CreateProcessInfo.lpImageName,
de->u.CreateProcessInfo.fUnicode,
de->u.CreateProcessInfo.lpBaseOfImage,
u.buffer, sizeof(u.buffer) / sizeof(WCHAR), TRUE);
u.buffer, ARRAY_SIZE(u.buffer), TRUE);
WINE_TRACE("%04x:%04x: create process '%s'/%p @%p (%u<%u>)\n",
de->dwProcessId, de->dwThreadId,
......@@ -455,7 +455,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
fetch_module_name(de->u.LoadDll.lpImageName,
de->u.LoadDll.fUnicode,
de->u.LoadDll.lpBaseOfDll,
u.buffer, sizeof(u.buffer) / sizeof(WCHAR), FALSE);
u.buffer, ARRAY_SIZE(u.buffer), FALSE);
WINE_TRACE("%04x:%04x: loads DLL %s @%p (%u<%u>)\n",
de->dwProcessId, de->dwThreadId,
......@@ -708,7 +708,7 @@ static const char *get_windows_version(void)
GetVersionExW( (OSVERSIONINFOW *)&info );
for (i = 0; i < sizeof(version_table) / sizeof(version_table[0]); i++)
for (i = 0; i < ARRAY_SIZE(version_table); i++)
{
if (version_table[i].type == info.wProductType &&
version_table[i].platform == info.dwPlatformId &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment