[PATCH 08/12] staging: ks7010: replace magic number 8

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Function uses magic number 8. Number refers to the micael mic
length. It would be better to define and use a global constant. Other
driver code in the kernel uses the name MICHAEL_MIC_LEN for the same
task.

Define global constant MICHAEL_MIC_LEN to be 8. Replace magic number 8
with newly defined constant.

Signed-off-by: Tobin C. Harding <me@xxxxxxxx>
---
 drivers/staging/ks7010/ks_hostif.c   | 12 ++++++------
 drivers/staging/ks7010/michael_mic.h |  2 ++
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 6fc8360..0455cda 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1154,7 +1154,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 	}
 
 	DPRINTK(4, "skb_buff length=%d\n", skb_len);
-	pp = kmalloc(hif_align_size(sizeof(*pp) + 6 + skb_len + 8),
+	pp = kmalloc(hif_align_size(sizeof(*pp) + 6 + skb_len + MICHAEL_MIC_LEN),
 		     KS_WLAN_MEM_FLAG);
 
 	if (!pp) {
@@ -1183,7 +1183,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 	buffer += 12;
 	length -= 12;
 	/* EtherType/Length check */
-	if (*(buffer + 1) + (*buffer << 8) > 1500) {
+	if (*(buffer + 1) + (*buffer << MICHAEL_MIC_LEN) > 1500) {
 		/* ProtocolEAP = *(buffer+1) + (*buffer << 8); */
 		/* DPRINTK(2, "Send [SNAP]Type %x\n",ProtocolEAP); */
 		/* SAP/CTL/OUI(6 byte) add */
@@ -1236,10 +1236,10 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
 						   (int)skb_len,
 						   (uint8_t)0,	/* priority */
 						   (uint8_t *)michael_mic.Result);
-				memcpy(p, michael_mic.Result, 8);
-				length += 8;
-				skb_len += 8;
-				p += 8;
+				memcpy(p, michael_mic.Result, MICHAEL_MIC_LEN);
+				length += MICHAEL_MIC_LEN;
+				skb_len += MICHAEL_MIC_LEN;
+				p += MICHAEL_MIC_LEN;
 				pp->auth_type =
 				    cpu_to_le16((uint16_t)TYPE_DATA);
 
diff --git a/drivers/staging/ks7010/michael_mic.h b/drivers/staging/ks7010/michael_mic.h
index 758e429..16971ab 100644
--- a/drivers/staging/ks7010/michael_mic.h
+++ b/drivers/staging/ks7010/michael_mic.h
@@ -9,6 +9,8 @@
  *   published by the Free Software Foundation.
  */
 
+#define MICHAEL_MIC_LEN 8
+
 /* MichaelMIC routine define */
 struct michael_mic_t {
 	u32 K0;	// Key
-- 
2.7.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux