From: David Hildenbrand <david@redhat.com>
To: Leonardo Bras <leonardo@linux.ibm.com>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Cc: Rob Herring <robh@kernel.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
YueHaibing <yuehaibing@huawei.com>,
Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>,
Paul Mackerras <paulus@samba.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Nathan Fontenot <nfont@linux.vnet.ibm.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 1/1] pseries/hotplug-memory.c: Change rc variable to bool
Date: Fri, 2 Aug 2019 09:18:47 +0200 [thread overview]
Message-ID: <69821502-a449-d1a8-c2e8-a1aa67cca02f@redhat.com> (raw)
In-Reply-To: <20190801231055.19603-1-leonardo@linux.ibm.com>
On 02.08.19 01:10, Leonardo Bras wrote:
> Changes the return variable to bool (as the return value) and
> avoids doing a ternary operation before returning.
>
> Also, since rc will always be true, there is no need to do
> rc &= bool, as (true && X) will result in X.
>
> Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
> ---
> arch/powerpc/platforms/pseries/hotplug-memory.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
> index 8e700390f3d6..392deb4855e5 100644
> --- a/arch/powerpc/platforms/pseries/hotplug-memory.c
> +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
> @@ -338,7 +338,7 @@ static int pseries_remove_mem_node(struct device_node *np)
> static bool lmb_is_removable(struct drmem_lmb *lmb)
> {
> int i, scns_per_block;
> - int rc = 1;
> + bool rc = true;
> unsigned long pfn, block_sz;
> u64 phys_addr;
>
> @@ -363,11 +363,11 @@ static bool lmb_is_removable(struct drmem_lmb *lmb)
> if (!pfn_present(pfn))
> continue;
>
> - rc &= is_mem_section_removable(pfn, PAGES_PER_SECTION);
> + rc = is_mem_section_removable(pfn, PAGES_PER_SECTION);
No, that's wrong.
If is_mem_section_removable() is false in the first iteration but true
in the last iteration, you would return true instead of false, which
introduced a bug. We have to AND all sub-results, not simply use the
last one.
> phys_addr += MIN_MEMORY_BLOCK_SIZE;
> }
>
> - return rc ? true : false;
> + return rc;
> }
>
> static int dlpar_add_lmb(struct drmem_lmb *);
>
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2019-08-02 7:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-01 23:10 [PATCH 1/1] pseries/hotplug-memory.c: Change rc variable to bool Leonardo Bras
2019-08-02 7:18 ` David Hildenbrand [this message]
2019-08-02 7:23 ` David Hildenbrand
2019-08-02 13:48 ` Leonardo Bras
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=69821502-a449-d1a8-c2e8-a1aa67cca02f@redhat.com \
--to=david@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=leonardo@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mahesh@linux.vnet.ibm.com \
--cc=nfont@linux.vnet.ibm.com \
--cc=paulus@samba.org \
--cc=rafael.j.wysocki@intel.com \
--cc=robh@kernel.org \
--cc=tglx@linutronix.de \
--cc=yuehaibing@huawei.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).