From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753436AbcFJMY3 (ORCPT ); Fri, 10 Jun 2016 08:24:29 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35921 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751899AbcFJMY2 (ORCPT ); Fri, 10 Jun 2016 08:24:28 -0400 MIME-Version: 1.0 In-Reply-To: References: From: Alexey Dobriyan Date: Fri, 10 Jun 2016 15:24:21 +0300 Message-ID: Subject: Re: [PATCH trivial] include/linux/mempolicy.h: Clean up code To: chengang@emindsoft.com.cn Cc: Linux Kernel Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 10, 2016 at 3:23 PM, Alexey Dobriyan 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?