RE: [PATCH v2 01/12] regmap-irq: Convert bool bitfields to unsigned int
From: David Laight
Date: Fri Jun 24 2022 - 10:29:05 EST
From: Joe Perches
> Sent: 24 June 2022 14:45
...
> I'm trying to show that conversions of bool:1->unsigned int:1
> as being trivial are not so trivial after all.
>
> It's fairly common to have code like:
>
> [bool] foo.bar = some_value & SETTING;
>
> where some value is tested for a mask/bit and a non-zero is true.
>
> So conversions of foo.bar from bool:1 to unsigned int:1 are not
> wise unless all possible side effects are known.
I can never decide whether:
bool_c = bool_a & bool_b;
can be compiled to a simple 'and' instruction, or requires a
load of instructions in case bool_a and/or bool_b has a non-zero
value without the bottom bit set.
All other C types are cpu register types - so you know what happens.
IMHO bool is an abomination and should not be used :-)
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)