summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/commands.c2
-rw-r--r--lib/birdlib.h1
-rw-r--r--proto/bgp/attrs.c3
3 files changed, 3 insertions, 3 deletions
diff --git a/client/commands.c b/client/commands.c
index aa00be0..5c60df8 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -41,7 +41,7 @@ cmd_build_tree(void)
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_node *old, *new;
diff --git a/lib/birdlib.h b/lib/birdlib.h
index 6f05330..933e3d5 100644
--- a/lib/birdlib.h
+++ b/lib/birdlib.h
@@ -19,6 +19,7 @@
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a)))
#ifndef NULL
#define NULL ((void *) 0)
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c
index 5c1e70d..350123a 100644
--- a/proto/bgp/attrs.c
+++ b/proto/bgp/attrs.c
@@ -185,8 +185,7 @@ bgp_get_bucket(struct bgp_proto *p, ea_list *old, ea_list *tmp)
}
/* Ensure that there are all mandatory attributes */
- /* FIXME: Introduce array size macro */
- for(i=0; i<sizeof(bgp_mandatory_attrs)/sizeof(bgp_mandatory_attrs[0]); i++)
+ for(i=0; i<ARRAY_SIZE(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);