From: Gavin Shan <gwshan@linux.vnet.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: Gavin Shan <gwshan@linux.vnet.ibm.com>, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 1/3] powerpc/kernel: Remove nested if statements in rtas_initialize()
Date: Tue, 24 Jan 2017 09:26:27 +1100 [thread overview]
Message-ID: <20170123222627.GA4316@gwshan> (raw)
In-Reply-To: <8760l6b0u3.fsf@concordia.ellerman.id.au>
On Mon, Jan 23, 2017 at 08:08:20PM +1100, Michael Ellerman wrote:
>Gavin Shan <gwshan@linux.vnet.ibm.com> writes:
>
>> This removes the unnecessary nested if statements in function
>> rtas_initialize(), to simplify the code. No functional changes
>> introduced.
>>
>> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
>> ---
>> arch/powerpc/kernel/rtas.c | 33 ++++++++++++++++-----------------
>> 1 file changed, 16 insertions(+), 17 deletions(-)
>>
>> diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
>> index 112cc3b..9ba0f67 100644
>> --- a/arch/powerpc/kernel/rtas.c
>> +++ b/arch/powerpc/kernel/rtas.c
>> @@ -1145,31 +1145,30 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
>> void __init rtas_initialize(void)
>> {
>> unsigned long rtas_region = RTAS_INSTANTIATE_MAX;
>> + const __be32 *basep, *entryp, *sizep;
>>
>> /* Get RTAS dev node and fill up our "rtas" structure with infos
>> * about it.
>> */
>> rtas.dev = of_find_node_by_name(NULL, "rtas");
>> - if (rtas.dev) {
>> - const __be32 *basep, *entryp, *sizep;
>> -
>> - basep = of_get_property(rtas.dev, "linux,rtas-base", NULL);
>> - sizep = of_get_property(rtas.dev, "rtas-size", NULL);
>> - if (basep != NULL && sizep != NULL) {
> ...
>> - } else
>
>Previously we set rtas.dev to NULL if either basep or sizep was NULL.
>
>> - rtas.dev = NULL;
>> - }
>> if (!rtas.dev)
>> return;
>>
>> + basep = of_get_property(rtas.dev, "linux,rtas-base", NULL);
>> + sizep = of_get_property(rtas.dev, "rtas-size", NULL);
>> + if (basep == NULL && sizep == NULL) {
>
>But now you set it to NULL only if BOTH basep and sizep are NULL.
>
>Was that intentional? If so you need to mention it in the change log.
>
>> + rtas.dev = NULL;
>> + return;
>> + }
>
>The proper negation of:
>
> if (basep != NULL && sizep != NULL) {
>is:
> if (basep == NULL || sizep == NULL) {
>
Thanks, Michael. It's not intentional. I'll update in v2.
Thanks,
Gavin
next prev parent reply other threads:[~2017-01-23 22:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-22 23:25 [PATCH 0/3] powerpc/kernel: Simplify rtas_initialize() Gavin Shan
2017-01-22 23:25 ` [PATCH 1/3] powerpc/kernel: Remove nested if statements in rtas_initialize() Gavin Shan
2017-01-23 9:08 ` Michael Ellerman
2017-01-23 22:26 ` Gavin Shan [this message]
2017-01-22 23:25 ` [PATCH 2/3] powerpc/kernel: Use of_property_read_u32() " Gavin Shan
2017-01-22 23:25 ` [PATCH 3/3] powerpc/kernel: Fix unbalanced refcount on RTAS device node Gavin Shan
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=20170123222627.GA4316@gwshan \
--to=gwshan@linux.vnet.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
/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).