[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <78612e21-de54-4bd2-c22f-1c67aed29b2e@redhat.com>
Date: Fri, 2 Aug 2019 09:23:14 +0200
From: David Hildenbrand <david@...hat.com>
To: Leonardo Bras <leonardo@...ux.ibm.com>,
linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org
Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Michael Ellerman <mpe@...erman.id.au>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
Nathan Fontenot <nfont@...ux.vnet.ibm.com>,
YueHaibing <yuehaibing@...wei.com>,
Thomas Gleixner <tglx@...utronix.de>,
Mahesh Salgaonkar <mahesh@...ux.vnet.ibm.com>,
Rob Herring <robh@...nel.org>
Subject: Re: [PATCH 1/1] pseries/hotplug-memory.c: Change rc variable to bool
On 02.08.19 09:18, David Hildenbrand wrote:
> 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@...ux.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.
BTW, including such subtle changes in a "Change rc variable to bool"
patch should be avoided.
--
Thanks,
David / dhildenb
Powered by blists - more mailing lists