linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: chengang@emindsoft.com.cn
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH trivial] include/linux/mempolicy.h: Clean up code
Date: Fri, 10 Jun 2016 15:24:21 +0300	[thread overview]
Message-ID: <CACVxJT_kA04OY3W=VxX2-z7_2E7VJ0Nwkk=8uG3iBTT66sD-NQ@mail.gmail.com> (raw)
In-Reply-To: <CACVxJT9DUrU+tEOg5nkpoo6d_LaAtUOLqzz_q=7AEsiarwnKjw@mail.gmail.com>

On Fri, Jun 10, 2016 at 3:23 PM, Alexey Dobriyan <adobriyan@gmail.com> wrote:
>> Use one return statement instead of multiple statements,
>> since the new return statement is still simple enough.
>
> Multiple statements are very readable exactly
> because one doesn't need to think of negations etc.
>
>> static inline bool mpol_equal(struct mempolicy *a, struct mempolicy *b)
>>  {
>> - if (a == b)
>> - return true;
>> - return __mpol_equal(a, b);
>> + return (a == b) || __mpol_equal(a, b);
>>  }
>
>
>
>>  struct mempolicy *__get_vma_policy(struct vm_area_struct *vma,
>> - unsigned long addr);
>> + unsigned long addr);
>
> For prototypes "one line per prototype, no extern" policy should be adopted.
>
>> - if (vma->vm_file &&
>> + return !(vma->vm_file &&
>>   gfp_zone(mapping_gfp_mask(vma->vm_file->f_mapping))
>> - < policy_zone)
>> - return false;
>> - return true;
>> + < policy_zone);
>
> If you align gfp_zone() call to "if (" then second test
> would even fit into one line!
>
> Who told you that shoving everything into one expression
> makes it easier to understand?

       reply	other threads:[~2016-06-10 12:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CACVxJT9DUrU+tEOg5nkpoo6d_LaAtUOLqzz_q=7AEsiarwnKjw@mail.gmail.com>
2016-06-10 12:24 ` Alexey Dobriyan [this message]
2016-06-10  4:46 [PATCH trivial] include/linux/mempolicy.h: Clean up code chengang

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='CACVxJT_kA04OY3W=VxX2-z7_2E7VJ0Nwkk=8uG3iBTT66sD-NQ@mail.gmail.com' \
    --to=adobriyan@gmail.com \
    --cc=chengang@emindsoft.com.cn \
    --cc=linux-kernel@vger.kernel.org \
    /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).