From patchwork Mon Nov 20 18:19:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 10066873 X-Patchwork-Delegate: shuah@kernel.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 01A076038F for ; Mon, 20 Nov 2017 18:20:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBC7928CFB for ; Mon, 20 Nov 2017 18:20:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF21F28D8B; Mon, 20 Nov 2017 18:20:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CF9428CFB for ; Mon, 20 Nov 2017 18:20:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752015AbdKTSTw (ORCPT ); Mon, 20 Nov 2017 13:19:52 -0500 Received: from mout.web.de ([212.227.15.3]:59429 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751871AbdKTSTv (ORCPT ); Mon, 20 Nov 2017 13:19:51 -0500 Received: from [192.168.1.3] ([77.181.220.221]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LnBD3-1eomMy23NF-00hJue; Mon, 20 Nov 2017 19:19:41 +0100 To: linux-pm@vger.kernel.org, Shuah Khan , Thomas Renninger Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Subject: [PATCH] cpupower: Combine two condition checks into one statement in get_cpu_topology() Message-ID: <3daea226-c5cb-62e7-a025-8f758712a81a@users.sourceforge.net> Date: Mon, 20 Nov 2017 19:19:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:8nPe2jG771NtpJqHSi0ZceNxlzDnv+uVdPI3jNIisWRIfw8Z9iD cVqta0wJ722wBM67W7PgjGK7ZP3S9YRSRqQaIDeRHC6NsrZey4k7ivK2/i4dZ4EhRjkdHSP +XYgp0q+oD+fg2v6pCYJvziYwfnOsDho+taeR0jGYJIlS4pMQM/DM5rKdjekrRptL82RAjz 0NWxPTY8HjBTe3rxUt1FA== X-UI-Out-Filterresults: notjunk:1; V01:K0:Mtavy2WxhvY=:uq6czo8PVyNvEp0SzzAMcm dLFgy2sXt4MJ0wrSpwmnEwEnvobNW7jF9EB+PcFFNCbeH3ISPUaQUdo7bDMv+84glViL5XCUn CnlK9sIjYO/ftEC/dJ8cbCM8gPqrLLc1FfC6ZRLpQAVSI0KcX2HBLvpBWUaqKUG+REr+AxbFw BmD0FOEH4gZ91LMpuTGJYPmcjiDPUKk2mMC7L4mRQnUEpqR00OFkFHc92KhS9KIaVmyfPNDqS mwJBfiEj67v4Sc7G5OdOVec4sloJ56i8B0mOAT+o0GM04tPbHWXGS3nXw62Wtnq7Z+glV15RD B0D722TjKCzxUJFMVSyu1RFRbNMuKbIRjy8YZ1zij94EUp6rjNQklsYDYUN4+ufVLVjwF4GdC fs+BRFq4OqwbRFbSPOohQor/5K83PaHeVKYdhlvu/WVZQLIWigRqo+54v2Nf3koN0BEKXLju4 aC3kqWC8IC6ikLM/CZOJYlh+YmuViQbaVfQFFWkiZgQYZcy/80mb42K0NSK9BTmbn/58E8iJN rPyBpdcQbHKvmqiGJsRhf9m4bgLaQVJPwLD8d9nXU9yOweUFEmTRzfh3cfJjs+7IUByd3wP6o /B6SgGJA/gilwZhLjM7o5gBYegRySHYwtC9oPAlAQwQb86ezbgcERqNq+NX72xUetZlbDi176 /Bco9PNc20SKscEbd0TjGL3Ut+tMtjeoISvoT7+zXOC+QvubIWWWKv7dNRFzM744hnI8h/Cov f0po4sQ2DBasymVXH+XRUqQJFyyphpo+Y+4FyBf02pcjTWs1wwdAdewJ7HhTPTuWHeO4S07p2 14YH436L7zfYarDzDTRDjVMuEWqAHcpHAb/zc05FU9XKdVWYCw= Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring 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 --- 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;