msi: Use the ARRAY_SIZE() macro.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Michael Stefaniuc 2018-08-20 21:15:43 +02:00 committed by Alexandre Julliard
parent 8204d04b7f
commit a9cb67bb7f
13 changed files with 40 additions and 41 deletions

View File

@ -2152,7 +2152,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)
@ -5546,9 +5546,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);
@ -6214,7 +6214,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;
@ -7686,7 +7686,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;
@ -7701,7 +7701,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) )))
{

View File

@ -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,

View File

@ -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];
}

View File

@ -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]);

View File

@ -213,7 +213,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)
@ -605,9 +605,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());
@ -943,7 +943,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;

View File

@ -451,7 +451,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;

View File

@ -3377,7 +3377,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;

View File

@ -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 );

View File

@ -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;

View File

@ -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)

View File

@ -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 );

View File

@ -1006,7 +1006,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;

View File

@ -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;