linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] staging: rtl8192e: Change cpu_to_le16 to le16_to_cpu
@ 2015-05-09 20:27 Arno Tiemersma
  2015-05-09 22:13 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Arno Tiemersma @ 2015-05-09 20:27 UTC (permalink / raw)
  To: gregkh, mateusz.kulikowski, behanw, mdcasey, devel, linux-kernel
  Cc: Arno Tiemersma

Since the function auth_parse returns a u16, and
struct rtllib_authentication.status is defined as an __le16, it seems
that

	return cpu_to_le16(a->status);

should be

	return le16_to_cpu(a->status);

This change silences the following sparse warnings:
drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
 warning: cast from restricted __le16
drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
 warning: incorrect type in return expression (different base types)
drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
    expected unsigned short
drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
    got restricted __le16 [usertype] <noident>

Signed-off-by: Arno Tiemersma <arno.tiemersma@gmail.com>
---
v2 since I did not have the right e-mail address for Mateusz Kulikowski

 drivers/staging/rtl8192e/rtllib_softmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
index 8f5e88b..98afd3b 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -1814,7 +1814,7 @@ static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen)
 				return -ENOMEM;
 		}
 	}
-	return cpu_to_le16(a->status);
+	return le16_to_cpu(a->status);
 }
 
 static int auth_rq_parse(struct sk_buff *skb, u8 *dest)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] staging: rtl8192e: Change cpu_to_le16 to le16_to_cpu
  2015-05-09 20:27 [PATCH v2] staging: rtl8192e: Change cpu_to_le16 to le16_to_cpu Arno Tiemersma
@ 2015-05-09 22:13 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2015-05-09 22:13 UTC (permalink / raw)
  To: Arno Tiemersma
  Cc: gregkh, mateusz.kulikowski, behanw, mdcasey, devel, linux-kernel

On Sat, May 09, 2015 at 10:27:16PM +0200, Arno Tiemersma wrote:
> Since the function auth_parse returns a u16, and
> struct rtllib_authentication.status is defined as an __le16, it seems
> that
> 
> 	return cpu_to_le16(a->status);
> 
> should be
> 
> 	return le16_to_cpu(a->status);
> 
> This change silences the following sparse warnings:
> drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
>  warning: cast from restricted __le16
> drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
>  warning: incorrect type in return expression (different base types)
> drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
>     expected unsigned short
> drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
>     got restricted __le16 [usertype] <noident>
> 
> Signed-off-by: Arno Tiemersma <arno.tiemersma@gmail.com>

Your patch seems reasonable.  The caller only cares about zero non-zero.

It feels like there are a bunch of endian bugs which Sparse misses in
this file.  For example, ->frame_ctl is endian but it's never converted
and it's compared against cpu endian in the switch statements.  (I
haven't double checked.  Do your own homework before sending patches).

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-09 22:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-09 20:27 [PATCH v2] staging: rtl8192e: Change cpu_to_le16 to le16_to_cpu Arno Tiemersma
2015-05-09 22:13 ` Dan Carpenter

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).