[coreboot] RFC: coding style: "standard" defines

Vadim Bendebury vbendeb at chromium.org
Thu Feb 4 23:19:04 CET 2016


On Thu, Feb 4, 2016 at 2:00 PM, Nico Huber <nico.h at gmx.de> wrote:
> On 04.02.2016 22:25, Patrick Georgi via coreboot wrote:
>> 2016-02-04 22:22 GMT+01:00 Martin Roth <gaumless at gmail.com>:
>>> I don't think we need redefinitions of TRUE/FALSE
>> We have no canonical definitions for TRUE/FALSE right now.
>> Contributions that use them (for whatever reason) tend to bring local
>> copies, and that's what I'd like to avoid.
> I don't like true/false definitions neither. If we have contributions
> which bring them, well, we should factor it out during review.
>
> Arguments against true/false definitions? It's C! As we know, in C,
> everything but 0 is naturally true. While redefining true/false seems
> to enhance readability, it breaks with this principle. That might not
> be a problem if you write new code---you usually know how you want to
> interpret true then. However if you just read code you might find a
> condition like
>   if (something == true)

This of course brings another style point/suggestion: Boolean checks
should never involve comparing, it should be

if (something){}

or

if (!something){}

--vb


> So, I expect that this comparison is done in terms of the type of
> `something` (and is only "true" if `something` evaluates to 1). Is it
> like that? Well, I'm pretty sure it is. But having to think about it
> is already too much IMO.
>
> Nico
>
> --
> coreboot mailing list: coreboot at coreboot.org
> http://www.coreboot.org/mailman/listinfo/coreboot



More information about the coreboot mailing list