Introduced `ARRAY_SIZE' macro to replace all the sizeof(a)/sizeof(*a) constructs.

This commit is contained in:
Martin Mares 2000-04-12 13:21:23 +00:00
parent dcab789047
commit 7750634946
3 changed files with 3 additions and 3 deletions

View file

@ -41,7 +41,7 @@ cmd_build_tree(void)
cmd_root.plastson = &cmd_root.son; cmd_root.plastson = &cmd_root.son;
for(i=0; i<sizeof(command_table) / sizeof(struct cmd_info); i++) for(i=0; i<ARRAY_SIZE(command_table); i++)
{ {
struct cmd_info *cmd = &command_table[i]; struct cmd_info *cmd = &command_table[i];
struct cmd_node *old, *new; struct cmd_node *old, *new;

View file

@ -19,6 +19,7 @@
#define MIN(a,b) (((a)<(b))?(a):(b)) #define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b))
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a)))
#ifndef NULL #ifndef NULL
#define NULL ((void *) 0) #define NULL ((void *) 0)

View file

@ -185,8 +185,7 @@ bgp_get_bucket(struct bgp_proto *p, ea_list *old, ea_list *tmp)
} }
/* Ensure that there are all mandatory attributes */ /* Ensure that there are all mandatory attributes */
/* FIXME: Introduce array size macro */ for(i=0; i<ARRAY_SIZE(bgp_mandatory_attrs); i++)
for(i=0; i<sizeof(bgp_mandatory_attrs)/sizeof(bgp_mandatory_attrs[0]); i++)
if (!(seen & (1 << bgp_mandatory_attrs[i]))) if (!(seen & (1 << bgp_mandatory_attrs[i])))
{ {
log(L_ERR "%s: Mandatory attribute %s missing", p->p.name, bgp_attr_table[bgp_mandatory_attrs[i]].name); log(L_ERR "%s: Mandatory attribute %s missing", p->p.name, bgp_attr_table[bgp_mandatory_attrs[i]].name);