From: Thomas Renninger <trenn@suse.de>
To: rjw@rjwysocki.net
Cc: linux-pm@vger.kernel.org,
Peter Senna Tschudin <peter.senna@gmail.com>,
Thomas Renninger <trenn@suse.de>
Subject: [PATCH 3/3] cpupower: Remove redundant error check
Date: Tue, 29 Jul 2014 18:12:20 +0200 [thread overview]
Message-ID: <1406650340-38644-3-git-send-email-trenn@suse.de> (raw)
In-Reply-To: <1406650340-38644-1-git-send-email-trenn@suse.de>
From: Peter Senna Tschudin <peter.senna@gmail.com>
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>
Signed-off-by: Thomas Renninger <trenn@suse.de>
---
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 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;
}
--
1.7.6.1
next prev parent reply other threads:[~2014-07-29 16:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-22 14:05 [PATCH 0/4] tools/power/cpupower latest fixes Thomas Renninger
2014-07-22 14:05 ` [PATCH 1/4] cpupower: mperf monitor: Correct use of ! and & Thomas Renninger
2014-07-22 14:05 ` [PATCH 2/4] tools: power: cpupower: bench: parse.c: Fix several minor errors Thomas Renninger
2014-07-22 14:06 ` [PATCH 3/4] cpupower: Remove redundant error check Thomas Renninger
2014-07-22 14:06 ` [PATCH 4/4] cpupower: Adjust MAINTAINERS file Thomas Renninger
2014-07-22 23:53 ` [PATCH 0/4] tools/power/cpupower latest fixes Rafael J. Wysocki
2014-07-29 16:12 ` [PATCH 1/3] cpupower: mperf monitor: Correct use of ! and & Thomas Renninger
2014-07-29 16:12 ` [PATCH 2/3] tools: power: cpupower: bench: parse.c: Fix several minor errors Thomas Renninger
2014-07-29 16:12 ` Thomas Renninger [this message]
2014-07-30 0:28 ` [PATCH 1/3] cpupower: mperf monitor: Correct use of ! and & Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1406650340-38644-3-git-send-email-trenn@suse.de \
--to=trenn@suse.de \
--cc=linux-pm@vger.kernel.org \
--cc=peter.senna@gmail.com \
--cc=rjw@rjwysocki.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox