* [PATCH 2/4 V2] cpupower: Remove redundant error check
@ 2014-05-17 22:14 Peter Senna Tschudin
0 siblings, 0 replies; only message in thread
From: Peter Senna Tschudin @ 2014-05-17 22:14 UTC (permalink / raw)
To: Dominik Brodowski
Cc: Peter Senna Tschudin, Thomas Renninger, linux-kernel,
Rafael J. Wysocki, Alan Cox, kernel-janitors, dan.carpenter
Remove double checks, and move the call to print_error to the
first check. Replace break by return, and return 0 on success.
The simplified version of the coccinelle semantic patch that
fixes this issue is as follows:
// <smpl>
@@
expression E; identifier pr; expression list es;
@@
for(...;...;...){
...
- if (E) break;
+ if (E){
+ pr(es);
+ break;
+ }
...
}
- if(E) pr(es);
// </smpl>
Untested.
Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
---
Changes from V1:
- Replaced break with a return
- Return 0 instead of ret on success
tools/power/cpupower/utils/cpufreq-set.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/tools/power/cpupower/utils/cpufreq-set.c b/tools/power/cpupower/utils/cpufreq-set.c
index a416de8..f656e58 100644
--- a/tools/power/cpupower/utils/cpufreq-set.c
+++ b/tools/power/cpupower/utils/cpufreq-set.c
@@ -320,12 +320,11 @@ int cmd_freq_set(int argc, char **argv)
printf(_("Setting cpu: %d\n"), cpu);
ret = do_one_cpu(cpu, &new_pol, freq, policychange);
- if (ret)
- break;
+ if (ret) {
+ print_error();
+ return ret;
+ }
}
- if (ret)
- print_error();
-
- return ret;
+ return 0;
}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-05-17 22:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-17 22:14 [PATCH 2/4 V2] cpupower: Remove redundant error check Peter Senna Tschudin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox