Skip to contentSkip to conversation

staging: rtl8723bs: Move closing braces of 'if' statements to end of line

PATCH In review Dafna Hirschfeld 2 participants 4 messages Feb 17, 2018 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8723bs: Move closing braces of 'if' statements to end of line

Move all closing braces to the end of the line. Remove braces in single 'if' statement. Break 'if' condition to avoid 80 characters line. Issues found with checkpatch.pl

---
 drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +5 -10
index f29e110..4861c80 100644
@@ -64,9 +64,7 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb
 	if (alloc_sz > 0) {
 		pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz);
 		if (pxmitbuf->pallocated_buf == NULL)
-		{
 			return _FAIL;
-		}
 
 		pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ);
 	}
@@ -90,8 +88,8 @@ void rtw_os_pkt_complete(struct adapter *padapter, _pkt *pkt)
 	queue = skb_get_queue_mapping(pkt);
 	if (padapter->registrypriv.wifi_spec) {
 		if (__netif_subqueue_stopped(padapter->pnetdev, queue) &&
-			(pxmitpriv->hwxmits[queue].accnt < WMM_XMIT_THRESHOLD))
-		{
+			(pxmitpriv->hwxmits[queue].accnt <
+			 WMM_XMIT_THRESHOLD)) {
 			netif_wake_subqueue(padapter->pnetdev, queue);
 		}
 	} else {
@@ -177,8 +175,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
 
 	for (i = 0; i < chk_alive_num; i++) {
 		psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]);
-		if (!(psta->state & _FW_LINKED))
-		{
+		if (!(psta->state & _FW_LINKED)) {
 			DBG_COUNTER(padapter->tx_logs.os_tx_m2u_ignore_fw_linked);
 			continue;
 		}
@@ -187,8 +184,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
 		if (!memcmp(psta->hwaddr, &skb->data[6], 6)
 			|| !memcmp(psta->hwaddr, null_addr, 6)
 			|| !memcmp(psta->hwaddr, bc_addr, 6)
-		)
-		{
+		) {
 			DBG_COUNTER(padapter->tx_logs.os_tx_m2u_ignore_self);
 			continue;
 		}
@@ -249,8 +245,7 @@ int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev)
 			#endif
 			)
 		&& (padapter->registrypriv.wifi_spec == 0)
-		)
-	{
+		) {
 		if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME/4)) {
 			res = rtw_mlcst2unicst(padapter, pkt);
 			if (res == true) {
Signature · 1 line
2.7.4
#1 lore raw
Quoted 2 lines · Dafna Hirschfeld

Move all closing braces to the end of the line.
Remove braces in single 'if' statement.

It's not really a single if statement, but rather an if with a single statement in the then branch (or in both branches, as appropriate).

Quoted 2 lines

Break 'if' condition to avoid 80 characters line.
Issues found with checkpatch.pl

This goes overboard on shortening the commit message line length. Maybe you can configure your editor to do the appropriate line break, or at least show the column number.

Quoted 11 lines
---
 drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +0 -0
index f29e110..4861c80 100644

drivers/staging/rtl8723bs/os_dep/xmit_linux.c int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb · line 69

Quoted 6 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +0 -2
@@ -64,9 +64,7 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb
 	if (alloc_sz > 0) {
 		pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz);
 		if (pxmitbuf->pallocated_buf == NULL)
-		{
 			return _FAIL;
-		}

OK

drivers/staging/rtl8723bs/os_dep/xmit_linux.c void rtw_os_pkt_complete(struct adapter *padapter, _pkt *pkt) · line 92

Quoted 11 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +2 -2
 		pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ);
 	}
@@ -90,8 +88,8 @@ void rtw_os_pkt_complete(struct adapter *padapter, _pkt *pkt)
 	queue = skb_get_queue_mapping(pkt);
 	if (padapter->registrypriv.wifi_spec) {
 		if (__netif_subqueue_stopped(padapter->pnetdev, queue) &&
-			(pxmitpriv->hwxmits[queue].accnt < WMM_XMIT_THRESHOLD))
-		{
+			(pxmitpriv->hwxmits[queue].accnt <
+			 WMM_XMIT_THRESHOLD)) {

This does not look so nice. What happens if you move the condition to the left, such that it starts just to the right of the ( on the preceeding line. If needed, you can also drop the parentheses.

drivers/staging/rtl8723bs/os_dep/xmit_linux.c static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) · line 178

Quoted 10 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +1 -2
 			netif_wake_subqueue(padapter->pnetdev, queue);
 		}
 	} else {
@@ -177,8 +175,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
 
 	for (i = 0; i < chk_alive_num; i++) {
 		psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]);
-		if (!(psta->state & _FW_LINKED))
-		{
+		if (!(psta->state & _FW_LINKED)) {

OK

drivers/staging/rtl8723bs/os_dep/xmit_linux.c static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) · line 187

Quoted 10 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +1 -2
 			DBG_COUNTER(padapter->tx_logs.os_tx_m2u_ignore_fw_linked);
 			continue;
 		}
