NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/51708: if_alcreg.h - CSR_ macro defs' _sc is unused



>Number:         51708
>Category:       kern
>Synopsis:       CSR_ macros depend on locally undefined argument sc, instead of on the provided _sc
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 11 17:55:00 +0000 2016
>Originator:     Amol
>Release:        NetBSD 7.0.2
>Organization:
	
>Environment:
	
	
System: NetBSD nbsd.dd.com 7.0.2 NetBSD 7.0.2 (DDKRNL) #4: Sun Dec 11 08:29:47 UTC 2016 user0%nbsd.dd.com@localhost:/home/user0/src/sys/arch/amd64/compile/DDKRNL amd64
Architecture: x86_64
Machine: amd64
>Description:
	
The CSR_ macros are defined as below inside dev/pci/if_alcreg.h:
/* Register access macros. */
#define	CSR_WRITE_4(_sc, reg, val)	\2yy
	bus_space_write_4((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg), (val))

The macros provide '_sc' as the softc parameter, however the macro expansion to bus_space_*_* use 'sc'.
It is likely that the callers of these CSR_ macros already have 'sc' variables within their scope, which
prevent compilation errors and more importantly, allow the driver to work.

>How-To-Repeat:
	
>Fix:
	

diff --git a/if_alcreg.h b/if_alcreg.h
index d131306..19f2acb 100644
--- a/if_alcreg.h
+++ b/if_alcreg.h
@@ -1488,15 +1488,15 @@ struct alc_softc {
 
 /* Register access macros. */
 #define        CSR_WRITE_4(_sc, reg, val)      \
-       bus_space_write_4((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg), (val))
+       bus_space_write_4((_sc)->sc_mem_bt, (_sc)->sc_mem_bh, (reg), (val))
 #define        CSR_WRITE_2(_sc, reg, val)      \
-       bus_space_write_2((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg), (val))
+       bus_space_write_2((_sc)->sc_mem_bt, (_sc)->sc_mem_bh, (reg), (val))
 #define        CSR_WRITE_1(_sc, reg, val)      \
-       bus_space_write_1((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg), (val))
+       bus_space_write_1((_sc)->sc_mem_bt, (_sc)->sc_mem_bh, (reg), (val))
 #define        CSR_READ_2(_sc, reg)            \
-       bus_space_read_2((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg))
+       bus_space_read_2((_sc)->sc_mem_bt, (_sc)->sc_mem_bh, (reg))
 #define        CSR_READ_4(_sc, reg)            \
-       bus_space_read_4((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg))
+       bus_space_read_4((_sc)->sc_mem_bt, (_sc)->sc_mem_bh, (reg))
 
 #define        ALC_RXCHAIN_RESET(_sc)                                          \
 do {                                                                   \

>Unformatted:
 	
 	201612111020Z



Home | Main Index | Thread Index | Old Index