From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161984AbcE3WNy (ORCPT ); Mon, 30 May 2016 18:13:54 -0400 Received: from out1134-233.mail.aliyun.com ([42.120.134.233]:23142 "EHLO out1134-233.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752176AbcE3WNw (ORCPT ); Mon, 30 May 2016 18:13:52 -0400 X-Greylist: delayed 303 seconds by postgrey-1.27 at vger.kernel.org; Mon, 30 May 2016 18:13:51 EDT X-Alimail-AntiSpam: AC=CONTINUE;BC=0.0778191|-1;FP=0|0|0|0|0|-1|-1|-1;HT=e02c03305;MF=chengang@emindsoft.com.cn;NM=1;PH=DS;RN=12;RT=12;SR=0;TI=SMTPD_----4s7G15u_1464646113; Message-ID: <574CBB3F.8020301@emindsoft.com.cn> Date: Tue, 31 May 2016 06:14:23 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Joe Perches , akpm@linux-foundation.org, trivial@kernel.org CC: kuleshovmail@gmail.com, tony.luck@intel.com, tangchen@cn.fujitsu.com, will.deacon@arm.com, holt@sgi.com, ard.biesheuvel@linaro.org, kirill.shutemov@linux.intel.com, linux-kernel@vger.kernel.org, Chen Gang Subject: Re: [PATCH trivial] include/linux/memblock.h: Clean up code for several trivial details References: <1464532567-6353-1-git-send-email-chengang@emindsoft.com.cn> <1464534527.14627.9.camel@perches.com> <574C4C4F.8080609@emindsoft.com.cn> <1464618832.14627.23.camel@perches.com> In-Reply-To: <1464618832.14627.23.camel@perches.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/30/16 22:33, Joe Perches wrote: > On Mon, 2016-05-30 at 22:21 +0800, Chen Gang wrote: >> On 5/29/16 23:08, Joe Perches wrote: >>> These !! uses are't necessary. >>> The compiler makes the bool return 0 or 1. >> No, they are not necessary. But for me, it will be more clearer, since >> in our kernel (at least in include/linux/), almost all Boolean functions >> use Boolean value or expression for return (and "!!" are often used). > > Opinions vary. > OK, thanks. I shall send patch v2 for it within this week. > There seem to be fewer than 20 !! uses in bool return > functions in include/linux/ > [root@localhost linux]# pwd /upstream/linux-next/include/linux [root@localhost linux]# grep -rn '!!' * | grep return | wc -l 32 [root@localhost linux]# except 11 files which use int instead of bool as return value: ide.h:854 mlx4/driver.h:76 mlx5/device.h:744 mmzone.h:793 mtd/mtd.h:412 nilfs2_fs.h:568 nilfs2_fs.h:602 nilfs2_fs.h:667 nilfs2_fs.h:771 page-flags.h:711 pagemap.h:54 > Finding the quantity of bool conversions in include/linux > from something other than 0, 1, true, or false to 0 or 1 > is not trivial, but it is non-zero and seems rather more > than 20. > [root@localhost linux]# grep -rn "\" * | grep ' & ' | grep -v "==" | grep -v '||' | grep -v 'struct' | grep -v '!=' | grep -v ',' | grep -v '?' | grep -v '!' | grep -v '&&' | wc -l 259 After give a glance, more than 60% are not for bool functions (so I guess about 100 area hint). Thanks -- Chen Gang (陈刚) Managing Natural Environments is the Duty of Human Beings.