wbemprox: Prefer the standard 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>
This commit is contained in:
Michael Stefaniuc 2018-11-15 20:59:48 +01:00 committed by Alexandre Julliard
parent ad576b6965
commit 904820a523
6 changed files with 53 additions and 55 deletions

View File

@ -1250,7 +1250,7 @@ static UINT16 systemenclosure_chassistypes[] =
};
static const struct array systemenclosure_chassistypes_array =
{
SIZEOF(systemenclosure_chassistypes),
ARRAY_SIZE(systemenclosure_chassistypes),
&systemenclosure_chassistypes
};
static const struct record_systemenclosure data_systemenclosure[] =
@ -3522,38 +3522,38 @@ done:
static struct table builtin_classes[] =
{
{ class_baseboardW, SIZEOF(col_baseboard), col_baseboard, SIZEOF(data_baseboard), 0, (BYTE *)data_baseboard },
{ class_biosW, SIZEOF(col_bios), col_bios, SIZEOF(data_bios), 0, (BYTE *)data_bios },
{ class_cdromdriveW, SIZEOF(col_cdromdrive), col_cdromdrive, 0, 0, NULL, fill_cdromdrive },
{ class_compsysW, SIZEOF(col_compsys), col_compsys, 0, 0, NULL, fill_compsys },
{ class_compsysproductW, SIZEOF(col_compsysproduct), col_compsysproduct, 0, 0, NULL, fill_compsysproduct },
{ class_datafileW, SIZEOF(col_datafile), col_datafile, 0, 0, NULL, fill_datafile },
{ class_desktopmonitorW, SIZEOF(col_desktopmonitor), col_desktopmonitor, 0, 0, NULL, fill_desktopmonitor },
{ class_directoryW, SIZEOF(col_directory), col_directory, 0, 0, NULL, fill_directory },
{ class_diskdriveW, SIZEOF(col_diskdrive), col_diskdrive, 0, 0, NULL, fill_diskdrive },
{ class_diskpartitionW, SIZEOF(col_diskpartition), col_diskpartition, 0, 0, NULL, fill_diskpartition },
{ class_ip4routetableW, SIZEOF(col_ip4routetable), col_ip4routetable, 0, 0, NULL, fill_ip4routetable },
{ class_logicaldiskW, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
{ class_logicaldisk2W, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
{ class_networkadapterW, SIZEOF(col_networkadapter), col_networkadapter, 0, 0, NULL, fill_networkadapter },
{ class_networkadapterconfigW, SIZEOF(col_networkadapterconfig), col_networkadapterconfig, 0, 0, NULL, fill_networkadapterconfig },
{ class_osW, SIZEOF(col_os), col_os, 0, 0, NULL, fill_os },
{ class_paramsW, SIZEOF(col_param), col_param, SIZEOF(data_param), 0, (BYTE *)data_param },
{ class_physicalmediaW, SIZEOF(col_physicalmedia), col_physicalmedia, SIZEOF(data_physicalmedia), 0, (BYTE *)data_physicalmedia },
{ class_physicalmemoryW, SIZEOF(col_physicalmemory), col_physicalmemory, 0, 0, NULL, fill_physicalmemory },
{ class_pnpentityW, SIZEOF(col_pnpentity), col_pnpentity, 0, 0, NULL, fill_pnpentity },
{ class_printerW, SIZEOF(col_printer), col_printer, 0, 0, NULL, fill_printer },
{ class_processW, SIZEOF(col_process), col_process, 0, 0, NULL, fill_process },
{ class_processorW, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
{ class_processor2W, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
{ class_qualifiersW, SIZEOF(col_qualifier), col_qualifier, SIZEOF(data_qualifier), 0, (BYTE *)data_qualifier },
{ class_serviceW, SIZEOF(col_service), col_service, 0, 0, NULL, fill_service },
{ class_sidW, SIZEOF(col_sid), col_sid, 0, 0, NULL, fill_sid },
{ class_sounddeviceW, SIZEOF(col_sounddevice), col_sounddevice, SIZEOF(data_sounddevice), 0, (BYTE *)data_sounddevice },
{ class_stdregprovW, SIZEOF(col_stdregprov), col_stdregprov, SIZEOF(data_stdregprov), 0, (BYTE *)data_stdregprov },
{ class_systemsecurityW, SIZEOF(col_systemsecurity), col_systemsecurity, SIZEOF(data_systemsecurity), 0, (BYTE *)data_systemsecurity },
{ class_systemenclosureW, SIZEOF(col_systemenclosure), col_systemenclosure, SIZEOF(data_systemenclosure), 0, (BYTE *)data_systemenclosure },
{ class_videocontrollerW, SIZEOF(col_videocontroller), col_videocontroller, 0, 0, NULL, fill_videocontroller }
{ class_baseboardW, ARRAY_SIZE(col_baseboard), col_baseboard, ARRAY_SIZE(data_baseboard), 0, (BYTE *)data_baseboard },
{ class_biosW, ARRAY_SIZE(col_bios), col_bios, ARRAY_SIZE(data_bios), 0, (BYTE *)data_bios },
{ class_cdromdriveW, ARRAY_SIZE(col_cdromdrive), col_cdromdrive, 0, 0, NULL, fill_cdromdrive },
{ class_compsysW, ARRAY_SIZE(col_compsys), col_compsys, 0, 0, NULL, fill_compsys },
{ class_compsysproductW, ARRAY_SIZE(col_compsysproduct), col_compsysproduct, 0, 0, NULL, fill_compsysproduct },
{ class_datafileW, ARRAY_SIZE(col_datafile), col_datafile, 0, 0, NULL, fill_datafile },
{ class_desktopmonitorW, ARRAY_SIZE(col_desktopmonitor), col_desktopmonitor, 0, 0, NULL, fill_desktopmonitor },
{ class_directoryW, ARRAY_SIZE(col_directory), col_directory, 0, 0, NULL, fill_directory },
{ class_diskdriveW, ARRAY_SIZE(col_diskdrive), col_diskdrive, 0, 0, NULL, fill_diskdrive },
{ class_diskpartitionW, ARRAY_SIZE(col_diskpartition), col_diskpartition, 0, 0, NULL, fill_diskpartition },
{ class_ip4routetableW, ARRAY_SIZE(col_ip4routetable), col_ip4routetable, 0, 0, NULL, fill_ip4routetable },
{ class_logicaldiskW, ARRAY_SIZE(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
{ class_logicaldisk2W, ARRAY_SIZE(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
{ class_networkadapterW, ARRAY_SIZE(col_networkadapter), col_networkadapter, 0, 0, NULL, fill_networkadapter },
{ class_networkadapterconfigW, ARRAY_SIZE(col_networkadapterconfig), col_networkadapterconfig, 0, 0, NULL, fill_networkadapterconfig },
{ class_osW, ARRAY_SIZE(col_os), col_os, 0, 0, NULL, fill_os },
{ class_paramsW, ARRAY_SIZE(col_param), col_param, ARRAY_SIZE(data_param), 0, (BYTE *)data_param },
{ class_physicalmediaW, ARRAY_SIZE(col_physicalmedia), col_physicalmedia, ARRAY_SIZE(data_physicalmedia), 0, (BYTE *)data_physicalmedia },
{ class_physicalmemoryW, ARRAY_SIZE(col_physicalmemory), col_physicalmemory, 0, 0, NULL, fill_physicalmemory },
{ class_pnpentityW, ARRAY_SIZE(col_pnpentity), col_pnpentity, 0, 0, NULL, fill_pnpentity },
{ class_printerW, ARRAY_SIZE(col_printer), col_printer, 0, 0, NULL, fill_printer },
{ class_processW, ARRAY_SIZE(col_process), col_process, 0, 0, NULL, fill_process },
{ class_processorW, ARRAY_SIZE(col_processor), col_processor, 0, 0, NULL, fill_processor },
{ class_processor2W, ARRAY_SIZE(col_processor), col_processor, 0, 0, NULL, fill_processor },
{ class_qualifiersW, ARRAY_SIZE(col_qualifier), col_qualifier, ARRAY_SIZE(data_qualifier), 0, (BYTE *)data_qualifier },
{ class_serviceW, ARRAY_SIZE(col_service), col_service, 0, 0, NULL, fill_service },
{ class_sidW, ARRAY_SIZE(col_sid), col_sid, 0, 0, NULL, fill_sid },
{ class_sounddeviceW, ARRAY_SIZE(col_sounddevice), col_sounddevice, ARRAY_SIZE(data_sounddevice), 0, (BYTE *)data_sounddevice },
{ class_stdregprovW, ARRAY_SIZE(col_stdregprov), col_stdregprov, ARRAY_SIZE(data_stdregprov), 0, (BYTE *)data_stdregprov },
{ class_systemsecurityW, ARRAY_SIZE(col_systemsecurity), col_systemsecurity, ARRAY_SIZE(data_systemsecurity), 0, (BYTE *)data_systemsecurity },
{ class_systemenclosureW, ARRAY_SIZE(col_systemenclosure), col_systemenclosure, ARRAY_SIZE(data_systemenclosure), 0, (BYTE *)data_systemenclosure },
{ class_videocontrollerW, ARRAY_SIZE(col_videocontroller), col_videocontroller, 0, 0, NULL, fill_videocontroller }
};
void init_table_list( void )
@ -3561,6 +3561,6 @@ void init_table_list( void )
static struct list tables = LIST_INIT( tables );
UINT i;
for (i = 0; i < SIZEOF(builtin_classes); i++) list_add_tail( &tables, &builtin_classes[i].entry );
for (i = 0; i < ARRAY_SIZE(builtin_classes); i++) list_add_tail( &tables, &builtin_classes[i].entry );
table_list = &tables;
}

View File

@ -807,7 +807,7 @@ static WCHAR *build_signature_table_name( const WCHAR *class, const WCHAR *metho
static const WCHAR fmtW[] = {'_','_','%','s','_','%','s','_','%','s',0};
static const WCHAR outW[] = {'O','U','T',0};
static const WCHAR inW[] = {'I','N',0};
UINT len = SIZEOF(fmtW) + SIZEOF(outW) + strlenW( class ) + strlenW( method );
UINT len = ARRAY_SIZE(fmtW) + ARRAY_SIZE(outW) + strlenW( class ) + strlenW( method );
WCHAR *ret;
if (!(ret = heap_alloc( len * sizeof(WCHAR) ))) return NULL;
@ -826,7 +826,7 @@ HRESULT create_signature( const WCHAR *class, const WCHAR *method, enum param_di
'D','i','r','e','c','t','i','o','n','%','s',0};
static const WCHAR geW[] = {'>','=','0',0};
static const WCHAR leW[] = {'<','=','0',0};
UINT len = SIZEOF(selectW) + SIZEOF(geW);
UINT len = ARRAY_SIZE(selectW) + ARRAY_SIZE(geW);
IEnumWbemClassObject *iter;
WCHAR *query, *name;
HRESULT hr;

View File

@ -109,8 +109,8 @@ static HRESULT create_qualifier_enum( const WCHAR *class, const WCHAR *member, c
if (!member) member = noneW;
len = strlenW( class ) + strlenW( member );
if (name) len += strlenW( name ) + SIZEOF(fmtW);
else len += SIZEOF(fmt2W);
if (name) len += strlenW( name ) + ARRAY_SIZE(fmtW);
else len += ARRAY_SIZE(fmt2W);
if (!(query = heap_alloc( len * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
if (name) sprintfW( query, fmtW, class, member, name );

View File

@ -420,13 +420,13 @@ static WCHAR *query_from_path( const struct path *path )
if (path->filter)
{
len = path->class_len + path->filter_len + SIZEOF(selectW);
len = path->class_len + path->filter_len + ARRAY_SIZE(selectW);
if (!(query = heap_alloc( len * sizeof(WCHAR) ))) return NULL;
sprintfW( query, selectW, path->class, path->filter );
}
else
{
len = path->class_len + SIZEOF(select_allW);
len = path->class_len + ARRAY_SIZE(select_allW);
if (!(query = heap_alloc( len * sizeof(WCHAR) ))) return NULL;
strcpyW( query, select_allW );
strcatW( query, path->class );

View File

@ -24,8 +24,6 @@
IClientSecurity client_security DECLSPEC_HIDDEN;
struct list *table_list DECLSPEC_HIDDEN;
#define SIZEOF(array) (sizeof(array)/sizeof((array)[0]))
enum param_direction
{
PARAM_OUT = -1,

View File

@ -559,18 +559,18 @@ static const WCHAR whereW[] = {'W','H','E','R','E'};
static const struct keyword keyword_table[] =
{
{ andW, SIZEOF(andW), TK_AND },
{ byW, SIZEOF(byW), TK_BY },
{ falseW, SIZEOF(falseW), TK_FALSE },
{ fromW, SIZEOF(fromW), TK_FROM },
{ isW, SIZEOF(isW), TK_IS },
{ likeW, SIZEOF(likeW), TK_LIKE },
{ notW, SIZEOF(notW), TK_NOT },
{ nullW, SIZEOF(nullW), TK_NULL },
{ orW, SIZEOF(orW), TK_OR },
{ selectW, SIZEOF(selectW), TK_SELECT },
{ trueW, SIZEOF(trueW), TK_TRUE },
{ whereW, SIZEOF(whereW), TK_WHERE }
{ andW, ARRAY_SIZE(andW), TK_AND },
{ byW, ARRAY_SIZE(byW), TK_BY },
{ falseW, ARRAY_SIZE(falseW), TK_FALSE },
{ fromW, ARRAY_SIZE(fromW), TK_FROM },
{ isW, ARRAY_SIZE(isW), TK_IS },
{ likeW, ARRAY_SIZE(likeW), TK_LIKE },
{ notW, ARRAY_SIZE(notW), TK_NOT },
{ nullW, ARRAY_SIZE(nullW), TK_NULL },
{ orW, ARRAY_SIZE(orW), TK_OR },
{ selectW, ARRAY_SIZE(selectW), TK_SELECT },
{ trueW, ARRAY_SIZE(trueW), TK_TRUE },
{ whereW, ARRAY_SIZE(whereW), TK_WHERE }
};
static int cmp_keyword( const void *arg1, const void *arg2 )
@ -594,7 +594,7 @@ static int keyword_type( const WCHAR *str, unsigned int len )
key.name = str;
key.len = len;
key.type = 0;
ret = bsearch( &key, keyword_table, SIZEOF(keyword_table), sizeof(struct keyword), cmp_keyword );
ret = bsearch( &key, keyword_table, ARRAY_SIZE(keyword_table), sizeof(struct keyword), cmp_keyword );
if (ret) return ret->type;
return TK_ID;
}