diff options
author | Peter Senna Tschudin <peter.senna@gmail.com> | 2014-07-29 12:12:20 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-07-29 19:57:13 -0400 |
commit | 059802f961db9717412b6958111ca1cd1865726e (patch) | |
tree | d5cdc976411b8e08f853fd88516b06f55c5957be /tools | |
parent | 13f6de52b149c030b0d529a3d8d68267ed20f01c (diff) |
cpupower: Remove redundant error check
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>
Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/power/cpupower/utils/cpufreq-set.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/tools/power/cpupower/utils/cpufreq-set.c b/tools/power/cpupower/utils/cpufreq-set.c index a416de80c55e..f656e585ed45 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) | |||
320 | 320 | ||
321 | printf(_("Setting cpu: %d\n"), cpu); | 321 | printf(_("Setting cpu: %d\n"), cpu); |
322 | ret = do_one_cpu(cpu, &new_pol, freq, policychange); | 322 | ret = do_one_cpu(cpu, &new_pol, freq, policychange); |
323 | if (ret) | 323 | if (ret) { |
324 | break; | 324 | print_error(); |
325 | return ret; | ||
326 | } | ||
325 | } | 327 | } |
326 | 328 | ||
327 | if (ret) | 329 | return 0; |
328 | print_error(); | ||
329 | |||
330 | return ret; | ||
331 | } | 330 | } |