Skip to contentSkip to conversation

staging:rtl8192u: Coding style changes

PATCH In review John Whitmore 2 participants 9 messages Aug 4, 2018 – Aug 5, 2018 Staging

lore
Share & tools
lore
#0 lore raw

cover staging:rtl8192u: Coding style changes

Cleanup of the drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h file as the QOS_TCLAS union was moved into this file, in a previous patch. The type contained a number of naming issues.

John Whitmore (7):
staging:rtl8192u: Remove typedef and rename QOS_TCLAS - Style staging:rtl8192u: Rename types in QOS_TCLAS union - Style staging:rtl8192u: Rename multiple variables - Style staging:rtl8192u: Remove blank line - Style staging:rtl8192u: Remove comments - Style staging:rtl8192u: Remove unused member variable - Style staging:rtl8192u: Replace magic number with defined constant - Style

 .../staging/rtl8192u/ieee80211/ieee80211.h    |  2 +-
 .../rtl8192u/ieee80211/ieee80211_softmac.c    |  2 +-
 .../staging/rtl8192u/ieee80211/rtl819x_TS.h   | 99 +++++++++----------
 .../rtl8192u/ieee80211/rtl819x_TSProc.c       |  6 +-
 4 files changed, 54 insertions(+), 55 deletions(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/7 staging:rtl8192u: Remove typedef and rename QOS_TCLAS - Style

Remove the typedef from the union QOS_TCLAS, which causes a checkpatch issue with defining new types. In addition, as a type, the name should be in lowercase so has been changed.

These are coding style changes and should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h     | 6 +++---
 drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +3 -3
index 5cf00a2e08ae..823ba363e0ab 100644
@@ -14,7 +14,7 @@ enum tr_select {
 	RX_DIR = 1,
 };
 
-typedef union _QOS_TCLAS {
+union qos_tclas {
 
 	struct _TYPE_GENERAL {
 		u8		Priority;
@@ -63,7 +63,7 @@ typedef union _QOS_TCLAS {
 		u8		Mask;
 		u16		TagType;
 	} TYPE2_8021Q;
-} QOS_TCLAS, *PQOS_TCLAS;
+};
 
 struct ts_common_info {
 	struct list_head		list;
@@ -71,7 +71,7 @@ struct ts_common_info {
 	struct timer_list		inact_timer;
 	u8				addr[6];
 	struct tspec_body		t_spec;
-	QOS_TCLAS			t_class[TCLAS_NUM];
+	union qos_tclas			t_class[TCLAS_NUM];
 	u8				t_clas_proc;
 	u8				t_clas_num;
 };
drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +3 -3
index de06cd11ab65..d46d8f468671 100644
@@ -105,7 +105,7 @@ static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo)
 {
 	eth_zero_addr(pTsCommonInfo->addr);
 	memset(&pTsCommonInfo->t_spec, 0, sizeof(struct tspec_body));
-	memset(&pTsCommonInfo->t_class, 0, sizeof(QOS_TCLAS)*TCLAS_NUM);
+	memset(&pTsCommonInfo->t_class, 0, sizeof(union qos_tclas)*TCLAS_NUM);
 	pTsCommonInfo->t_clas_proc = 0;
 	pTsCommonInfo->t_clas_num = 0;
 }
@@ -265,7 +265,7 @@ static struct ts_common_info *SearchAdmitTRStream(struct ieee80211_device *ieee,
 }
 
 static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr,
-			struct tspec_body *pTSPEC, PQOS_TCLAS pTCLAS, u8 TCLAS_Num,
+			struct tspec_body *pTSPEC, union qos_tclas *pTCLAS, u8 TCLAS_Num,
 			u8 TCLAS_Proc)
 {
 	u8	count;
@@ -279,7 +279,7 @@ static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr,
 		memcpy((u8 *)(&(pTsCommonInfo->t_spec)), (u8 *)pTSPEC, sizeof(struct tspec_body));
 
 	for(count = 0; count < TCLAS_Num; count++)
-		memcpy((u8 *)(&(pTsCommonInfo->t_class[count])), (u8 *)pTCLAS, sizeof(QOS_TCLAS));
+		memcpy((u8 *)(&(pTsCommonInfo->t_class[count])), (u8 *)pTCLAS, sizeof(union qos_tclas));
 
 	pTsCommonInfo->t_clas_proc = TCLAS_Proc;
 	pTsCommonInfo->t_clas_num = TCLAS_Num;
Signature · 1 line
2.18.0
#2 lore raw

PATCH 2/7 staging:rtl8192u: Rename types in QOS_TCLAS union - Style

In reply to John Whitmore

Whilst none of the structures inside the qos_tclas union are used, their names conflict with the coding standard being named in uppercase. The names of all five have been changed to lowercase.

This is a style change, and since none of the structures are referenced, these changes should have no impact on runtime code execution.

---
 .../staging/rtl8192u/ieee80211/rtl819x_TS.h   | 20 +++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +10 -10
index 823ba363e0ab..c352ba0bcd8f 100644
@@ -16,22 +16,22 @@ enum tr_select {
 
 union qos_tclas {
 
-	struct _TYPE_GENERAL {
+	struct type_general {
 		u8		Priority;
 		u8		ClassifierType;
 		u8		Mask;
-	} TYPE_GENERAL;
+	} type_general;
 
-	struct _TYPE0_ETH {
+	struct type0_eth {
 		u8		Priority;
 		u8		ClassifierType;
 		u8		Mask;
 		u8		SrcAddr[6];
 		u8		DstAddr[6];
 		u16		Type;
-	} TYPE0_ETH;
+	} type0_eth;
 
-	struct _TYPE1_IPV4 {
+	struct type1_ipv4 {
 		u8		Priority;
 		u8		ClassifierType;
 		u8		Mask;
@@ -43,9 +43,9 @@ union qos_tclas {
 		u8		DSCP;
 		u8		Protocol;
 		u8		Reserved;
-	} TYPE1_IPV4;
+	} type1_ipv4;
 
-	struct _TYPE1_IPV6 {
+	struct type1_ipv6 {
 		u8		Priority;
 		u8		ClassifierType;
 		u8		Mask;
@@ -55,14 +55,14 @@ union qos_tclas {
 		u16		SrcPort;
 		u16		DstPort;
 		u8		FlowLabel[3];
-	} TYPE1_IPV6;
+	} type1_ipv6;
 
-	struct _TYPE2_8021Q {
+	struct type2_8021q {
 		u8		Priority;
 		u8		ClassifierType;
 		u8		Mask;
 		u16		TagType;
-	} TYPE2_8021Q;
+	} type2_8021q;
 };
 
 struct ts_common_info {
Signature · 1 line
2.18.0
#3 lore raw

PATCH 3/7 staging:rtl8192u: Rename multiple variables - Style

In reply to John Whitmore

All of the variables used within the structures of the union qos_tclas cause checkpatch issue due to CamelCase naming. As none the member variables are used in code all have been changed on one patch.

These changes are coding style in nature and should not impact runtime code execution.

---
 .../staging/rtl8192u/ieee80211/rtl819x_TS.h   | 66 +++++++++----------
 1 file changed, 33 insertions(+), 33 deletions(-)
drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +33 -33
index c352ba0bcd8f..508ed639cda5 100644
@@ -17,51 +17,51 @@ enum tr_select {
 union qos_tclas {
 
 	struct type_general {
-		u8		Priority;
-		u8		ClassifierType;
-		u8		Mask;
+		u8		priority;
+		u8		classifier_type;
+		u8		mask;
 	} type_general;
 
 	struct type0_eth {
-		u8		Priority;
-		u8		ClassifierType;
-		u8		Mask;
-		u8		SrcAddr[6];
-		u8		DstAddr[6];
-		u16		Type;
+		u8		priority;
+		u8		classifier_type;
+		u8		mask;
+		u8		src_addr[6];
+		u8		dst_addr[6];
+		u16		type;
 	} type0_eth;
 
 	struct type1_ipv4 {
-		u8		Priority;
-		u8		ClassifierType;
-		u8		Mask;
-		u8		Version;
-		u8		SrcIP[4];
-		u8		DstIP[4];
-		u16		SrcPort;
-		u16		DstPort;
-		u8		DSCP;
-		u8		Protocol;
-		u8		Reserved;
+		u8		priority;
+		u8		classifier_type;
+		u8		mask;
+		u8		version;
+		u8		src_ip[4];
+		u8		dst_ip[4];
+		u16		src_port;
+		u16		dst_port;
+		u8		dscp;
+		u8		protocol;
+		u8		reserved;
 	} type1_ipv4;
 
 	struct type1_ipv6 {
-		u8		Priority;
-		u8		ClassifierType;
-		u8		Mask;
-		u8		Version;
-		u8		SrcIP[16];
-		u8		DstIP[16];
-		u16		SrcPort;
-		u16		DstPort;
-		u8		FlowLabel[3];
+		u8		priority;
+		u8		classifier_type;
+		u8		mask;
+		u8		version;
+		u8		src_ip[16];
+		u8		dst_ip[16];
+		u16		src_port;
+		u16		dst_port;
+		u8		flow_label[3];
 	} type1_ipv6;
 
 	struct type2_8021q {
-		u8		Priority;
-		u8		ClassifierType;
-		u8		Mask;
-		u16		TagType;
+		u8		priority;
+		u8		classifier_type;
+		u8		mask;
+		u16		tag_type;
 	} type2_8021q;
 };
 
Signature · 1 line
2.18.0
#4 lore raw

PATCH 4/7 staging:rtl8192u: Remove blank line - Style

In reply to John Whitmore

Removal of a blank like which causes a checkpatch issue.

This is a simple coding style change and should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +0 -1
index 508ed639cda5..93984e8e87c3 100644
@@ -15,7 +15,6 @@ enum tr_select {
 };
 
 union qos_tclas {
-
 	struct type_general {
 		u8		priority;
 		u8		classifier_type;
Signature · 1 line
2.18.0
#5 lore raw

PATCH 5/7 staging:rtl8192u: Remove comments - Style

In reply to John Whitmore

Removal of three comments. The comments in question do not add anything to the understanding of the code, and if they are necessary it would imply that the structure and its member variables are badly named.

This is a simple style change and should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h +3 -3
index 93984e8e87c3..924d4b373099 100644
@@ -78,8 +78,8 @@ struct ts_common_info {
 struct tx_ts_record {
 	struct ts_common_info		ts_common_info;
 	u16				tx_cur_seq;
-	BA_RECORD			tx_pending_ba_record;	/*  For BA Originator */
-	BA_RECORD			tx_admitted_ba_record;	/*  For BA Originator */
+	BA_RECORD			tx_pending_ba_record;
+	BA_RECORD			tx_admitted_ba_record;
 	u8				add_ba_req_in_progress;
 	u8				add_ba_req_delayed;
 	u8				using_ba;
@@ -93,7 +93,7 @@ struct rx_ts_record {
 	u16				rx_timeout_indicate_seq;
 	struct list_head		rx_pending_pkt_list;
 	struct timer_list		rx_pkt_pending_timer;
-	BA_RECORD			rx_admitted_ba_record;	 /*  For BA Recipient */
+	BA_RECORD			rx_admitted_ba_record;
 	u16				rx_last_seq_num;
 	u8				rx_last_frag_num;
 	u8				num;
Signature · 1 line
2.18.0
#6 lore raw

PATCH 6/7 staging:rtl8192u: Remove unused member variable - Style

In reply to John Whitmore

Remove name of 'reserved' bitfield member which is simply used to pad the bitfield to a byte boundary. The actual bit has been left in place so alignment should not change. The name, which is not required has been removed.

This is a coding style change which should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/ieee80211/ieee80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/ieee80211/ieee80211.h +1 -1
index 3cfeac0d7214..fc449806dab8 100644
@@ -114,7 +114,7 @@ struct cb_desc {
 	u8 bBroadcast:1;
 	//u8 reserved2:2;
 	u8 drv_agg_enable:1;
-	u8 reserved2:1;
+	u8:1;
 
 	/* Tx Desc related element(12-19) */
 	u8 rata_index;
Signature · 1 line
2.18.0
maintainer
#7 lore raw

Re: [PATCH 6/7] staging:rtl8192u: Remove unused member variable - Style

Quoted 18 lines · John Whitmore

Remove name of 'reserved' bitfield member which is simply used to pad the bitfield to a byte boundary. The actual bit has been left in place so alignment should not change. The name, which is not required has been removed.

This is a coding style change which should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/ieee80211/ieee80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/ieee80211/ieee80211.h +0 -0
index 3cfeac0d7214..fc449806dab8 100644

drivers/staging/rtl8192u/ieee80211/ieee80211.h struct cb_desc { · line 117

Quoted 5 lines
drivers/staging/rtl8192u/ieee80211/ieee80211.h +1 -1
@@ -114,7 +114,7 @@ struct cb_desc {
 	u8 bBroadcast:1;
 	//u8 reserved2:2;
 	u8 drv_agg_enable:1;
-	u8 reserved2:1;
+	u8:1;

No, this is ok, and a common thing to do. Anonymous bit fields is not a normal thing.

thanks,

greg k-h

#8 lore raw

PATCH 7/7 staging:rtl8192u: Replace magic number with defined constant - Style

In reply to John Whitmore

Replace the magic number '8' with defined constant which is normally used 'MAX_DEV_ADDR_SIZE'.

This is a coding style change which should have no impact on runtime code execution.

---
 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +1 -1
index 51cb5e4658b0..212cc9ccbb96 100644
@@ -217,7 +217,7 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee
 	struct rtl_80211_hdr_3addr  *header =
 		(struct rtl_80211_hdr_3addr  *)skb->data;
 
-	struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8);
+	struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
 
 	spin_lock_irqsave(&ieee->lock, flags);
 
Signature · 1 line
2.18.0