RE: [greybus-dev] [PATCH] staging: greybus: fixed the coding style, labels should not be indented.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Alex Elder
> Sent: 03 June 2021 22:55
...
> Not necessarily, sizeof(bool) is implementation defined.
> And I thought you didn't think the size of the structure
> was very important...

It is 'implementation defined' but will be 32 bits on everything
except an old 32bit ARM ABI.

> In any case, I'm open to changing the type of these fields,
> and my preference would be bool rather than u8, because it
> is completely clear what it represents.

Yes, and it isn't at all clear what it actually means.
If the value of a bool memory location isn't 0 or 1
what does 'bool_a & bool_b' mean.
It might be 'undefined behaviour' - but that doesn't actually
exclude an ICBM hitting the coder's house!
I've seen very silly code generated (by an old gcc) for
simple statements like:
	bool_a |= bool_b;
Mostly because it didn't trust the values to be 0 or 1
and wanted to ensure the result was either 0 or 1.

If I use an integer type (as in traditional C) I know
what I'm getting and there are no unexpected comparisons
and conditionals.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)




[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux