staging: rtl8723au: change typecast to match type returned by htons()
PATCH 1/1 staging: rtl8723au: change typecast to match type returned by htons()
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().
--- drivers/staging/rtl8723au/core/rtw_xmit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723au/core/rtw_xmit.c +1 -1
@@ -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); }
Signature · 1 line
1.7.10.4
Quoted 6 lines · 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>
Quoted 7 lines
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 <[email protected]>--- drivers/staging/rtl8723au/core/rtw_xmit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Looks fine to me
Quoted 13 lines
drivers/staging/rtl8723au/core/rtw_xmit.c +1
-1@@ -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); }
Quoted 20 lines · Jes Sorensen
Quoted 6 lines · 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>Quoted 7 lines
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 <[email protected]>--- drivers/staging/rtl8723au/core/rtw_xmit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Looks fine to me
Signed-off-by Jes Sorensen <[email protected]>Quoted 1 line
Quoted 10 lines
drivers/staging/rtl8723au/core/rtw_xmit.c s32 rtw_put_snap23a(u8 *data, u16 h_proto) · line 1279
Quoted 10 lines
drivers/staging/rtl8723au/core/rtw_xmit.c +1
-1@@ -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
Quoted 8 lines
drivers/staging/rtl8723au/core/rtw_xmit.c s32 rtw_put_snap23a(u8 *data, u16 h_proto) · line 1281
Quoted 2 lines
drivers/staging/rtl8723au/core/rtw_xmit.c +0
-0return SNAP_SIZE +sizeof (u16); }--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 25 lines · Arend van Spriel
Quoted 24 lines · Jes Sorensen
Quoted 10 lines · 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>Quoted 7 lines
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 <[email protected]>--- drivers/staging/rtl8723au/core/rtw_xmit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Looks fine to me
Signed-off-by Jes Sorensen <[email protected]>Quoted 1 line
Quoted 13 lines
Quoted 11 lines
drivers/staging/rtl8723au/core/rtw_xmit.c s32 rtw_put_snap23a(u8 *data, u16 h_proto) · line 1279
Quoted 11 lines
drivers/staging/rtl8723au/core/rtw_xmit.c +1
-1@@ -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