Re: [patch 3/3] d80211: silence sparse warning: bad constant expression
On Wed, 18 Oct 2006 08:12:27 -0700, David Kimdon wrote: > I actually think the code reads slightly cleaner using num_algs, but > don't have a strong preference. I'd be happy to make the change if > removing num_algs is preferred. Don't know. But nobody except me objected for more than a week so I've applied the patch to my tree. I've also applied the following patches from you: d80211: use FCS_LEN instead of hardcoded number. d80211: remove unused Super AG definitions, purge comment (the second version of the patch) Thanks for the patches, Jiri -- Jiri Benc SUSE Labs - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 3/3] d80211: silence sparse warning: bad constant expression
On Wed, Oct 18, 2006 at 03:56:07PM +0200, Jiri Benc wrote: > On Mon, 9 Oct 2006 13:11:02 -0700, David Kimdon wrote: > > --- wireless-dev.orig/net/d80211/ieee80211_sta.c > > +++ wireless-dev/net/d80211/ieee80211_sta.c > > @@ -930,8 +930,8 @@ static void ieee80211_rx_mgmt_auth(struc > > printk(KERN_DEBUG "%s: AP denied authentication (auth_alg=%d " > >"code=%d)\n", dev->name, ifsta->auth_alg, status_code); > > if (status_code == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) { > > - const int num_algs = 3; > > - u8 algs[num_algs]; > > + u8 algs[3]; > > + const int num_algs = ARRAY_SIZE(algs); > > Wouldn't it be better just to use ARRAY_SIZE(algs) and get rid of > num_algs completely? I actually think the code reads slightly cleaner using num_algs, but don't have a strong preference. I'd be happy to make the change if removing num_algs is preferred. -David - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 3/3] d80211: silence sparse warning: bad constant expression
On Mon, 9 Oct 2006 13:11:02 -0700, David Kimdon wrote: > --- wireless-dev.orig/net/d80211/ieee80211_sta.c > +++ wireless-dev/net/d80211/ieee80211_sta.c > @@ -930,8 +930,8 @@ static void ieee80211_rx_mgmt_auth(struc > printk(KERN_DEBUG "%s: AP denied authentication (auth_alg=%d " > "code=%d)\n", dev->name, ifsta->auth_alg, status_code); > if (status_code == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) { > - const int num_algs = 3; > - u8 algs[num_algs]; > + u8 algs[3]; > + const int num_algs = ARRAY_SIZE(algs); Wouldn't it be better just to use ARRAY_SIZE(algs) and get rid of num_algs completely? Thanks, Jiri -- Jiri Benc SUSE Labs - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 3/3] d80211: silence sparse warning: bad constant expression
Update to use ARRAY_SIZE, based on comment from Joe Perches. d80211: silence sparse warning: 'bad constant expression' Sparse does not figure out that algs[] isn't really a variable length array. The message is: net/d80211/ieee80211_sta.c:934:12: error: bad constant expression This switches algs[] to be obviously a constant array, and derives the value of num_algs algs[]. The code is correct and equivalent with or without this change. Signed-off-by: David Kimdon <[EMAIL PROTECTED]> Index: wireless-dev/net/d80211/ieee80211_sta.c === --- wireless-dev.orig/net/d80211/ieee80211_sta.c +++ wireless-dev/net/d80211/ieee80211_sta.c @@ -930,8 +930,8 @@ static void ieee80211_rx_mgmt_auth(struc printk(KERN_DEBUG "%s: AP denied authentication (auth_alg=%d " "code=%d)\n", dev->name, ifsta->auth_alg, status_code); if (status_code == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) { - const int num_algs = 3; - u8 algs[num_algs]; + u8 algs[3]; + const int num_algs = ARRAY_SIZE(algs); int i, pos; algs[0] = algs[1] = algs[2] = 0xff; if (ifsta->auth_algs & IEEE80211_AUTH_ALG_OPEN) - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 3/3] d80211: silence sparse warning: bad constant expression
Sparse does not figure out that algs[] isn't really a variable length array. The message is: net/d80211/ieee80211_sta.c:934:12: error: bad constant expression This switches algs[] to be obviously a constant array, and derives the value of num_algs algs[]. The code is correct and equivalent with or without this change. Signed-off-by: David Kimdon <[EMAIL PROTECTED]> Index: wireless-dev/net/d80211/ieee80211_sta.c === --- wireless-dev.orig/net/d80211/ieee80211_sta.c +++ wireless-dev/net/d80211/ieee80211_sta.c @@ -930,8 +930,8 @@ static void ieee80211_rx_mgmt_auth(struc printk(KERN_DEBUG "%s: AP denied authentication (auth_alg=%d " "code=%d)\n", dev->name, ifsta->auth_alg, status_code); if (status_code == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) { - const int num_algs = 3; - u8 algs[num_algs]; + u8 algs[3]; + const int num_algs = sizeof(algs) / sizeof(algs[0]); int i, pos; algs[0] = algs[1] = algs[2] = 0xff; if (ifsta->auth_algs & IEEE80211_AUTH_ALG_OPEN) -- - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html