Re: [PATCH] sched/deadline: Use bools for the state flags

From: Linus Torvalds
Date: Tue Nov 21 2017 - 10:53:54 EST


On Tue, Nov 21, 2017 at 1:43 AM, Jiri Kosina <jikos@xxxxxxxxxx> wrote:
>
> Surely that works as well. I chose bool as that's in line with the actual
> semantics, but I can of course resend with unsigned type if that's
> preferred for one reason or another.

As others have already said, please don't use "bool" in structures at
all. It's an incredible waste of space, but it's also not entirely
clear what the type size even is. Usually a byte, but I don't think
there is any guarantee of it at all.

Use "bool" mainly as a return type from functions that return
true/false, and maybe as local variables in functions.

Maybe using single-bit bitfield with "bool" as the base type might
work, but the normal thing we tend to do is to just make sure the base
type is unsigned. It's a tiny bit more typing, but it's very
unambiguous what is going on, and you can specify the base type as you
wish and as it makes sense for packing etc.

Linus