Skip to contentSkip to conversation

staging: rtl8188eu: remove unnecessary ternary operator

PATCH In review Michael Straube 2 participants 8 messages Oct 27, 2018 – Oct 28, 2018 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 staging: rtl8188eu: remove unnecessary ternary operator

The field accept_addba_req of struct mlme_ext_info has type bool. Use the value of accept_addba_req directly instead of the ternary operator in an asignment.

---
 drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8188eu/core/rtw_wlan_util.c +1 -2
index 3e05e2c7f61b..d678dcee7312 100644
@@ -1504,8 +1504,7 @@ void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr)
 		tid = (param>>2)&0x0f;
 		preorder_ctrl = &psta->recvreorder_ctrl[tid];
 		preorder_ctrl->indicate_seq = 0xffff;
-		preorder_ctrl->enable = (pmlmeinfo->accept_addba_req) ? true
-								      : false;
+		preorder_ctrl->enable = pmlmeinfo->accept_addba_req;
 	}
 }
 
Signature · 1 line
2.19.1
#1 lore raw

PATCH 2/5 staging: rtl8188eu: change type of a struct field

The field enable of struct recv_reorder_ctrl is only used for boolean values, so change the type from u8 to bool.

---
 drivers/staging/rtl8188eu/include/rtw_recv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8188eu/include/rtw_recv.h +1 -1
index 54b7ba367293..8fc500496f92 100644
@@ -27,7 +27,7 @@
 /* for Rx reordering buffer control */
 struct recv_reorder_ctrl {
 	struct adapter	*padapter;
-	u8 enable;
+	bool enable;
 	u16 indicate_seq;/* wstart_b, init_value=0xffff */
 	u16 wend_b;
 	u8 wsize_b;
Signature · 1 line
2.19.1
#2 lore raw

PATCH 3/5 staging: rtl8188eu: change return type of rtl8188eu_xmitframe_complete()

In reply to Michael Straube

The function rtl8188eu_xmitframe_complete() returns true or false. Change the return type from s32 to bool.

---
 drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c    | 3 ++-
 drivers/staging/rtl8188eu/include/rtl8188e_xmit.h | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +2 -1
index a11bee16d070..69a0edd27710 100644
@@ -412,7 +412,8 @@ static u32 xmitframe_need_length(struct xmit_frame *pxmitframe)
 	return len;
 }
 
-s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitpriv)
+bool rtl8188eu_xmitframe_complete(struct adapter *adapt,
+				  struct xmit_priv *pxmitpriv)
 {
 	struct xmit_frame *pxmitframe = NULL;
 	struct xmit_frame *pfirstframe = NULL;
drivers/staging/rtl8188eu/include/rtl8188e_xmit.h +2 -2
index 20d35480dab8..421e9f45306f 100644
@@ -149,8 +149,8 @@ s32 rtl8188eu_init_xmit_priv(struct adapter *padapter);
 s32 rtl8188eu_xmit_buf_handler(struct adapter *padapter);
 #define hal_xmit_handler rtl8188eu_xmit_buf_handler
 void rtl8188eu_xmit_tasklet(void *priv);
-s32 rtl8188eu_xmitframe_complete(struct adapter *padapter,
-				 struct xmit_priv *pxmitpriv);
+bool rtl8188eu_xmitframe_complete(struct adapter *padapter,
+				  struct xmit_priv *pxmitpriv);
 
 void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf);
 
Signature · 1 line
2.19.1
#3 lore raw

PATCH 4/5 staging: rtl8188eu: change return type of rtw_hal_xmit()

In reply to Michael Straube

The function rtw_hal_xmit() returns true or false. Change the return type from s32 to bool.

---
 drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c | 2 +-
 drivers/staging/rtl8188eu/include/hal_intf.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +1 -1
