Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1231911

[PATCH V2] staging: rtl8723au: Remove unneeded endianness conversions

From Lars Svensson <lars1.svensson@sonymobile.com>
Newsgroups linux.kernel
Subject [PATCH V2] staging: rtl8723au: Remove unneeded endianness conversions
Date 2015-09-24 09:20 +0200
Message-ID <qc8YV-4tW-19@gated-at.bofh.it> (permalink)
References <qbPtg-1lx-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Fixing Sparse warnings in rtw_security.c. When checking crc, both
actual and expected value was converted to cpu endianness before
comparing, causing sparse warnings as below. Since the values are
read from the buffer in correct byte order the extra conversions
should not be needed.

Thanks to Larry Finger for help sorting this out.

  CHECK   drivers/staging/rtl8723au/core/rtw_security.c
drivers/staging/rtl8723au/core/rtw_security.c:248:22: \
warning: cast to restricted __le32
drivers/staging/rtl8723au/core/rtw_security.c:249:24: \
warning: cast to restricted __le32
drivers/staging/rtl8723au/core/rtw_security.c:776:22: \
warning: cast to restricted __le32
drivers/staging/rtl8723au/core/rtw_security.c:777:24: \
warning: cast to restricted __le32

Signed-off-by: Lars Svensson <Lars1.Svensson@sonymobile.com>
---
Patch V2: Reworked as adviced.
---
 drivers/staging/rtl8723au/core/rtw_security.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_security.c b/drivers/staging/rtl8723au/core/rtw_security.c
index 3d40bab..a44c606 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -245,8 +245,8 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter,
 	arcfour_encrypt(&mycontext, payload, payload, length);
 
 	/* calculate icv and compare the icv */
-	actual_crc = le32_to_cpu(getcrc32(payload, length - 4));
-	expected_crc = le32_to_cpu(get_unaligned_le32(&payload[length - 4]));
+	actual_crc = getcrc32(payload, length - 4);
+	expected_crc = get_unaligned_le32(&payload[length - 4]);
 
 	if (actual_crc != expected_crc) {
 		RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
@@ -772,9 +772,8 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
 	/* 4 decrypt payload include icv */
 	arcfour_init(&mycontext, rc4key, 16);
 	arcfour_encrypt(&mycontext, payload, payload, length);
-
-	actual_crc = le32_to_cpu(getcrc32(payload, length - 4));
-	expected_crc = le32_to_cpu(get_unaligned_le32(&payload[length - 4]));
+	actual_crc = getcrc32(payload, length - 4);
+	expected_crc = get_unaligned_le32(&payload[length - 4]);
 
 	if (actual_crc != expected_crc) {
 		RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
-- 
2.4.2

--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] staging: rtl8723au: Mark type casts to __le32 as intentional Lars Svensson <lars1.svensson@sonymobile.com> - 2015-09-22 16:00 +0200
  Re: [PATCH] staging: rtl8723au: Mark type casts to __le32 as  intentional Larry Finger <Larry.Finger@lwfinger.net> - 2015-09-22 23:40 +0200
    Re: [PATCH] staging: rtl8723au: Mark type casts to __le32 as  intentional Lars Svensson <Lars1.Svensson@sonymobile.com> - 2015-09-23 12:30 +0200
      [PATCH V2] staging: rtl8723au: Remove unneeded endianness conversions Lars Svensson <lars1.svensson@sonymobile.com> - 2015-09-24 09:20 +0200
        Re: [PATCH V2] staging: rtl8723au: Remove unneeded endianness  conversions Larry Finger <Larry.Finger@lwfinger.net> - 2015-09-26 20:00 +0200

csiph-web