@@ -187,8 +184,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
 		if (!memcmp(psta->hwaddr, &skb->data[6], 6)
 			|| !memcmp(psta->hwaddr, null_addr, 6)
 			|| !memcmp(psta->hwaddr, bc_addr, 6)
-		)
-		{
+		) {

The close parenthesis on the line with the { is not nice. Move the whole thing back to just after the last memcmp call.

drivers/staging/rtl8723bs/os_dep/xmit_linux.c int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev) · line 248

Quoted 10 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +1 -2
 			DBG_COUNTER(padapter->tx_logs.os_tx_m2u_ignore_self);
 			continue;
 		}
@@ -249,8 +245,7 @@ int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev)
 			#endif
 			)
 		&& (padapter->registrypriv.wifi_spec == 0)
-		)
-	{
+		) {

Same here.

julia

Quoted 13 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +0 -1
 		if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME/4)) {
 			res = rtw_mlcst2unicst(padapter, pkt);
 			if (res == true) {
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20180217171924.GA4155%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 66 lines · Julia Lawall
Quoted 2 lines · Dafna Hirschfeld

Move all closing braces to the end of the line.
Remove braces in single 'if' statement.

It's not really a single if statement, but rather an if with a single statement in the then branch (or in both branches, as appropriate).

Quoted 2 lines

Break 'if' condition to avoid 80 characters line.
Issues found with checkpatch.pl

This goes overboard on shortening the commit message line length. Maybe you can configure your editor to do the appropriate line break, or at least show the column number.

Quoted 11 lines
---
 drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +0 -0
index f29e110..4861c80 100644

drivers/staging/rtl8723bs/os_dep/xmit_linux.c int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb · line 69

Quoted 6 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +0 -2
@@ -64,9 +64,7 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb
 	if (alloc_sz > 0) {
 		pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz);
 		if (pxmitbuf->pallocated_buf == NULL)
-		{
 			return _FAIL;
-		}

OK

drivers/staging/rtl8723bs/os_dep/xmit_linux.c void rtw_os_pkt_complete(struct adapter *padapter, _pkt *pkt) · line 92

Quoted 11 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +2 -2
 		pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ);
 	}
@@ -90,8 +88,8 @@ void rtw_os_pkt_complete(struct adapter *padapter, _pkt *pkt)
 	queue = skb_get_queue_mapping(pkt);
 	if (padapter->registrypriv.wifi_spec) {
 		if (__netif_subqueue_stopped(padapter->pnetdev, queue) &&
-			(pxmitpriv->hwxmits[queue].accnt < WMM_XMIT_THRESHOLD))
-		{
+			(pxmitpriv->hwxmits[queue].accnt <
+			 WMM_XMIT_THRESHOLD)) {

This does not look so nice. What happens if you move the condition to the left, such that it starts just to the right of the ( on the preceeding line. If needed, you can also drop the parentheses.

drivers/staging/rtl8723bs/os_dep/xmit_linux.c static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) · line 178

Quoted 10 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +1 -2
 			netif_wake_subqueue(padapter->pnetdev, queue);
 		}
 	} else {
@@ -177,8 +175,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
 
 	for (i = 0; i < chk_alive_num; i++) {
 		psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]);
-		if (!(psta->state & _FW_LINKED))
-		{
+		if (!(psta->state & _FW_LINKED)) {

OK

Quoted 13 lines

drivers/staging/rtl8723bs/os_dep/xmit_linux.c static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) · line 187

Quoted 10 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +1 -2
 			DBG_COUNTER(padapter->tx_logs.os_tx_m2u_ignore_fw_linked);
 			continue;
 		}
@@ -187,8 +184,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
 		if (!memcmp(psta->hwaddr, &skb->data[6], 6)
 			|| !memcmp(psta->hwaddr, null_addr, 6)
 			|| !memcmp(psta->hwaddr, bc_addr, 6)
-		)
-		{
+		) {

The close parenthesis on the line with the { is not nice. Move the whole thing back to just after the last memcmp call.

Hi, Solving the issue here as you asked raises a "CHECK: Logical continuations should be on the previous line" It apperntly relates to the '||' being in the start of each line instead of the end.
Moving the '||' to the end solves all issues. Should I add it to the patch ?

Quoted 13 lines

drivers/staging/rtl8723bs/os_dep/xmit_linux.c int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev) · line 248

Quoted 11 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +1 -2
 			DBG_COUNTER(padapter->tx_logs.os_tx_m2u_ignore_self);
 			continue;
 		}
@@ -249,8 +245,7 @@ int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev)
 			#endif
 			)
 		&& (padapter->registrypriv.wifi_spec == 0)
