mmc: sdhci-cadence: fix logically and structurally dead code
Subsystems (3)
PATCH v2 1/1 mmc: sdhci-cadence: fix logically and structurally dead code
Currently, the code block inside the for loop will never execute more than once, because the function returns inmediately after the first iteration, hence the execution of the code at the second iteration is structurally dead and, code at line 281: return 0; is never reached.
Fix this by checking _ret_ before return.
Addresses-Coverity-ID: 1468009 ("Logically dead code")
Addresses-Coverity-ID: 1468002 ("Structurally dead code")
---
Changes in v2:
- Update changelog.
- Drop the 'Fixes' tag.
- Add check on ret instead of removing the "return ret;" line.
- Thanks to Masahiro Yamada for the feedback provided.
drivers/mmc/host/sdhci-cadence.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-cadence.c +2 -2
@@ -274,8 +274,8 @@ static int sdhci_cdns_set_tune_val(struct sdhci_host *host, unsigned int val) ret =readl_poll_timeout (reg, tmp, !(tmp &SDHCI_CDNS_HRS06_TUNE_UP ),0 ,1 ); - -return ret; +if (ret) +return ret; }return 0 ;
Signature · 1 line
2.7.4
2018-04-20 0:59 GMT+09:00 Gustavo A. R. Silva <[email protected]>:
Quoted 6 lines
Currently, the code block inside the for loop will never execute more than once, because the function returns inmediately after the first iteration, hence the execution of the code at the second iteration is structurally dead and, code at line 281: return 0; is never reached.
Quoted 7 lines
Fix this by checking _ret_ before return.
Addresses-Coverity-ID: 1468009 ("Logically dead code")
Addresses-Coverity-ID: 1468002 ("Structurally dead code")Suggested-by Masahiro Yamada <[email protected]>Signed-off-by Gustavo A. R. Silva <[email protected]>---
Looks good to me except the typo in the log
inmediately -> immediately
Quoted 27 lines
Changes in v2:
- Update changelog.
- Drop the 'Fixes' tag.
- Add check on ret instead of removing the "return ret;" line.
- Thanks to Masahiro Yamada for the feedback provided.drivers/mmc/host/sdhci-cadence.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/mmc/host/sdhci-cadence.c +2
-3@@ -274,8 +274,8 @@ static int sdhci_cdns_set_tune_val(struct sdhci_host *host, unsigned int val) ret =readl_poll_timeout (reg, tmp, !(tmp &SDHCI_CDNS_HRS06_TUNE_UP ),0 ,1 ); - -return ret; +if (ret) +return ret; }return 0 ; --2.7.4
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 6 lines · Gustavo A. R. Silva
Currently, the code block inside the for loop will never execute more than once, because the function returns inmediately after the first iteration, hence the execution of the code at the second iteration is structurally dead and, code at line 281: return 0; is never reached.
Quoted 6 lines
Fix this by checking _ret_ before return.
Addresses-Coverity-ID: 1468009 ("Logically dead code")
Addresses-Coverity-ID: 1468002 ("Structurally dead code")Suggested-by Masahiro Yamada <[email protected]>Signed-off-by Gustavo A. R. Silva <[email protected]>
Quoted 26 lines
---
Changes in v2:
- Update changelog.
- Drop the 'Fixes' tag.
- Add check on ret instead of removing the "return ret;" line.
- Thanks to Masahiro Yamada for the feedback provided.drivers/mmc/host/sdhci-cadence.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/mmc/host/sdhci-cadence.c +2
-2@@ -274,8 +274,8 @@ static int sdhci_cdns_set_tune_val(struct sdhci_host *host, unsigned int val) ret =readl_poll_timeout (reg, tmp, !(tmp &SDHCI_CDNS_HRS06_TUNE_UP ),0 ,1 ); - -return ret; +if (ret) +return ret; }return 0 ;
Ulf Hansson
AppliedQuoted 6 lines · Gustavo A. R. Silva
Currently, the code block inside the for loop will never execute more than once, because the function returns inmediately after the first iteration, hence the execution of the code at the second iteration is structurally dead and, code at line 281: return 0; is never reached.
Quoted 6 lines
Fix this by checking _ret_ before return.
Addresses-Coverity-ID: 1468009 ("Logically dead code")
Addresses-Coverity-ID: 1468002 ("Structurally dead code")Suggested-by Masahiro Yamada <[email protected]>Signed-off-by Gustavo A. R. Silva <[email protected]>
Thanks, applied for next and by fixing the minor spelling mistake in the changelog.
Kind regards
Uffe
Quoted 28 lines
---
Changes in v2:
- Update changelog.
- Drop the 'Fixes' tag.
- Add check on ret instead of removing the "return ret;" line.
- Thanks to Masahiro Yamada for the feedback provided.drivers/mmc/host/sdhci-cadence.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/mmc/host/sdhci-cadence.c +2
-3@@ -274,8 +274,8 @@ static int sdhci_cdns_set_tune_val(struct sdhci_host *host, unsigned int val) ret =readl_poll_timeout (reg, tmp, !(tmp &SDHCI_CDNS_HRS06_TUNE_UP ),0 ,1 ); - -return ret; +if (ret) +return ret; }return 0 ; --2.7.4