summaryrefslogtreecommitdiffstats
path: root/drivers/staging/rtl8188eu/core/rtw_ap.c
diff options
context:
space:
mode:
authorVaishali Thakkar2015-02-20 09:48:37 +0100
committerGreg Kroah-Hartman2015-02-26 21:34:17 +0100
commite4504a1519544f40675fccbe0d93e993cbb04f06 (patch)
treef1d25032adf52eee04cd6d2956b9b5811bfdcb5b /drivers/staging/rtl8188eu/core/rtw_ap.c
parentStaging: rtl8188eu: Remove unused struct ndis_802_11_key (diff)
downloadkernel-qcow2-linux-e4504a1519544f40675fccbe0d93e993cbb04f06.tar.gz
kernel-qcow2-linux-e4504a1519544f40675fccbe0d93e993cbb04f06.tar.xz
kernel-qcow2-linux-e4504a1519544f40675fccbe0d93e993cbb04f06.zip
Staging: rtl8188eu: Use put_unaligned_le16
Using byte ordering functions and then memcpy() is risky and prone to hide errors which are hard to track down. So, this patch introduces the use of function put_unaligned_le16 which makes the code clear. Here, use of variable tim_bitmap_le and variable itself is removed. Also, to be compatible with the changes header file is added too. Coccinelle is used to do this change and semantic patch used for this is as follows: @a@ typedef __le16; __le16 e16; identifier tmp; expression ptr; expression y,e; type T; @@ - tmp = cpu_to_le16(y); <+... when != tmp ( - memcpy(ptr, (T)&tmp, \(2\|sizeof(__le16)\|sizeof(e16)\)); + put_unaligned_le16(y,ptr); | - memcpy(ptr, (T)&tmp, ...); + put_unaligned_le16(y,ptr); ) ...+> ? tmp = e @@ type T; identifier a.tmp; @@ - T tmp; ...when != tmp Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Preeti U Murthy <preeti@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/rtl8188eu/core/rtw_ap.c')
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_ap.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c
index da19145c49c5..e65ee6e858a8 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -23,6 +23,7 @@
#include <drv_types.h>
#include <wifi.h>
#include <ieee80211.h>
+#include <asm/unaligned.h>
#ifdef CONFIG_88EU_AP_MODE
@@ -78,11 +79,8 @@ static void update_BCNTIM(struct adapter *padapter)
if (true) {
u8 *p, *dst_ie, *premainder_ie = NULL;
u8 *pbackup_remainder_ie = NULL;
- __le16 tim_bitmap_le;
uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen;
- tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap);
-
p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_);
if (p != NULL && tim_ielen > 0) {
tim_ielen += 2;
@@ -137,9 +135,9 @@ static void update_BCNTIM(struct adapter *padapter)
*dst_ie++ = 0;
if (tim_ielen == 4) {
- *dst_ie++ = *(u8 *)&tim_bitmap_le;
+ *dst_ie++ = pstapriv->tim_bitmap & 0xff;
} else if (tim_ielen == 5) {
- memcpy(dst_ie, &tim_bitmap_le, 2);
+ put_unaligned_le16(pstapriv->tim_bitmap, dst_ie);
dst_ie += 2;
}