[quagga-dev 3649] Re: 0.98.4 bug report: files ospf_opaque.c, ospf_vty.c and ospf6_asbr.c

Andrew J. Schorr aschorr at telemetry-investments.com
Fri Sep 16 17:43:52 BST 2005


On Fri, Sep 16, 2005 at 03:10:53PM +0000, d binderman wrote:
> >I also do not understand why gcc does not issue a warning.
> 
> It probably will, if you turn up the warning level enough -Wall should do 
> it.

Actually, it doesn't:

sh-3.00$ gcc --version | head -1
gcc (GCC) 4.0.1 20050727 (Red Hat 4.0.1-5)
sh-3.00$ cat hello.c
#include <stdio.h>

int
main(int argc, char **argv)
{
  int *x = x;
  puts("Hello, world!");
  return 0;
}
sh-3.00$ gcc -Wall hello.c
sh-3.00$

And the same with gcc 3.3.2.  No warning at all.  I guess the compiler
just treats it as a no-op.

> I don't have the code easily available anymore, so I can't persuade you 
> further.
> 
> The macro seemed broken in the version I looked at. The Intel compiler 
> agreed with me. You might be looking at a later fixed version.

I guess this depends on which version of the code you were looking at.
There was a change on Jan 25, 2005 that may have fixed this problem...

Anyway, I have attached a more robust patch to avoid future problems
of that nature.

Regards,
Andy
-------------- next part --------------
Index: ospf6d/ospf6_asbr.c
===================================================================
RCS file: /var/cvsroot/quagga/ospf6d/ospf6_asbr.c,v
retrieving revision 1.18
diff -b -u -p -r1.18 ospf6_asbr.c
--- ospf6d/ospf6_asbr.c	10 Aug 2005 15:46:11 -0000	1.18
+++ ospf6d/ospf6_asbr.c	16 Sep 2005 16:42:50 -0000
@@ -50,19 +50,22 @@
 
 unsigned char conf_debug_ospf6_asbr = 0;
 
+/* Note: these descriptions must match the route types defined in lib/zebra.h */
 const char *zroute_name[] =
 { "system", "kernel", "connected", "static",
   "rip", "ripng", "ospf", "ospf6", "isis", "bgp", "hsls", "unknown" };
+#define NUM_ZROUTE_NAMES ((sizeof(zroute_name)/sizeof(zroute_name[0]))-1)
 
 const char *zroute_abname[] =
 { "X", "K", "C", "S", "R", "R", "O", "O", "I", "B", "H", "?" };
+#define NUM_ZROUTE_ABNAMES ((sizeof(zroute_abname)/sizeof(zroute_abname[0]))-1)
 
 #define ZROUTE_NAME(x)                                     \
-  (0 < (x) && (x) < ZEBRA_ROUTE_MAX ? zroute_name[(x)] :   \
-   zroute_name[ZEBRA_ROUTE_MAX])
+  (0 <= (x) && (x) < NUM_ZROUTE_NAMES ? zroute_name[(x)] :   \
+   zroute_name[NUM_ZROUTE_NAMES])
 #define ZROUTE_ABNAME(x)                                   \
-  (0 < (x) && (x) < ZEBRA_ROUTE_MAX ? zroute_abname[(x)] : \
-   zroute_abname[ZEBRA_ROUTE_MAX])
+  (0 <= (x) && (x) < NUM_ZROUTE_ABNAMES ? zroute_abname[(x)] : \
+   zroute_abname[NUM_ZROUTE_ABNAMES])
 
 /* AS External LSA origination */
 void


More information about the Quagga-dev mailing list