Re: [PATCH trivial] include/linux/memblock.h: Clean up code for several trivial details
From: Chen Gang
Date: Mon May 30 2016 - 18:13:57 EST
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
[root@localhost linux]# grep -rn '!!' * | grep return | wc -l
except 11 files which use int instead of bool as return value:
> 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 "\<return\>" * | grep ' & ' | grep -v "==" | grep -v '||' | grep -v 'struct' | grep -v '!=' | grep -v ',' | grep -v '?' | grep -v '!' | grep -v '&&' | wc -l
After give a glance, more than 60% are not for bool functions (so I
guess about 100 area hint).
Chen Gang (éå)
Managing Natural Environments is the Duty of Human Beings.