]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Introduced `ARRAY_SIZE' macro to replace all the sizeof(a)/sizeof(*a) constructs.
authorMartin Mares <mj@ucw.cz>
Wed, 12 Apr 2000 13:21:23 +0000 (13:21 +0000)
committerMartin Mares <mj@ucw.cz>
Wed, 12 Apr 2000 13:21:23 +0000 (13:21 +0000)
client/commands.c
lib/birdlib.h
proto/bgp/attrs.c

index aa00be08d926a0945b8269920e673d3d6fe90e7d..5c60df8c8c4a4bd8d6fcc062f18a467d91d8b837 100644 (file)
@@ -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;
index 6f053302ee397061551f37747eec7611ff0dff10..933e3d50adb33b8b3c5fb0e5325f6b7be6ff3e90 100644 (file)
@@ -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)
index 5c1e70db6e08afb02ab027b973ca18e053d613b4..350123a4fd70b927e327e4433eee476e1cedc723 100644 (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 */
-  /* 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);