Staging: mt7621-mmc: Fix ret.cooci warnings
Subsystems (2)
PATCH v2 1/1 Staging: mt7621-mmc: Fix ret.cooci warnings
Return the value directly instead of storing it in local variable err. Remove the unused local variable err.
The semantic patch that fixes this problem is as follows
// <smpl>
@@
local idexpression ret;
expression e;
@@
-ret =
+return
e;
-return ret;
// </smpl>
---
v2:
-dropped patch series and did all the changes in same patch as the
first patch introduced the problem.
-Commit log modified.
drivers/staging/mt7621-mmc/sd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/mt7621-mmc/sd.c +1 -3
@@ -752,7 +752,6 @@ static int msdc_app_cmd(struct mmc_host *mmc, struct msdc_host *host) {struct mmc_command cmd;struct mmc_request mrq; -u32 err;memset (&cmd,0 ,sizeof (struct mmc_command )); cmd.opcode =MMC_APP_CMD ;
@@ -763,8 +762,7 @@ static int msdc_app_cmd(struct mmc_host *mmc, struct msdc_host *host) mrq.cmd = &cmd; cmd.mrq = &mrq; cmd.data =NULL ; - err =msdc_do_command (host, &cmd,0 ,CMD_TIMEOUT ); -return err; +return msdc_do_command (host, &cmd,0 ,CMD_TIMEOUT ); }static int msdc_tune_cmdrsp (struct msdc_host *host,struct mmc_command *cmd)
Signature · 1 line
2.17.1
Quoted 14 lines · Bhanusree Pola
Return the value directly instead of storing it in local variable err. Remove the unused local variable err.
The semantic patch that fixes this problem is as follows// <smpl>
@@
local idexpression ret;
expression e;
@@(quoted diff) +1
-2-ret = +return e; -return ret;
Quoted 1 line
// </smpl>
It could be better to say the semantic patch that fixes the first part of the problem, because the semantic patch doesn't drop the declaration of err.
Quoted 23 lines
Signed-off-by Bhanusree Pola <[email protected]>---
v2:
-dropped patch series and did all the changes in same patch as the
first patch introduced the problem.(quoted diff) +0
-1-Commit log modified. drivers/staging/mt7621-mmc/sd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/staging/mt7621-mmc/sd.c +0
-1@@ -752,7 +752,6 @@ static int msdc_app_cmd(struct mmc_host *mmc, struct msdc_host *host) {struct mmc_command cmd;struct mmc_request mrq; -u32 err;memset (&cmd,0 ,sizeof (struct mmc_command )); cmd.opcode =MMC_APP_CMD ;
drivers/staging/mt7621-mmc/sd.c static int msdc_app_cmd(struct mmc_host *mmc, struct msdc_host *host) · line 767
Quoted 5 lines
drivers/staging/mt7621-mmc/sd.c +0
-2@@ -763,8 +762,7 @@ static int msdc_app_cmd(struct mmc_host *mmc, struct msdc_host *host) mrq.cmd = &cmd; cmd.mrq = &mrq; cmd.data =NULL ; - err =msdc_do_command (host, &cmd,0 ,CMD_TIMEOUT ); -return err;
One can observe that this is returning a u32 variable (unsigned) when the function return type int (signed). Actually, it seems that msdc_do_command can return negative values, so int is better. However, msdc_command has return type unsigned int, which seems incorrect. It would be useful to clean all this up. Basically, you have to check the function definition to see what kinds of values it can return, and then check that the return type matches with that.
julia
Quoted 14 lines
drivers/staging/mt7621-mmc/sd.c +1
-1+return msdc_do_command (host, &cmd,0 ,CMD_TIMEOUT ); }static int msdc_tune_cmdrsp (struct msdc_host *host,struct mmc_command *cmd) --2.17.1
--
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/20190316152015.7879-1-bhanusreemahesh%40gmail.com.
For more options, visit https://groups.google.com/d/optout.