Re: [PATCH trivial] include/linux/mempolicy.h: Clean up code
From: Alexey Dobriyan
Date: Fri Jun 10 2016 - 08:24:32 EST
On Fri, Jun 10, 2016 at 3:23 PM, Alexey Dobriyan <adobriyan@xxxxxxxxx> 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?