From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-pm@vger.kernel.org, Shuah Khan <shuah@kernel.org>,
Thomas Renninger <trenn@suse.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] cpupower: Combine two condition checks into one statement in get_cpu_topology()
Date: Mon, 20 Nov 2017 19:19:39 +0100 [thread overview]
Message-ID: <3daea226-c5cb-62e7-a025-8f758712a81a@users.sourceforge.net> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 20 Nov 2017 19:10:14 +0100
The same assignments were used in an if branch of two separate statements.
* Merge their condition checks into a single statement instead.
* Adjust the indentation there.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
tools/power/cpupower/lib/cpupower.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/tools/power/cpupower/lib/cpupower.c b/tools/power/cpupower/lib/cpupower.c
index 9c395ec924de..81c828e5920e 100644
--- a/tools/power/cpupower/lib/cpupower.c
+++ b/tools/power/cpupower/lib/cpupower.c
@@ -140,18 +140,12 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)
for (cpu = 0; cpu < cpus; cpu++) {
cpu_top->core_info[cpu].cpu = cpu;
cpu_top->core_info[cpu].is_online = cpupower_is_cpu_online(cpu);
- if(sysfs_topology_read_file(
- cpu,
- "physical_package_id",
- &(cpu_top->core_info[cpu].pkg)) < 0) {
- cpu_top->core_info[cpu].pkg = -1;
- cpu_top->core_info[cpu].core = -1;
- continue;
- }
- if(sysfs_topology_read_file(
- cpu,
- "core_id",
- &(cpu_top->core_info[cpu].core)) < 0) {
+ if (sysfs_topology_read_file(cpu, "physical_package_id",
+ &(cpu_top->core_info[cpu].pkg))
+ < 0 ||
+ sysfs_topology_read_file(cpu, "core_id",
+ &(cpu_top->core_info[cpu].core))
+ < 0) {
cpu_top->core_info[cpu].pkg = -1;
cpu_top->core_info[cpu].core = -1;
continue;
--
2.15.0
next reply other threads:[~2017-11-20 18:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-20 18:19 SF Markus Elfring [this message]
2017-11-21 19:47 ` [PATCH] cpupower: Combine two condition checks into one statement in get_cpu_topology() Shuah Khan
2017-11-21 20:37 ` SF Markus Elfring
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=3daea226-c5cb-62e7-a025-8f758712a81a@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=trenn@suse.com \
/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;
as well as URLs for NNTP newsgroup(s).