All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: r8188eu: hal: remove goto statement and local variable
@ 2021-10-27  4:38 Saurav Girepunje
  2021-11-03 14:28 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Saurav Girepunje @ 2021-10-27  4:38 UTC (permalink / raw)
  To: Larry.Finger, phil, gregkh, straube.linux, saurav.girepunje,
	linux-staging, linux-kernel
  Cc: saurav.girepunje

Remove the goto statement from FillH2CCmd_88E(). In this function goto
can be replace by return statement. As on goto label exit, function
only return it is not performing any cleanup. Avoiding goto will
improve the function readability. After replacing the goto statement
local variable ret is also not needed. So remove the ret local variable.

Signed-off-by: Saurav Girepunje <saurav.girepunje@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c
index c5f9353fe3e6..de88e9ee532d 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c
@@ -53,19 +53,14 @@ static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *p
 	u8 cmd_idx, ext_cmd_len;
 	u32 h2c_cmd = 0;
 	u32 h2c_cmd_ex = 0;
-	s32 ret = _FAIL;

 	if (!adapt->bFWReady) {
 		DBG_88E("FillH2CCmd_88E(): return H2C cmd because fw is not ready\n");
-		return ret;
+		return _FAIL;
 	}

-	if (!pCmdBuffer)
-		goto exit;
-	if (CmdLen > RTL88E_MAX_CMD_LEN)
-		goto exit;
-	if (adapt->bSurpriseRemoved)
-		goto exit;
+	if (!pCmdBuffer || CmdLen > RTL88E_MAX_CMD_LEN || adapt->bSurpriseRemoved)
+		return _FAIL;

 	/* pay attention to if  race condition happened in  H2C cmd setting. */
 	do {
@@ -73,7 +68,7 @@ static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *p

 		if (!_is_fw_read_cmd_down(adapt, h2c_box_num)) {
 			DBG_88E(" fw read cmd failed...\n");
-			goto exit;
+			return _FAIL;
 		}

 		*(u8 *)(&h2c_cmd) = ElementID;
@@ -102,11 +97,7 @@ static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *p

 	} while ((!bcmd_down) && (retry_cnts--));

-	ret = _SUCCESS;
-
-exit:
-
-	return ret;
+	return _SUCCESS;
 }

 u8 rtl8188e_set_raid_cmd(struct adapter *adapt, u32 mask)
--
2.33.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: r8188eu: hal: remove goto statement and local variable
  2021-10-27  4:38 [PATCH] staging: r8188eu: hal: remove goto statement and local variable Saurav Girepunje
@ 2021-11-03 14:28 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2021-11-03 14:28 UTC (permalink / raw)
  To: Saurav Girepunje
  Cc: Larry.Finger, phil, gregkh, straube.linux, linux-staging,
	linux-kernel, saurav.girepunje

On Wed, Oct 27, 2021 at 10:08:08AM +0530, Saurav Girepunje wrote:
> Remove the goto statement from FillH2CCmd_88E(). In this function goto
> can be replace by return statement. As on goto label exit, function
> only return it is not performing any cleanup. Avoiding goto will
> improve the function readability. After replacing the goto statement
> local variable ret is also not needed. So remove the ret local variable.
> 
> Signed-off-by: Saurav Girepunje <saurav.girepunje@gmail.com>
> ---

Thanks!

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-03 14:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27  4:38 [PATCH] staging: r8188eu: hal: remove goto statement and local variable Saurav Girepunje
2021-11-03 14:28 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.