From: Peter Senna Tschudin Date: Tue, 29 Jul 2014 16:12:20 +0000 (+0200) Subject: cpupower: Remove redundant error check X-Git-Tag: v4.9.8~5866^2^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=059802f961db9717412b6958111ca1cd1865726e;p=platform%2Fkernel%2Flinux-rpi3.git 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: // @@ expression E; identifier pr; expression list es; @@ for(...;...;...){ ... - if (E) break; + if (E){ + pr(es); + break; + } ... } - if(E) pr(es); // Signed-off-by: Peter Senna Tschudin Signed-off-by: Thomas Renninger Signed-off-by: Rafael J. Wysocki --- 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; }