https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9792c08fe4822bd1f95bd…
commit 9792c08fe4822bd1f95bda0f57946acc3feaa475
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sat Mar 12 23:54:36 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:28:00 2022 +0100
[WINESYNC] msi: Use the ARRAY_SIZE() macro.
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id a9cb67bb7ffb5b25469ba6a732f8913ac8778c36 by Michael Stefaniuc
<mstefani(a)winehq.org>
---
dll/win32/msi/action.c | 12 ++++++------
dll/win32/msi/appsearch.c | 3 +--
dll/win32/msi/assembly.c | 2 +-
dll/win32/msi/automation.c | 2 +-
dll/win32/msi/custom.c | 8 ++++----
dll/win32/msi/database.c | 2 +-
dll/win32/msi/dialog.c | 2 +-
dll/win32/msi/msi.c | 4 ++--
dll/win32/msi/package.c | 2 +-
dll/win32/msi/patch.c | 2 +-
dll/win32/msi/registry.c | 38 +++++++++++++++++++-------------------
dll/win32/msi/source.c | 2 +-
dll/win32/msi/upgrade.c | 2 +-
13 files changed, 40 insertions(+), 41 deletions(-)
diff --git a/dll/win32/msi/action.c b/dll/win32/msi/action.c
index ac925417866..1ef6da8562b 100644
--- a/dll/win32/msi/action.c
+++ b/dll/win32/msi/action.c
@@ -2159,7 +2159,7 @@ static WCHAR *create_temp_dir( MSIDATABASE *db )
if (!db->tempfolder)
{
WCHAR tmp[MAX_PATH];
- UINT len = sizeof(tmp)/sizeof(tmp[0]);
+ UINT len = ARRAY_SIZE( tmp );
if (msi_get_property( db, szTempFolder, tmp, &len ) ||
GetFileAttributesW( tmp ) != FILE_ATTRIBUTE_DIRECTORY)
@@ -5560,9 +5560,9 @@ UINT ACTION_ForceReboot(MSIPACKAGE *package)
squash_guid( package->ProductCode, squashed_pc );
- GetSystemDirectoryW(sysdir, sizeof(sysdir)/sizeof(sysdir[0]));
+ GetSystemDirectoryW(sysdir, ARRAY_SIZE(sysdir));
RegCreateKeyW(HKEY_LOCAL_MACHINE,RunOnce,&hkey);
- snprintfW( buffer, sizeof(buffer)/sizeof(buffer[0]), msiexec_fmt, sysdir, squashed_pc
);
+ snprintfW(buffer, ARRAY_SIZE(buffer), msiexec_fmt, sysdir, squashed_pc);
msi_reg_set_val_str( hkey, squashed_pc, buffer );
RegCloseKey(hkey);
@@ -6228,7 +6228,7 @@ static LPCWSTR *msi_service_args_to_vector(LPWSTR args, DWORD
*numargs)
static const WCHAR separator[] = {'[','~',']',0};
*numargs = 0;
- sep_len = sizeof(separator) / sizeof(WCHAR) - 1;
+ sep_len = ARRAY_SIZE(separator) - 1;
if (!args)
return NULL;
@@ -7704,7 +7704,7 @@ static UINT ITERATE_RemoveExistingProducts( MSIRECORD *rec, LPVOID
param )
MSIPACKAGE *package = param;
const WCHAR *property = MSI_RecordGetString( rec, 7 );
int attrs = MSI_RecordGetInteger( rec, 5 );
- UINT len = sizeof(fmtW)/sizeof(fmtW[0]);
+ UINT len = ARRAY_SIZE( fmtW );
WCHAR *product, *features, *cmd;
STARTUPINFOW si;
PROCESS_INFORMATION info;
@@ -7719,7 +7719,7 @@ static UINT ITERATE_RemoveExistingProducts( MSIRECORD *rec, LPVOID
param )
if (features)
len += strlenW( features );
else
- len += sizeof(szAll) / sizeof(szAll[0]);
+ len += ARRAY_SIZE( szAll );
if (!(cmd = msi_alloc( len * sizeof(WCHAR) )))
{
diff --git a/dll/win32/msi/appsearch.c b/dll/win32/msi/appsearch.c
index 693da18355c..fbed073bd4a 100644
--- a/dll/win32/msi/appsearch.c
+++ b/dll/win32/msi/appsearch.c
@@ -949,8 +949,7 @@ static UINT ACTION_SearchDirectory(MSIPACKAGE *package, MSISIGNATURE
*sig,
if (GetDriveTypeW(pathWithDrive) != DRIVE_FIXED)
continue;
- lstrcpynW(pathWithDrive + 3, path,
- sizeof(pathWithDrive) / sizeof(pathWithDrive[0]) - 3);
+ lstrcpynW(pathWithDrive + 3, path, ARRAY_SIZE(pathWithDrive) - 3);
if (sig->File)
rc = ACTION_RecurseSearchDirectory(package, &val, sig,
diff --git a/dll/win32/msi/assembly.c b/dll/win32/msi/assembly.c
index 59fd332d253..e3bd9651507 100644
--- a/dll/win32/msi/assembly.c
+++ b/dll/win32/msi/assembly.c
@@ -344,7 +344,7 @@ static const WCHAR *clr_version[] =
static const WCHAR *get_clr_version_str( enum clr_version version )
{
- if (version >= sizeof(clr_version)/sizeof(clr_version[0])) return
clr_version_unknown;
+ if (version >= ARRAY_SIZE( clr_version )) return clr_version_unknown;
return clr_version[version];
}
diff --git a/dll/win32/msi/automation.c b/dll/win32/msi/automation.c
index 06ad2f90a4b..80254e6df45 100644
--- a/dll/win32/msi/automation.c
+++ b/dll/win32/msi/automation.c
@@ -130,7 +130,7 @@ void release_typelib(void)
{
unsigned i;
- for (i = 0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
+ for (i = 0; i < ARRAY_SIZE(typeinfos); i++)
if (typeinfos[i])
ITypeInfo_Release(typeinfos[i]);
diff --git a/dll/win32/msi/custom.c b/dll/win32/msi/custom.c
index 0107cd941ed..78e846d9590 100644
--- a/dll/win32/msi/custom.c
+++ b/dll/win32/msi/custom.c
@@ -214,7 +214,7 @@ WCHAR *msi_create_temp_file( MSIDATABASE *db )
if (!db->tempfolder)
{
WCHAR tmp[MAX_PATH];
- UINT len = sizeof(tmp)/sizeof(tmp[0]);
+ UINT len = ARRAY_SIZE( tmp );
if (msi_get_property( db, szTempFolder, tmp, &len ) ||
GetFileAttributesW( tmp ) != FILE_ATTRIBUTE_DIRECTORY)
@@ -620,9 +620,9 @@ static DWORD custom_start_server(MSIPACKAGE *package, DWORD arch)
wow64 = FALSE;
if ((sizeof(void *) == 8 || wow64) && arch == SCS_32BIT_BINARY)
- GetSystemWow64DirectoryW(path, MAX_PATH - sizeof(msiexecW)/sizeof(WCHAR));
+ GetSystemWow64DirectoryW(path, MAX_PATH - ARRAY_SIZE(msiexecW));
else
- GetSystemDirectoryW(path, MAX_PATH - sizeof(msiexecW)/sizeof(WCHAR));
+ GetSystemDirectoryW(path, MAX_PATH - ARRAY_SIZE(msiexecW));
strcatW(path, msiexecW);
sprintfW(cmdline, argsW, path, GetCurrentProcessId());
@@ -958,7 +958,7 @@ static UINT HANDLE_CustomType23( MSIPACKAGE *package, const WCHAR
*source, const
static const WCHAR msiexecW[] =
{'m','s','i','e','x','e','c',0};
static const WCHAR paramsW[] = {'/','q','b','
','/','i',' '};
WCHAR *dir, *arg, *p;
- UINT len_src, len_dir, len_tgt, len = sizeof(paramsW)/sizeof(paramsW[0]);
+ UINT len_src, len_dir, len_tgt, len = ARRAY_SIZE( paramsW );
HANDLE handle;
if (!(dir = msi_dup_property( package->db, szOriginalDatabase ))) return
ERROR_OUTOFMEMORY;
diff --git a/dll/win32/msi/database.c b/dll/win32/msi/database.c
index 303667d52b8..91e5e96832b 100644
--- a/dll/win32/msi/database.c
+++ b/dll/win32/msi/database.c
@@ -458,7 +458,7 @@ static LPWSTR msi_build_createsql_prelude(LPWSTR table)
static const WCHAR create_fmt[] =
{'C','R','E','A','T','E','
','T','A','B','L','E','
','`','%','s','`',' ','(','
',0};
- size = sizeof(create_fmt)/sizeof(create_fmt[0]) + lstrlenW(table) - 2;
+ size = ARRAY_SIZE(create_fmt) + lstrlenW(table) - 2;
prelude = msi_alloc(size * sizeof(WCHAR));
if (!prelude)
return NULL;
diff --git a/dll/win32/msi/dialog.c b/dll/win32/msi/dialog.c
index f0222de0a66..860b80e4073 100644
--- a/dll/win32/msi/dialog.c
+++ b/dll/win32/msi/dialog.c
@@ -3384,7 +3384,7 @@ static UINT msi_dialog_hyperlink_handler( msi_dialog *dialog,
msi_control *contr
{
static const WCHAR hrefW[] = {'h','r','e','f'};
static const WCHAR openW[] = {'o','p','e','n',0};
- int len, len_href = sizeof(hrefW) / sizeof(hrefW[0]);
+ int len, len_href = ARRAY_SIZE( hrefW );
const WCHAR *p, *q;
WCHAR quote = 0;
LITEM item;
diff --git a/dll/win32/msi/msi.c b/dll/win32/msi/msi.c
index 1043452388c..db29625b255 100644
--- a/dll/win32/msi/msi.c
+++ b/dll/win32/msi/msi.c
@@ -1028,7 +1028,7 @@ UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR
szBuffer)
UINT rc, index;
HKEY compkey, prodkey;
WCHAR squashed_comp[SQUASHED_GUID_SIZE], squashed_prod[SQUASHED_GUID_SIZE];
- DWORD sz = sizeof(squashed_prod)/sizeof(squashed_prod[0]);
+ DWORD sz = ARRAY_SIZE(squashed_prod);
TRACE("%s %p\n", debugstr_w(szComponent), szBuffer);
@@ -3482,7 +3482,7 @@ static UINT MSI_ProvideQualifiedComponentEx(LPCWSTR szComponent,
return ERROR_FILE_NOT_FOUND;
}
msi_free( components );
- StringFromGUID2( &guid, comp, sizeof(comp)/sizeof(comp[0]) );
+ StringFromGUID2( &guid, comp, ARRAY_SIZE( comp ));
}
state = MSI_GetComponentPath( szProduct, comp, szAllSid, MSIINSTALLCONTEXT_ALL,
lpPathBuf, pcchPathBuf );
diff --git a/dll/win32/msi/package.c b/dll/win32/msi/package.c
index 577fcbbf185..fa0831bc2de 100644
--- a/dll/win32/msi/package.c
+++ b/dll/win32/msi/package.c
@@ -559,7 +559,7 @@ static LPWSTR get_fusion_filename(MSIPACKAGE *package)
if (!RegCreateKeyExW(netsetup, v4client, 0, NULL, 0, KEY_QUERY_VALUE, NULL,
&hkey, NULL))
{
- size = sizeof(path)/sizeof(path[0]);
+ size = ARRAY_SIZE(path);
if (!RegQueryValueExW(hkey, installpath, NULL, &type, (BYTE *)path,
&size))
{
len = strlenW(path) + strlenW(fusion) + 2;
diff --git a/dll/win32/msi/patch.c b/dll/win32/msi/patch.c
index f6ed3c1f1a4..bd9b7b87df4 100644
--- a/dll/win32/msi/patch.c
+++ b/dll/win32/msi/patch.c
@@ -1037,7 +1037,7 @@ UINT msi_apply_registered_patch( MSIPACKAGE *package, LPCWSTR
patch_code )
TRACE("%p, %s\n", package, debugstr_w(patch_code));
- len = sizeof(patch_file) / sizeof(WCHAR);
+ len = ARRAY_SIZE( patch_file );
r = MsiGetPatchInfoExW( patch_code, package->ProductCode, NULL,
package->Context,
INSTALLPROPERTY_LOCALPACKAGEW, patch_file, &len );
if (r != ERROR_SUCCESS)
diff --git a/dll/win32/msi/registry.c b/dll/win32/msi/registry.c
index cbc8d8d6f0a..efc72725ce7 100644
--- a/dll/win32/msi/registry.c
+++ b/dll/win32/msi/registry.c
@@ -1297,12 +1297,12 @@ static UINT fetch_machine_component( DWORD ctx, DWORD index, DWORD
*idx, WCHAR g
if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, componentsW, 0, access, &key_components
))
return ERROR_NO_MORE_ITEMS;
- len_component = sizeof(component)/sizeof(component[0]);
+ len_component = ARRAY_SIZE( component );
while (!RegEnumKeyExW( key_components, i, component, &len_component, NULL, NULL,
NULL, NULL ))
{
if (*idx == index) goto found;
(*idx)++;
- len_component = sizeof(component)/sizeof(component[0]);
+ len_component = ARRAY_SIZE( component );
i++;
}
RegCloseKey( key_components );
@@ -1349,14 +1349,14 @@ static UINT fetch_user_component( const WCHAR *usersid, DWORD ctx,
DWORD index,
if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, userdataW, 0, access, &key_users ))
return ERROR_NO_MORE_ITEMS;
- len_user = sizeof(user)/sizeof(user[0]);
+ len_user = ARRAY_SIZE( user );
while (!RegEnumKeyExW( key_users, i, user, &len_user, NULL, NULL, NULL, NULL ))
{
if ((strcmpW( usersid, szAllSid ) && strcmpW( usersid, user )) ||
!strcmpW( szLocalSid, user ))
{
i++;
- len_user = sizeof(user)/sizeof(user[0]);
+ len_user = ARRAY_SIZE( user );
continue;
}
strcpyW( path, user );
@@ -1364,19 +1364,19 @@ static UINT fetch_user_component( const WCHAR *usersid, DWORD ctx,
DWORD index,
if (RegOpenKeyExW( key_users, path, 0, access, &key_components ))
{
i++;
- len_user = sizeof(user)/sizeof(user[0]);
+ len_user = ARRAY_SIZE( user );
continue;
}
- len_component = sizeof(component)/sizeof(component[0]);
+ len_component = ARRAY_SIZE( component );
while (!RegEnumKeyExW( key_components, j, component, &len_component, NULL,
NULL, NULL, NULL ))
{
if (*idx == index) goto found;
(*idx)++;
- len_component = sizeof(component)/sizeof(component[0]);
+ len_component = ARRAY_SIZE( component );
j++;
}
RegCloseKey( key_components );
- len_user = sizeof(user)/sizeof(user[0]);
+ len_user = ARRAY_SIZE( user );
i++;
}
RegCloseKey( key_users );
@@ -1709,7 +1709,7 @@ UINT WINAPI MsiEnumRelatedProductsW(LPCWSTR szUpgradeCode, DWORD
dwReserved,
UINT r;
HKEY hkey;
WCHAR szKeyName[SQUASHED_GUID_SIZE];
- DWORD dwSize = sizeof(szKeyName)/sizeof(szKeyName[0]);
+ DWORD dwSize = ARRAY_SIZE(szKeyName);
TRACE("%s %u %u %p\n", debugstr_w(szUpgradeCode), dwReserved,
iProductIndex, lpProductBuf);
@@ -2324,18 +2324,18 @@ static UINT fetch_machine_product( const WCHAR *match, DWORD
index, DWORD *idx,
if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, productsW, 0, access, &key ))
return ERROR_NO_MORE_ITEMS;
- len = sizeof(product)/sizeof(product[0]);
+ len = ARRAY_SIZE( product );
while (!RegEnumKeyExW( key, i, product, &len, NULL, NULL, NULL, NULL ))
{
if (match && strcmpW( match, product ))
{
i++;
- len = sizeof(product)/sizeof(product[0]);
+ len = ARRAY_SIZE( product );
continue;
}
if (*idx == index) goto found;
(*idx)++;
- len = sizeof(product)/sizeof(product[0]);
+ len = ARRAY_SIZE( product );
i++;
}
RegCloseKey( key );
@@ -2396,13 +2396,13 @@ static UINT fetch_user_product( const WCHAR *match, const WCHAR
*usersid, DWORD
}
else return ERROR_INVALID_PARAMETER;
- len_user = sizeof(user)/sizeof(user[0]);
+ len_user = ARRAY_SIZE( user );
while (!RegEnumKeyExW( key_users, i, user, &len_user, NULL, NULL, NULL, NULL ))
{
if (strcmpW( usersid, user ) && strcmpW( usersid, szAllSid ))
{
i++;
- len_user = sizeof(user)/sizeof(user[0]);
+ len_user = ARRAY_SIZE( user );
continue;
}
strcpyW( path, user );
@@ -2410,25 +2410,25 @@ static UINT fetch_user_product( const WCHAR *match, const WCHAR
*usersid, DWORD
if (RegOpenKeyExW( key_users, path, 0, access, &key_products ))
{
i++;
- len_user = sizeof(user)/sizeof(user[0]);
+ len_user = ARRAY_SIZE( user );
continue;
}
- len_product = sizeof(product)/sizeof(product[0]);
+ len_product = ARRAY_SIZE( product );
while (!RegEnumKeyExW( key_products, j, product, &len_product, NULL, NULL,
NULL, NULL ))
{
if (match && strcmpW( match, product ))
{
j++;
- len_product = sizeof(product)/sizeof(product[0]);
+ len_product = ARRAY_SIZE( product );
continue;
}
if (*idx == index) goto found;
(*idx)++;
- len_product = sizeof(product)/sizeof(product[0]);
+ len_product = ARRAY_SIZE( product );
j++;
}
RegCloseKey( key_products );
- len_user = sizeof(user)/sizeof(user[0]);
+ len_user = ARRAY_SIZE( user );
i++;
}
RegCloseKey( key_users );
diff --git a/dll/win32/msi/source.c b/dll/win32/msi/source.c
index 960324b11db..3640b0dfbd2 100644
--- a/dll/win32/msi/source.c
+++ b/dll/win32/msi/source.c
@@ -1010,7 +1010,7 @@ static UINT fill_source_list(struct list *sourcelist, HKEY
sourcekey, DWORD *cou
while (r == ERROR_SUCCESS)
{
- size = sizeof(name) / sizeof(name[0]);
+ size = ARRAY_SIZE(name);
r = RegEnumValueW(sourcekey, index, name, &size, NULL, NULL, NULL,
&val_size);
if (r != ERROR_SUCCESS)
return r;
diff --git a/dll/win32/msi/upgrade.c b/dll/win32/msi/upgrade.c
index ac58d909e05..bbc7df6eec5 100644
--- a/dll/win32/msi/upgrade.c
+++ b/dll/win32/msi/upgrade.c
@@ -103,7 +103,7 @@ static UINT ITERATE_FindRelatedProducts(MSIRECORD *rec, LPVOID param)
{
MSIPACKAGE *package = param;
WCHAR product[SQUASHED_GUID_SIZE];
- DWORD index = 0, attributes = 0, sz = sizeof(product)/sizeof(product[0]);
+ DWORD index = 0, attributes = 0, sz = ARRAY_SIZE(product);
LPCWSTR upgrade_code;
HKEY hkey = 0;
UINT rc = ERROR_SUCCESS;