* [PATCH] staging: rtl8723au: change typecast to match type returned by htons()
@ 2014-11-10 20:07 Chris Ruffin
2014-11-10 20:21 ` Jes Sorensen
0 siblings, 1 reply; 4+ messages in thread
From: Chris Ruffin @ 2014-11-10 20:07 UTC (permalink / raw)
To: linux-wireless, linux-kernel, devel, Jes Sorensen, Larry Finger,
Greg Kroah-Hartman
Cc: Chris Ruffin
Using a u16 pointer typecast for a result from htons() results in the following warning from sparse:
drivers/staging/rtl8723au/core/rtw_xmit.c:1279:36: warning: incorrect type in assignment (different base types)
drivers/staging/rtl8723au/core/rtw_xmit.c:1279:36: expected unsigned short [unsigned] [short] [usertype] <noident>
drivers/staging/rtl8723au/core/rtw_xmit.c:1279:36: got restricted __be16 [usertype] <noident>
This patch fixes the issue by using an endian-specific typecast
that will always match the type returned by htons().
Signed-off-by: Chris Ruffin <cmruffin@gmail.com>
---
drivers/staging/rtl8723au/core/rtw_xmit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
index a0f7e27..44ef55c 100644
--- a/drivers/staging/rtl8723au/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
@@ -1276,7 +1276,7 @@ s32 rtw_put_snap23a(u8 *data, u16 h_proto)
snap->oui[0] = oui[0];
snap->oui[1] = oui[1];
snap->oui[2] = oui[2];
- *(u16 *)(data + SNAP_SIZE) = htons(h_proto);
+ *(__be16 *)(data + SNAP_SIZE) = htons(h_proto);
return SNAP_SIZE + sizeof(u16);
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] staging: rtl8723au: change typecast to match type returned by htons()
2014-11-10 20:07 [PATCH] staging: rtl8723au: change typecast to match type returned by htons() Chris Ruffin
@ 2014-11-10 20:21 ` Jes Sorensen
2014-11-10 20:28 ` Arend van Spriel
0 siblings, 1 reply; 4+ messages in thread
From: Jes Sorensen @ 2014-11-10 20:21 UTC (permalink / raw)
To: Chris Ruffin
Cc: linux-wireless, linux-kernel, devel, Larry Finger,
Greg Kroah-Hartman
Chris Ruffin <cmruffin@gmail.com> writes:
> Using a u16 pointer typecast for a result from htons() results in the following warning from sparse:
>
> drivers/staging/rtl8723au/core/rtw_xmit.c:1279:36: warning: incorrect type in assignment (different base types)
> drivers/staging/rtl8723au/core/rtw_xmit.c:1279:36: expected unsigned short [unsigned] [short] [usertype] <noident>
> drivers/staging/rtl8723au/core/rtw_xmit.c:1279:36: got restricted __be16 [usertype] <noident>
>
> This patch fixes the issue by using an endian-specific typecast
> that will always match the type returned by htons().
>
> Signed-off-by: Chris Ruffin <cmruffin@gmail.com>
> ---
> drivers/staging/rtl8723au/core/rtw_xmit.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Looks fine to me
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
>
> diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
> index a0f7e27..44ef55c 100644
> --- a/drivers/staging/rtl8723au/core/rtw_xmit.c
> +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
> @@ -1276,7 +1276,7 @@ s32 rtw_put_snap23a(u8 *data, u16 h_proto)
> snap->oui[0] = oui[0];
> snap->oui[1] = oui[1];
> snap->oui[2] = oui[2];
> - *(u16 *)(data + SNAP_SIZE) = htons(h_proto);
> + *(__be16 *)(data + SNAP_SIZE) = htons(h_proto);
> return SNAP_SIZE + sizeof(u16);
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] staging: rtl8723au: change typecast to match type returned by htons()
2014-11-10 20:21 ` Jes Sorensen
@ 2014-11-10 20:28 ` Arend van Spriel
2014-11-10 21:09 ` Jes Sorensen
0 siblings, 1 reply; 4+ messages in thread
From: Arend van Spriel @ 2014-11-10 20:28 UTC (permalink / raw)
To: Jes Sorensen, Chris Ruffin
Cc: linux-wireless, linux-kernel, devel, Larry Finger,
Greg Kroah-Hartman
On 10-11-14 21:21, Jes Sorensen wrote:
> Chris Ruffin <cmruffin@gmail.com> writes:
>> Using a u16 pointer typecast for a result from htons() results in the following warning from sparse:
>>
>> drivers/staging/rtl8723au/core/rtw_xmit.c:1279:36: warning: incorrect type in assignment (different base types)
>> drivers/staging/rtl8723au/core/rtw_xmit.c:1279:36: expected unsigned short [unsigned] [short] [usertype] <noident>
>> drivers/staging/rtl8723au/core/rtw_xmit.c:1279:36: got restricted __be16 [usertype] <noident>
>>
>> This patch fixes the issue by using an endian-specific typecast
>> that will always match the type returned by htons().
>>
>> Signed-off-by: Chris Ruffin <cmruffin@gmail.com>
>> ---
>> drivers/staging/rtl8723au/core/rtw_xmit.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Looks fine to me
>
> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
>
>>
>> diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
>> index a0f7e27..44ef55c 100644
>> --- a/drivers/staging/rtl8723au/core/rtw_xmit.c
>> +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
>> @@ -1276,7 +1276,7 @@ s32 rtw_put_snap23a(u8 *data, u16 h_proto)
>> snap->oui[0] = oui[0];
>> snap->oui[1] = oui[1];
>> snap->oui[2] = oui[2];
>> - *(u16 *)(data + SNAP_SIZE) = htons(h_proto);
>> + *(__be16 *)(data + SNAP_SIZE) = htons(h_proto);
Could (data + SNAP_SIZE) be on a unaligned address?
Regards,
Arend
>> return SNAP_SIZE + sizeof(u16);
>> }
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] staging: rtl8723au: change typecast to match type returned by htons()
2014-11-10 20:28 ` Arend van Spriel
@ 2014-11-10 21:09 ` Jes Sorensen
0 siblings, 0 replies; 4+ messages in thread
From: Jes Sorensen @ 2014-11-10 21:09 UTC (permalink / raw)
To: Arend van Spriel
Cc: Chris Ruffin, linux-wireless, linux-kernel, devel, Larry Finger,
Greg Kroah-Hartman
Arend van Spriel <arend@broadcom.com> writes:
> On 10-11-14 21:21, Jes Sorensen wrote:
>> Chris Ruffin <cmruffin@gmail.com> writes:
>>> Using a u16 pointer typecast for a result from htons() results in
>>> the following warning from sparse:
>>>
>>> drivers/staging/rtl8723au/core/rtw_xmit.c:1279:36: warning:
>>> incorrect type in assignment (different base types)
>>> drivers/staging/rtl8723au/core/rtw_xmit.c:1279:36: expected
>>> unsigned short [unsigned] [short] [usertype] <noident>
>>> drivers/staging/rtl8723au/core/rtw_xmit.c:1279:36: got restricted
>>> __be16 [usertype] <noident>
>>>
>>> This patch fixes the issue by using an endian-specific typecast
>>> that will always match the type returned by htons().
>>>
>>> Signed-off-by: Chris Ruffin <cmruffin@gmail.com>
>>> ---
>>> drivers/staging/rtl8723au/core/rtw_xmit.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> Looks fine to me
>>
>> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
>>
>>>
>>> diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c
>>> b/drivers/staging/rtl8723au/core/rtw_xmit.c
>>> index a0f7e27..44ef55c 100644
>>> --- a/drivers/staging/rtl8723au/core/rtw_xmit.c
>>> +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
>>> @@ -1276,7 +1276,7 @@ s32 rtw_put_snap23a(u8 *data, u16 h_proto)
>>> snap->oui[0] = oui[0];
>>> snap->oui[1] = oui[1];
>>> snap->oui[2] = oui[2];
>>> - *(u16 *)(data + SNAP_SIZE) = htons(h_proto);
>>> + *(__be16 *)(data + SNAP_SIZE) = htons(h_proto);
>
> Could (data + SNAP_SIZE) be on a unaligned address?
It shouldn't but probably better to take it into account. I am moving
things around in this code right now, so I'll just fix it in a follow-on
patch to this one.
Cheers,
Jes
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-10 21:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-10 20:07 [PATCH] staging: rtl8723au: change typecast to match type returned by htons() Chris Ruffin
2014-11-10 20:21 ` Jes Sorensen
2014-11-10 20:28 ` Arend van Spriel
2014-11-10 21:09 ` Jes Sorensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).