Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/ntdll/actctx.c | 4 ++--
dlls/ntdll/cdrom.c | 2 +-
dlls/ntdll/debugtools.c | 2 +-
dlls/ntdll/directory.c | 16 ++++++++--------
dlls/ntdll/file.c | 2 +-
dlls/ntdll/heap.c | 2 +-
dlls/ntdll/loader.c | 8 ++++----
dlls/ntdll/path.c | 12 ++++++------
dlls/ntdll/relay.c | 4 ++--
dlls/ntdll/signal_arm.c | 2 +-
dlls/ntdll/signal_arm64.c | 2 +-
dlls/ntdll/signal_i386.c | 2 +-
dlls/ntdll/signal_powerpc.c | 2 +-
dlls/ntdll/signal_x86_64.c | 2 +-
dlls/ntdll/time.c | 3 +--
dlls/ntdll/virtual.c | 2 +-
16 files changed, 33 insertions(+), 34 deletions(-)
diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c
index 7e3aec4d1e..53a8b06882 100644
--- a/dlls/ntdll/actctx.c
+++ b/dlls/ntdll/actctx.c
@@ -1556,7 +1556,7 @@ static OLEMISC get_olemisc_value(const WCHAR *str, int len)
int min, max;
min = 0;
- max = sizeof(olemisc_values)/sizeof(struct olemisc_entry) - 1;
+ max = ARRAY_SIZE(olemisc_values) - 1;
while (min <= max)
{
@@ -3131,7 +3131,7 @@ static WCHAR *lookup_manifest_file( HANDLE dir, struct assembly_identity *ai )
tmp = strchrW(tmp, '_') + 1;
tmp = strchrW(tmp, '_') + 1;
if (dir_info->FileNameLength - (tmp - dir_info->FileName) * sizeof(WCHAR) == sizeof(wine_trailerW) &&
- !memicmpW( tmp, wine_trailerW, sizeof(wine_trailerW) / sizeof(WCHAR) ))
+ !memicmpW( tmp, wine_trailerW, ARRAY_SIZE( wine_trailerW )))
{
/* prefer a non-Wine manifest if we already have one */
/* we'll still load the builtin dll if specified through DllOverrides */
diff --git a/dlls/ntdll/cdrom.c b/dlls/ntdll/cdrom.c
index 2c64106072..066181b1d1 100644
--- a/dlls/ntdll/cdrom.c
+++ b/dlls/ntdll/cdrom.c
@@ -208,7 +208,7 @@ static const char *iocodex(DWORD code)
{
unsigned int i;
static char buffer[25];
- for(i=0; i<sizeof(iocodextable)/sizeof(struct iocodexs); i++)
+ for(i=0; i<ARRAY_SIZE(iocodextable); i++)
if (code==iocodextable[i].code)
return iocodextable[i].codex;
sprintf(buffer, "IOCTL_CODE_%x", (int)code);
diff --git a/dlls/ntdll/debugtools.c b/dlls/ntdll/debugtools.c
index 2c8287d225..254673b473 100644
--- a/dlls/ntdll/debugtools.c
+++ b/dlls/ntdll/debugtools.c
@@ -175,7 +175,7 @@ static int NTDLL_dbg_vlog( enum __wine_debug_class cls, struct __wine_debug_chan
ret += wine_dbg_printf( "%04x:", GetCurrentThreadId() );
if (*format == '\1') /* special magic to avoid standard prefix */
format++;
- else if (cls < sizeof(classes)/sizeof(classes[0]))
+ else if (cls < ARRAY_SIZE( classes ))
ret += wine_dbg_printf( "%s:%s:%s ", classes[cls], channel->name, function );
}
if (format)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 4655a63450..c48b9e97ea 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -1008,7 +1008,7 @@ struct vol_caps
static struct fs_cache *look_up_fs_cache( dev_t dev )
{
int i;
- for (i = 0; i < sizeof(fs_cache)/sizeof(fs_cache[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( fs_cache ); i++)
if (fs_cache[i].dev == dev)
return fs_cache+i;
return NULL;
@@ -1033,7 +1033,7 @@ static void add_fs_cache( dev_t dev, fsid_t fsid, BOOLEAN case_sensitive )
}
/* Add a new entry */
- for (i = 0; i < sizeof(fs_cache)/sizeof(fs_cache[0]); i++)
+ for (i = 0; i < ARRAY_SIZE( fs_cache ); i++)
if (fs_cache[i].dev == 0)
{
/* This entry is empty, use it */
@@ -1455,8 +1455,8 @@ static BOOL append_entry( struct dir_data *data, const char *long_name,
if (short_name)
{
short_len = ntdll_umbstowcs( 0, short_name, strlen(short_name),
- short_nameW, sizeof(short_nameW) / sizeof(WCHAR) - 1 );
- if (short_len == -1) short_len = sizeof(short_nameW) / sizeof(WCHAR) - 1;
+ short_nameW, ARRAY_SIZE( short_nameW ) - 1 );
+ if (short_len == -1) short_len = ARRAY_SIZE( short_nameW ) - 1;
for (i = 0; i < short_len; i++) short_nameW[i] = toupperW( short_nameW[i] );
}
else /* generate a short name if necessary */
@@ -2291,7 +2291,7 @@ static void init_redirects(void)
{
windir.dev = st.st_dev;
windir.ino = st.st_ino;
- nb_redirects = sizeof(redirects) / sizeof(redirects[0]);
+ nb_redirects = ARRAY_SIZE( redirects );
for (i = 0; i < nb_redirects; i++)
{
if (!redirects[i].dos_target) continue;
@@ -2473,11 +2473,11 @@ static inline int get_dos_prefix_len( const UNICODE_STRING *name )
if (name->Length >= sizeof(nt_prefixW) &&
!memcmp( name->Buffer, nt_prefixW, sizeof(nt_prefixW) ))
- return sizeof(nt_prefixW) / sizeof(WCHAR);
+ return ARRAY_SIZE( nt_prefixW );
if (name->Length >= sizeof(dosdev_prefixW) &&
- !memicmpW( name->Buffer, dosdev_prefixW, sizeof(dosdev_prefixW)/sizeof(WCHAR) ))
- return sizeof(dosdev_prefixW) / sizeof(WCHAR);
+ !memicmpW( name->Buffer, dosdev_prefixW, ARRAY_SIZE( dosdev_prefixW )))
+ return ARRAY_SIZE( dosdev_prefixW );
return 0;
}
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index b9d24251f2..b39e931452 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -3256,7 +3256,7 @@ NTSTATUS WINAPI NtQueryVolumeInformationFile( HANDLE handle, PIO_STATUS_BLOCK io
}
break;
case FileFsAttributeInformation:
- if (length < offsetof( FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName[sizeof(ntfsW)/sizeof(WCHAR)] ))
+ if (length < offsetof( FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName[ARRAY_SIZE( ntfsW )] ))
io->u.Status = STATUS_BUFFER_TOO_SMALL;
else
{
diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c
index ca08f9d854..44d49bca99 100644
--- a/dlls/ntdll/heap.c
+++ b/dlls/ntdll/heap.c
@@ -124,7 +124,7 @@ static const SIZE_T HEAP_freeListSizes[] =
{
0x200, 0x400, 0x1000, ~0UL
};
-#define HEAP_NB_FREE_LISTS (sizeof(HEAP_freeListSizes) / sizeof(HEAP_freeListSizes[0]) + HEAP_NB_SMALL_FREE_LISTS)
+#define HEAP_NB_FREE_LISTS (ARRAY_SIZE( HEAP_freeListSizes ) + HEAP_NB_SMALL_FREE_LISTS)
typedef union
{
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index df206e848d..8d18af8b86 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -1878,7 +1878,7 @@ static NTSTATUS perform_relocations( void *module, SIZE_T len )
if (!relocs->Size) return STATUS_SUCCESS;
if (!relocs->VirtualAddress) return STATUS_CONFLICTING_ADDRESSES;
- if (nt->FileHeader.NumberOfSections > sizeof(protect_old)/sizeof(protect_old[0]))
+ if (nt->FileHeader.NumberOfSections > ARRAY_SIZE( protect_old ))
return STATUS_INVALID_IMAGE_FORMAT;
sec = (const IMAGE_SECTION_HEADER *)((const char *)&nt->OptionalHeader +
@@ -2275,7 +2275,7 @@ static NTSTATUS find_actctx_dll( LPCWSTR libname, LPWSTR *fullname )
strcpyW( p, user_shared_data->NtSystemRoot );
p += strlenW(p);
memcpy( p, winsxsW, sizeof(winsxsW) );
- p += sizeof(winsxsW) / sizeof(WCHAR);
+ p += ARRAY_SIZE( winsxsW );
memcpy( p, info->lpAssemblyDirectoryName, info->ulAssemblyDirectoryNameLength );
p += info->ulAssemblyDirectoryNameLength / sizeof(WCHAR);
*p++ = '\\';
@@ -2840,7 +2840,7 @@ NTSTATUS WINAPI LdrQueryImageFileExecutionOptions( const UNICODE_STRING *key, LP
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'I','m','a','g','e',' ','F','i','l','e',' ',
'E','x','e','c','u','t','i','o','n',' ','O','p','t','i','o','n','s','\\'};
- WCHAR path[MAX_PATH + sizeof(optionsW)/sizeof(WCHAR)];
+ WCHAR path[MAX_PATH + ARRAY_SIZE( optionsW )];
OBJECT_ATTRIBUTES attr;
UNICODE_STRING name_str;
HANDLE hkey;
@@ -2862,7 +2862,7 @@ NTSTATUS WINAPI LdrQueryImageFileExecutionOptions( const UNICODE_STRING *key, LP
name_str.Length = sizeof(optionsW) + len;
name_str.MaximumLength = name_str.Length;
memcpy( path, optionsW, sizeof(optionsW) );
- memcpy( path + sizeof(optionsW)/sizeof(WCHAR), p, len );
+ memcpy( path + ARRAY_SIZE( optionsW ), p, len );
if ((status = NtOpenKey( &hkey, KEY_QUERY_VALUE, &attr ))) return status;
if (type == REG_DWORD)
diff --git a/dlls/ntdll/path.c b/dlls/ntdll/path.c
index 785978ced2..ccc95e3d64 100644
--- a/dlls/ntdll/path.c
+++ b/dlls/ntdll/path.c
@@ -1116,12 +1116,12 @@ NTSTATUS CDECL wine_unix_to_nt_file_name( const ANSI_STRING *name, UNICODE_STRIN
goto done;
}
memcpy( nt->Buffer, unix_prefixW, sizeof(unix_prefixW) );
- ntdll_umbstowcs( 0, path, lenA, nt->Buffer + sizeof(unix_prefixW)/sizeof(WCHAR), lenW );
- lenW += sizeof(unix_prefixW)/sizeof(WCHAR);
+ ntdll_umbstowcs( 0, path, lenA, nt->Buffer + ARRAY_SIZE( unix_prefixW ), lenW );
+ lenW += ARRAY_SIZE( unix_prefixW );
nt->Buffer[lenW] = 0;
nt->Length = lenW * sizeof(WCHAR);
nt->MaximumLength = nt->Length + sizeof(WCHAR);
- for (p = nt->Buffer + sizeof(unix_prefixW)/sizeof(WCHAR); *p; p++) if (*p == '/') *p = '\\';
+ for (p = nt->Buffer + ARRAY_SIZE( unix_prefixW ); *p; p++) if (*p == '/') *p = '\\';
status = STATUS_SUCCESS;
}
goto done;
@@ -1138,12 +1138,12 @@ NTSTATUS CDECL wine_unix_to_nt_file_name( const ANSI_STRING *name, UNICODE_STRIN
memcpy( nt->Buffer, prefixW, sizeof(prefixW) );
nt->Buffer[4] += drive;
- ntdll_umbstowcs( 0, path, lenA, nt->Buffer + sizeof(prefixW)/sizeof(WCHAR), lenW );
- lenW += sizeof(prefixW)/sizeof(WCHAR);
+ ntdll_umbstowcs( 0, path, lenA, nt->Buffer + ARRAY_SIZE( prefixW ), lenW );
+ lenW += ARRAY_SIZE( prefixW );
nt->Buffer[lenW] = 0;
nt->Length = lenW * sizeof(WCHAR);
nt->MaximumLength = nt->Length + sizeof(WCHAR);
- for (p = nt->Buffer + sizeof(prefixW)/sizeof(WCHAR); *p; p++) if (*p == '/') *p = '\\';
+ for (p = nt->Buffer + ARRAY_SIZE( prefixW ); *p; p++) if (*p == '/') *p = '\\';
done:
RtlFreeHeap( GetProcessHeap(), 0, cwd );
diff --git a/dlls/ntdll/relay.c b/dlls/ntdll/relay.c
index 255a5259e1..4ebd1fd688 100644
--- a/dlls/ntdll/relay.c
+++ b/dlls/ntdll/relay.c
@@ -1197,10 +1197,10 @@ void WINAPI DECLSPEC_HIDDEN __regs_SNOOP_Entry( void **stack )
while (*rets) {
- for (i=0;i<sizeof((*rets)->entry)/sizeof((*rets)->entry[0]);i++)
+ for (i=0;i<ARRAY_SIZE( (*rets)->entry );i++)
if (!(*rets)->entry[i].origreturn)
break;
- if (i!=sizeof((*rets)->entry)/sizeof((*rets)->entry[0]))
+ if (i!=ARRAY_SIZE( (*rets)->entry ))
break;
rets = &((*rets)->next);
}
diff --git a/dlls/ntdll/signal_arm.c b/dlls/ntdll/signal_arm.c
index 5e35907484..1986389077 100644
--- a/dlls/ntdll/signal_arm.c
+++ b/dlls/ntdll/signal_arm.c
@@ -940,7 +940,7 @@ static void usr1_handler( int signal, siginfo_t *siginfo, void *sigcontext )
*/
int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
{
- if (sig >= sizeof(handlers) / sizeof(handlers[0])) return -1;
+ if (sig >= ARRAY_SIZE(handlers)) return -1;
if (handlers[sig] != NULL) return -2;
handlers[sig] = wsh;
return 0;
diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c
index 55a711048c..5a44914489 100644
--- a/dlls/ntdll/signal_arm64.c
+++ b/dlls/ntdll/signal_arm64.c
@@ -838,7 +838,7 @@ static void usr1_handler( int signal, siginfo_t *siginfo, void *sigcontext )
*/
int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
{
- if (sig >= sizeof(handlers) / sizeof(handlers[0])) return -1;
+ if (sig >= ARRAY_SIZE(handlers)) return -1;
if (handlers[sig] != NULL) return -2;
handlers[sig] = wsh;
return 0;
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index 23630857ef..384615fc26 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -2221,7 +2221,7 @@ static void usr1_handler( int signal, siginfo_t *siginfo, void *sigcontext )
*/
int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
{
- if (sig >= sizeof(handlers) / sizeof(handlers[0])) return -1;
+ if (sig >= ARRAY_SIZE(handlers)) return -1;
if (handlers[sig] != NULL) return -2;
handlers[sig] = wsh;
return 0;
diff --git a/dlls/ntdll/signal_powerpc.c b/dlls/ntdll/signal_powerpc.c
index f88beec8d8..f5231e7b34 100644
--- a/dlls/ntdll/signal_powerpc.c
+++ b/dlls/ntdll/signal_powerpc.c
@@ -1006,7 +1006,7 @@ static void usr1_handler( int signal, siginfo_t *siginfo, void *sigcontext )
*/
int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
{
- if (sig >= sizeof(handlers) / sizeof(handlers[0])) return -1;
+ if (sig >= ARRAY_SIZE(handlers)) return -1;
if (handlers[sig] != NULL) return -2;
handlers[sig] = wsh;
return 0;
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
index e751082d72..4fb80bb378 100644
--- a/dlls/ntdll/signal_x86_64.c
+++ b/dlls/ntdll/signal_x86_64.c
@@ -3247,7 +3247,7 @@ static void usr1_handler( int signal, siginfo_t *siginfo, void *ucontext )
*/
int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh)
{
- if (sig >= sizeof(handlers) / sizeof(handlers[0])) return -1;
+ if (sig >= ARRAY_SIZE(handlers)) return -1;
if (handlers[sig] != NULL) return -2;
handlers[sig] = wsh;
return 0;
diff --git a/dlls/ntdll/time.c b/dlls/ntdll/time.c
index e2cd770af0..b0eefb8465 100644
--- a/dlls/ntdll/time.c
+++ b/dlls/ntdll/time.c
@@ -605,8 +605,7 @@ static BOOL match_tz_name(const char* tz_name,
return TRUE;
strcpyW(key.key_name, reg_tzi->TimeZoneKeyName);
- match = bsearch(&key, mapping, sizeof(mapping)/sizeof(mapping[0]),
- sizeof(mapping[0]), compare_tz_key);
+ match = bsearch(&key, mapping, ARRAY_SIZE(mapping), sizeof(mapping[0]), compare_tz_key);
if (!match)
return TRUE;
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index befb59c436..af1509eae5 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1416,7 +1416,7 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, SIZE_T m
memset( ptr + header_size, 0, header_end - (ptr + header_size) );
if ((char *)(nt + 1) > header_end) goto error;
header_start = (char*)&nt->OptionalHeader+nt->FileHeader.SizeOfOptionalHeader;
- if (nt->FileHeader.NumberOfSections > sizeof(sections)/sizeof(*sections)) goto error;
+ if (nt->FileHeader.NumberOfSections > ARRAY_SIZE( sections )) goto error;
if (header_start + sizeof(*sections) * nt->FileHeader.NumberOfSections > header_end) goto error;
/* Some applications (e.g. the Steam version of Borderlands) map over the top of the section headers,
* copying the headers into local memory is necessary to properly load such applications. */
--
2.14.4