Subject: port-sparc64/19975: sparc64/include/bus.h macro decl shadows variable
To: None <>
From: None <>
List: netbsd-bugs
Date: 01/21/2003 15:23:53
>Number:         19975
>Category:       port-sparc64
>Synopsis:       sparc64/include/bus.h macro decl shadows variable
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-sparc64-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 20 22:25:00 PST 2003
>Originator:     Jun-ichiro itojun Hagino
>Release:        NetBSD 1.6M
System: NetBSD 1.6M NetBSD 1.6M (STARFRUIT) #44: Tue Jan 21 12:17:11 JST 2003 i386
Architecture: i386
Machine: i386
	in sys/arch/sparc64/include/bus.h, the following macro definition is

#define bus_space_read_multi_1(t, h, o, a, c) do {			\
	int i = c;							\
	u_int8_t *p = (u_int8_t *)a;					\
	while (i-- > 0)							\
		*p++ = bus_space_read_1(t, h, o);			\
} while (0)
	the definition is troublesome as it shadows variable "i".  consider
	the following usage.
		for (i = 0; i < 10; i++)
			bus_space_read_multi_1(x, y, z, u, i);

	code inspection.  it was mentioned by openbsd developers.
	make it an inline function, or avoid the use of temporary variable.