Subject: port-sparc64/19975: sparc64/include/bus.h macro decl shadows variable
To: None <gnats-bugs@gnats.netbsd.org>
From: None <itojun@itojun.org>
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
>Closed-Date:
>Last-Modified:
>Originator: Jun-ichiro itojun Hagino
>Release: NetBSD 1.6M
>Organization:
itojun.org
>Environment:
System: NetBSD starfruit.itojun.org 1.6M NetBSD 1.6M (STARFRUIT) #44: Tue Jan 21 12:17:11 JST 2003 itojun@starfruit.itojun.org:/home/itojun/NetBSD/src/sys/arch/i386/compile/STARFRUIT i386
Architecture: i386
Machine: i386
>Description:
in sys/arch/sparc64/include/bus.h, the following macro definition is
used:
#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);
>How-To-Repeat:
code inspection. it was mentioned by openbsd developers.
>Fix:
make it an inline function, or avoid the use of temporary variable.
>Release-Note:
>Audit-Trail:
>Unformatted: