diff mbox

mac80211: Do not use sizeof() on pointer type

Message ID 1440584534-27251-1-git-send-email-thierry.reding@gmail.com (mailing list archive)
State Accepted
Delegated to: Johannes Berg
Headers show

Commit Message

Thierry Reding Aug. 26, 2015, 10:22 a.m. UTC
From: Thierry Reding <treding@nvidia.com>

The rate_control_cap_mask() function takes a parameter mcs_mask, which
GCC will take to be u8 * even though it was declared with a fixed size.
This causes the following warning:

	net/mac80211/rate.c: In function 'rate_control_cap_mask':
	net/mac80211/rate.c:719:25: warning: 'sizeof' on array function parameter 'mcs_mask' will return size of 'u8 * {aka unsigned char *}' [-Wsizeof-array-argument]
	   for (i = 0; i < sizeof(mcs_mask); i++)
	                         ^
	net/mac80211/rate.c:684:10: note: declared here
	       u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN],
	          ^

This can be easily fixed by using the IEEE80211_HT_MCS_MASK_LEN directly
within the loop condition.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 net/mac80211/rate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Arend van Spriel Aug. 26, 2015, 8:23 p.m. UTC | #1
On 08/26/2015 12:22 PM, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> The rate_control_cap_mask() function takes a parameter mcs_mask, which
> GCC will take to be u8 * even though it was declared with a fixed size.
> This causes the following warning:
>
> 	net/mac80211/rate.c: In function 'rate_control_cap_mask':
> 	net/mac80211/rate.c:719:25: warning: 'sizeof' on array function parameter 'mcs_mask' will return size of 'u8 * {aka unsigned char *}' [-Wsizeof-array-argument]
> 	   for (i = 0; i < sizeof(mcs_mask); i++)
> 	                         ^
> 	net/mac80211/rate.c:684:10: note: declared here
> 	       u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN],
> 	          ^
>
> This can be easily fixed by using the IEEE80211_HT_MCS_MASK_LEN directly
> within the loop condition.

Or use ARRAY_SIZE(mcs_mask).

Regards,
Arend

> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>   net/mac80211/rate.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
> index 9857693b91ec..9ce8883d5f44 100644
> --- a/net/mac80211/rate.c
> +++ b/net/mac80211/rate.c
> @@ -716,7 +716,7 @@ static bool rate_control_cap_mask(struct ieee80211_sub_if_data *sdata,
>
>   		/* Filter out rates that the STA does not support */
>   		*mask &= sta->supp_rates[sband->band];
> -		for (i = 0; i < sizeof(mcs_mask); i++)
> +		for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++)
>   			mcs_mask[i] &= sta->ht_cap.mcs.rx_mask[i];
>
>   		sta_vht_cap = sta->vht_cap.vht_mcs.rx_mcs_map;
>

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arend van Spriel Aug. 26, 2015, 8:40 p.m. UTC | #2
On 08/26/2015 10:23 PM, Arend van Spriel wrote:
> On 08/26/2015 12:22 PM, Thierry Reding wrote:
>> From: Thierry Reding <treding@nvidia.com>
>>
>> The rate_control_cap_mask() function takes a parameter mcs_mask, which
>> GCC will take to be u8 * even though it was declared with a fixed size.
>> This causes the following warning:
>>
>>     net/mac80211/rate.c: In function 'rate_control_cap_mask':
>>     net/mac80211/rate.c:719:25: warning: 'sizeof' on array function
>> parameter 'mcs_mask' will return size of 'u8 * {aka unsigned char *}'
>> [-Wsizeof-array-argument]
>>        for (i = 0; i < sizeof(mcs_mask); i++)
>>                              ^
>>     net/mac80211/rate.c:684:10: note: declared here
>>            u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN],
>>               ^
>>
>> This can be easily fixed by using the IEEE80211_HT_MCS_MASK_LEN directly
>> within the loop condition.
>
> Or use ARRAY_SIZE(mcs_mask).

Better not. Missed the 'function parameter' bit. Sorry for the noise.

Regards,
Arend

> Regards,
> Arend
>
>> Signed-off-by: Thierry Reding <treding@nvidia.com>
>> ---
>>   net/mac80211/rate.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
>> index 9857693b91ec..9ce8883d5f44 100644
>> --- a/net/mac80211/rate.c
>> +++ b/net/mac80211/rate.c
>> @@ -716,7 +716,7 @@ static bool rate_control_cap_mask(struct
>> ieee80211_sub_if_data *sdata,
>>
>>           /* Filter out rates that the STA does not support */
>>           *mask &= sta->supp_rates[sband->band];
>> -        for (i = 0; i < sizeof(mcs_mask); i++)
>> +        for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++)
>>               mcs_mask[i] &= sta->ht_cap.mcs.rx_mask[i];
>>
>>           sta_vht_cap = sta->vht_cap.vht_mcs.rx_mcs_map;
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Johannes Berg Sept. 4, 2015, 12:24 p.m. UTC | #3
On Wed, 2015-08-26 at 12:22 +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> The rate_control_cap_mask() function takes a parameter mcs_mask, 
> which
> GCC will take to be u8 * even though it was declared with a fixed 
> size.
> This causes the following warning:
> 
> 	net/mac80211/rate.c: In function 'rate_control_cap_mask':
> 	net/mac80211/rate.c:719:25: warning: 'sizeof' on array 
> function parameter 'mcs_mask' will return size of 'u8 * {aka unsigned 
> char *}' [-Wsizeof-array-argument]
> 	   for (i = 0; i < sizeof(mcs_mask); i++)
> 	                         ^
> 	net/mac80211/rate.c:684:10: note: declared here
> 	       u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN],
> 	          ^
> 
> This can be easily fixed by using the IEEE80211_HT_MCS_MASK_LEN 
> directly
> within the loop condition.

Dunno if you (Thierry) saw all the discussion about this - but anyway,
applied, thanks.

johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 9857693b91ec..9ce8883d5f44 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -716,7 +716,7 @@  static bool rate_control_cap_mask(struct ieee80211_sub_if_data *sdata,
 
 		/* Filter out rates that the STA does not support */
 		*mask &= sta->supp_rates[sband->band];
-		for (i = 0; i < sizeof(mcs_mask); i++)
+		for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++)
 			mcs_mask[i] &= sta->ht_cap.mcs.rx_mask[i];
 
 		sta_vht_cap = sta->vht_cap.vht_mcs.rx_mcs_map;