Subject: kern/6271: ANSI compliance in if_arp.h header
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dave@dtsp.co.nz>
List: netbsd-bugs
Date: 10/11/1998 03:55:28
>Number:         6271
>Category:       kern
>Synopsis:       ANSI compliance in if_arp.h header
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 10 21:50:01 1998
>Last-Modified:
>Originator:     Dave Sainty
>Organization:
Dynamic Technology Services and Products Ltd (NZ)
>Release:        11/10/98 sup
>Environment:
>Description:
	/usr/include/net/if_arp.h has a zero length array in one of its
	structures.  This violates ANSI C, which is "ok", but it's
	inappropriate to have the compiler warn about this if compiling with
	ANSI violation warnings on.

>How-To-Repeat:
	In my case, #include <net/if.h>
>Fix:
This could be reimplemented as something like (->ar_hrd to typecheck the
parameter):

#define ar_sha(ap) (((u_int8_t*)(&(ap)->ar_hrd)+sizeof(struct arphdr))+0)

But this is uglier than the non-ANSI version.  So my fix is to tell the
compiler it's ok...


--- ../NetBSD-sup/src/sys/net/if_arp.h  Wed Feb 11 01:27:24 1998
+++ src/sys/net/if_arp.h        Sun Oct 11 16:31:26 1998
@@ -73,6 +73,7 @@
        u_int8_t  ar_tha[];     /* target hardware address */
        u_int8_t  ar_tpa[];     /* target protocol address */
 #endif
+       __extension__ /* ANSI C forbids zero-size array */
        u_int8_t  ar_remain[0]; /* minimum size, normally bigger */
 #define ar_sha(ap) (((ap)->ar_remain)+0)
 #define ar_spa(ap) (((ap)->ar_remain)+(ap)->ar_hln)
>Audit-Trail:
>Unformatted:
System: NetBSD tequila.dave.dtsp.co.nz 1.3G NetBSD 1.3G (TEQUILA) #1: Thu Aug 20 00:13:30 NZST 1998 dave@tequila.dave.dtsp.co.nz:/vol/tequila/userC/NetBSD-current/src/sys/arch/i386/compile/TEQUILA i386