svn commit: r295523 - head/sys/fs/ext2fs

Pedro Giffuni pfg at FreeBSD.org
Thu Feb 11 19:01:31 UTC 2016



On 02/11/16 11:54, Bruce Evans wrote:
> On Thu, 11 Feb 2016, Pedro F. Giffuni wrote:
>
>> Log:
>>  Ext4: Use boolean type instead of '0' and '1'
>>
>>  There are precedents of uses of bool in the kernel and
>>  it is incorrect style to use integers as replacement for
>>  a boolean type.
>
> This is all backwards.
>
> It is correct style to use integers to represent booleans.
>

We had this same discussion for ddb.
You didn't agree there either though.


> There are precedents for breaking this style by using the
> bool type, but not many in fs code:
>

This line of code (from ext2_bmap.c):

  if (path.ep_is_sparse)

is correct only of ep_is_sparse is boolean. If it is an int
it has to be rewritten as:

  if (path.ep_is_sparse != 0)

I chose to keep it boolean.

> In all of /sys/fs/*, there were just 12 lines of declarations
> that use 'bool'.  All of these were in autofs.  Now there are
> 13 such lines (1 more in ext2fs).  1 use is especially useless
> and especially unlikely to be all uses of booleans.
>

The age of the code matters. Ext2 has a lot of code copy/pasted
from UFS and it is useful to keep it similar.
The ext4 code is new, I don't expect to maintain the exact style
unless it's documented as part of style(9).

Pedro.


More information about the svn-src-head mailing list