index 69a0edd27710..35bc8fc32db1 100644
@@ -598,7 +598,7 @@ bool rtl8188eu_xmitframe_complete(struct adapter *adapt,
  *	true	dump packet directly
  *	false	enqueue packet
  */
-s32 rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe)
+bool rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe)
 {
 	s32 res;
 	struct xmit_buf *pxmitbuf = NULL;
drivers/staging/rtl8188eu/include/hal_intf.h +1 -1
index e5be27af7bf5..8b65fcba1967 100644
@@ -185,7 +185,7 @@ u32	rtw_hal_inirp_init(struct adapter *padapter);
 void	rtw_hal_inirp_deinit(struct adapter *padapter);
 void usb_intf_stop(struct adapter *padapter);
 
-s32	rtw_hal_xmit(struct adapter *padapter, struct xmit_frame *pxmitframe);
+bool rtw_hal_xmit(struct adapter *padapter, struct xmit_frame *pxmitframe);
 s32	rtw_hal_mgnt_xmit(struct adapter *padapter,
 			  struct xmit_frame *pmgntframe);
 
Signature · 1 line
2.19.1
#7 lore raw

PATCH 5/5 staging: rtl8188eu: cleanup long line in rtw_hal_xmit()

In reply to Michael Straube

Cleanup a line over 80 characters in rtw_hal_xmit() by using if(x) instead of if(x == true). Also clears a missing spaces around '|' checkpatch issue.

---
 drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +1 -1
index 35bc8fc32db1..a72e069269b8 100644
@@ -611,7 +611,7 @@ bool rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe)
 	if (rtw_txframes_sta_ac_pending(adapt, pattrib) > 0)
 		goto enqueue;
 
-	if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true)
+	if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING))
 		goto enqueue;
 
 	pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv);
Signature · 1 line
2.19.1
#4 lore raw

Re: [PATCH 4/5] staging: rtl8188eu: change return type of rtw_hal_xmit()

In reply to Michael Straube
Quoted 2 lines · Michael Straube

The function rtw_hal_xmit() returns true or false. Change the return type from s32 to bool.

[]

drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c

Quoted 1 line
drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +0 -0

[]

drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c bool rtl8188eu_xmitframe_complete(struct adapter *adapt, · line 603

Quoted 8 lines
drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +1 -1
@@ -598,7 +598,7 @@ bool rtl8188eu_xmitframe_complete(struct adapter *adapt,
  *	true	dump packet directly
  *	false	enqueue packet
  */
-s32 rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe)
+bool rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe)
 {
 	s32 res;

Does "s32 res" need changing to bool too?

#5 lore raw

Re: [PATCH 4/5] staging: rtl8188eu: change return type of rtw_hal_xmit()

Quoted 6 lines · Joe Perches
Quoted 2 lines · Michael Straube

The function rtw_hal_xmit() returns true or false. Change the return type from s32 to bool.

[]

drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c

Quoted 1 line
drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +0 -0

[]

Quoted 10 lines

drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c bool rtl8188eu_xmitframe_complete(struct adapter *adapt, · line 603

Quoted 8 lines
drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +1 -1
@@ -598,7 +598,7 @@ bool rtl8188eu_xmitframe_complete(struct adapter *adapt,
  *	true	dump packet directly
  *	false	enqueue packet
  */
-s32 rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe)
+bool rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe)
 {
 	s32 res;

Does "s32 res" need changing to bool too?

Perhaps all the functions regardless of types
with returns of only _SUCCESS and _FAIL could be
converted to bool.

#6 lore raw

Re: [PATCH 4/5] staging: rtl8188eu: change return type of rtw_hal_xmit()

Quoted 18 lines · Joe Perches
Quoted 6 lines · Joe Perches
Quoted 2 lines · Michael Straube

The function rtw_hal_xmit() returns true or false. Change the return type from s32 to bool.

[]

drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c

Quoted 1 line
drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +0 -0

[]

Quoted 10 lines

drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c bool rtl8188eu_xmitframe_complete(struct adapter *adapt, · line 603

Quoted 8 lines
drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +1 -1
@@ -598,7 +598,7 @@ bool rtl8188eu_xmitframe_complete(struct adapter *adapt,
   *	true	dump packet directly
   *	false	enqueue packet
   */
-s32 rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe)
+bool rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe)
  {
  	s32 res;

Does "s32 res" need changing to bool too?

Quoted 4 lines

Perhaps all the functions regardless of types
with returns of only _SUCCESS and _FAIL could be
converted to bool.

"s32 res" is not used for return value, so it does not need changing to bool. But it could be converted too.

I'll keep that, and converting functions only returning _SUCCESS and _FAIL to bool, in mind for future patches. Thanks.

Perhaps _SUCCESS / _FAIL could be replaced with true / false throughout the driver to get rid of the defines? Or is that a bad idea?

Regards,
Michael