Re: [PATCH v4] coding-style: Clarify the expectations around bool
From: Jason Gunthorpe
Date: Mon Jan 14 2019 - 12:28:44 EST
On Sun, Jan 13, 2019 at 05:01:39PM +0100, Federico Vaga wrote:
> > -17) Don't re-invent the kernel macros
> > +17) Using bool
> > +--------------
> > +
> > +The Linux kernel bool type is an alias for the C99 _Bool type. bool
> > values can
> > +only evaluate to 0 or 1, and implicit or explicit conversion to bool
> > +automatically converts the value to true or false. When using bool
> > types the
> > +!! construction is not needed, which eliminates a class of bugs.
> > +
> > +When working with bool values the true and false definitions should be
> > used
> > +instead of 0 and 1.
>
> A very minor thing. I would suggest to keep consistent, in the
> statement, the mapping between definitions ("true and false [...]")
> and their correspondent integer values ("[...] instead of 1 and 0").
>
> In few words, I propose to change "0 and 1" into "1 and 0".
Hm, sure, seems harmless
> > +Similarly for function arguments, many true/false values can be
> > consolidated
> > +into a single bitwise 'flags' argument and 'flags' can often a more
> > readable
> > +alternative if the call-sites have naked true/false constants.
>
> Of course, English is not my primary language, but it looks to me
> that here a "be" is missing: "[...] and 'flags' can often a more
> readable alternative [...]".
yes, sthanks
> > +Otherwise limited use of bool in structures and arguments can improve
> > +readability.
>
> I'm going to update the Italian translations for this. Do you want
> me to contribute directly to this patch? Otherwise I will send a
> dedicated patch later when this one get accepted.
I think you should send it as an update I guess? I don't really know
the process for translations
Jason