Skip to content

Commit

Permalink
cpupower: Remove redundant error check
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Thomas Renninger <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
petersenna authored and rafaeljw committed Jul 29, 2014
1 parent 13f6de5 commit 059802f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tools/power/cpupower/utils/cpufreq-set.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 059802f

Please sign in to comment.