Skip to contentSkip to conversation

brcmsmac: fix u16 overflow warning

PATCH In review Tim Gardner 2 participants 2 messages Feb 7, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 brcmsmac: fix u16 overflow warning

DOT11_MIN_BEACON_PERIOD and DOT11_MAX_BEACON_PERIOD are superfluous. The only invalid beacon period is 0. Comparing a 16 bit quantity to 0xffff also causes a compile warning:

drivers/net/wireless/brcm80211/brcmsmac/main.c:5560 brcms_c_set_beacon_period()
warn: impossible condition '(period > 65535) => (0-65535 > 65535)'

Observed from smatch analysis.

Cc Brett Rudley <[email protected]>
Cc Arend van Spriel <[email protected]>
Cc "Franky (Zhenhui) Lin" <[email protected]>
Cc Hante Meuleman <[email protected]>
Cc "John W. Linville" <[email protected]>
Cc Pieter-Paul Giesberts <[email protected]>
Cc Seth Forshee <[email protected]>
Cc Hauke Mehrtens <[email protected]>
---
 drivers/net/wireless/brcm80211/brcmsmac/main.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/wireless/brcm80211/brcmsmac/main.c +1 -4
index c26992a..080b54d 100644
@@ -101,8 +101,6 @@
 #define DOT11_RTS_LEN			16
 #define DOT11_CTS_LEN			10
 #define DOT11_BA_BITMAP_LEN		128
-#define DOT11_MIN_BEACON_PERIOD		1
-#define DOT11_MAX_BEACON_PERIOD		0xFFFF
 #define DOT11_MAXNUMFRAGS		16
 #define DOT11_MAX_FRAG_LEN		2346
 
@@ -5555,8 +5553,7 @@ int brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcm_rateset *rs)
 
 int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period)
 {
-	if (period < DOT11_MIN_BEACON_PERIOD ||
-	    period > DOT11_MAX_BEACON_PERIOD)
+	if (period == 0)
 		return -EINVAL;
 
 	wlc->default_bss->beacon_period = period;
Signature · 1 line
1.7.9.5
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Tim Gardner

DOT11_MIN_BEACON_PERIOD and DOT11_MAX_BEACON_PERIOD are superfluous. The only invalid beacon period is 0. Comparing a 16 bit quantity to 0xffff also causes a compile warning:

drivers/net/wireless/brcm80211/brcmsmac/main.c:5560 brcms_c_set_beacon_period()
warn: impossible condition '(period > 65535) => (0-65535 > 65535)'

Observed from smatch analysis.

Quoted 10 lines
Cc Brett Rudley <[email protected]>
Cc "Franky (Zhenhui) Lin" <[email protected]>
Cc Hante Meuleman <[email protected]>
Cc "John W. Linville" <[email protected]>
Cc Pieter-Paul Giesberts <[email protected]>
Cc Seth Forshee <[email protected]>
Cc Hauke Mehrtens <[email protected]>
Quoted 29 lines
---
 drivers/net/wireless/brcm80211/brcmsmac/main.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/wireless/brcm80211/brcmsmac/main.c +1 -4
index c26992a..080b54d 100644
@@ -101,8 +101,6 @@
 #define DOT11_RTS_LEN			16
 #define DOT11_CTS_LEN			10
 #define DOT11_BA_BITMAP_LEN		128
-#define DOT11_MIN_BEACON_PERIOD		1
-#define DOT11_MAX_BEACON_PERIOD		0xFFFF
 #define DOT11_MAXNUMFRAGS		16
 #define DOT11_MAX_FRAG_LEN		2346
 
@@ -5555,8 +5553,7 @@ int brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcm_rateset *rs)
 
 int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period)
 {
-	if (period < DOT11_MIN_BEACON_PERIOD ||
-	    period > DOT11_MAX_BEACON_PERIOD)
+	if (period == 0)
 		return -EINVAL;
 
 	wlc->default_bss->beacon_period = period;