-		)
-	{
+		) {

Same here.

See the longer context of this code https://elixir.bootlin.com/linux/v4.16-rc1/source/drivers/staging/rtl8723bs/os_dep/xmit_linux.c#L248
Here is the same thing as in previous case, the '||' are in the start. It's also not possible to move them to the end of previous line because it is withing an #if/#endif clause.

Quoted 16 lines

julia

Quoted 13 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +0 -1
 		if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME/4)) {
 			res = rtw_mlcst2unicst(padapter, pkt);
 			if (res == true) {
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20180217171924.GA4155%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#3 lore raw
Quoted 80 lines · Dafna Hirschfeld
Quoted 66 lines · Julia Lawall
Quoted 2 lines · Dafna Hirschfeld

Move all closing braces to the end of the line.
Remove braces in single 'if' statement.

It's not really a single if statement, but rather an if with a single statement in the then branch (or in both branches, as appropriate).

Quoted 2 lines

Break 'if' condition to avoid 80 characters line.
Issues found with checkpatch.pl

This goes overboard on shortening the commit message line length. Maybe you can configure your editor to do the appropriate line break, or at least show the column number.

Quoted 11 lines
---
 drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +0 -0
index f29e110..4861c80 100644

drivers/staging/rtl8723bs/os_dep/xmit_linux.c int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb · line 69

Quoted 6 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +0 -2
@@ -64,9 +64,7 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb
 	if (alloc_sz > 0) {
 		pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz);
 		if (pxmitbuf->pallocated_buf == NULL)
-		{
 			return _FAIL;
-		}

OK

drivers/staging/rtl8723bs/os_dep/xmit_linux.c void rtw_os_pkt_complete(struct adapter *padapter, _pkt *pkt) · line 92

Quoted 11 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +2 -2
 		pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ);
 	}
@@ -90,8 +88,8 @@ void rtw_os_pkt_complete(struct adapter *padapter, _pkt *pkt)
 	queue = skb_get_queue_mapping(pkt);
 	if (padapter->registrypriv.wifi_spec) {
 		if (__netif_subqueue_stopped(padapter->pnetdev, queue) &&
-			(pxmitpriv->hwxmits[queue].accnt < WMM_XMIT_THRESHOLD))
-		{
+			(pxmitpriv->hwxmits[queue].accnt <
+			 WMM_XMIT_THRESHOLD)) {

This does not look so nice. What happens if you move the condition to the left, such that it starts just to the right of the ( on the preceeding line. If needed, you can also drop the parentheses.

drivers/staging/rtl8723bs/os_dep/xmit_linux.c static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) · line 178

Quoted 10 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +1 -2
 			netif_wake_subqueue(padapter->pnetdev, queue);
 		}
 	} else {
@@ -177,8 +175,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
 
 	for (i = 0; i < chk_alive_num; i++) {
 		psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]);
-		if (!(psta->state & _FW_LINKED))
-		{
+		if (!(psta->state & _FW_LINKED)) {

OK

Quoted 13 lines

drivers/staging/rtl8723bs/os_dep/xmit_linux.c static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) · line 187

Quoted 10 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +1 -2
 			DBG_COUNTER(padapter->tx_logs.os_tx_m2u_ignore_fw_linked);
 			continue;
 		}
@@ -187,8 +184,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
 		if (!memcmp(psta->hwaddr, &skb->data[6], 6)
 			|| !memcmp(psta->hwaddr, null_addr, 6)
 			|| !memcmp(psta->hwaddr, bc_addr, 6)
-		)
-		{
+		) {

The close parenthesis on the line with the { is not nice. Move the whole thing back to just after the last memcmp call.

Quoted 3 lines

Hi, Solving the issue here as you asked raises a "CHECK: Logical continuations should be on the previous line" It apperntly relates to the '||' being in the start of each line instead of the end.
Moving the '||' to the end solves all issues. Should I add it to the patch ?

It could be reasonable. The subject of the patch could become "clean up conditionals", to be a bit more general.

Quoted 13 lines
Quoted 13 lines

drivers/staging/rtl8723bs/os_dep/xmit_linux.c int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev) · line 248

Quoted 11 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +1 -2
 			DBG_COUNTER(padapter->tx_logs.os_tx_m2u_ignore_self);
 			continue;
 		}
@@ -249,8 +245,7 @@ int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev)
 			#endif
 			)
 		&& (padapter->registrypriv.wifi_spec == 0)
-		)
-	{
+		) {

Same here.

Quoted 3 lines

See the longer context of this code https://elixir.bootlin.com/linux/v4.16-rc1/source/drivers/staging/rtl8723bs/os_dep/xmit_linux.c#L248
Here is the same thing as in previous case, the '||' are in the start. It's also not possible to move them to the end of previous line because it is withing an #if/#endif clause.

If it's impossible, it's impossible. Checkpatch just makes suggestions. It doesn't always see enough of the context.

julia

Quoted 17 lines
Quoted 16 lines

julia

Quoted 13 lines
drivers/staging/rtl8723bs/os_dep/xmit_linux.c +0 -1
 		if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME/4)) {
 			res = rtw_mlcst2unicst(padapter, pkt);
 			if (res == true) {
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20180217171924.GA4155%40gmail.com.
For more options, visit https://groups.google.com/d/optout.