diff options
| author | Niklas Cassel <cassel@kernel.org> | 2025-12-01 13:35:03 +0100 |
|---|---|---|
| committer | Niklas Cassel <cassel@kernel.org> | 2025-12-02 11:17:56 +0100 |
| commit | a42b71d49945aac0b943987cbdec1d1c805caab3 (patch) | |
| tree | 7163d289685a54b6226d1528341ba0223a360c0d /samples/rust/rust_i2c_client.rs | |
| parent | 6ce0dd9f54ea9773c0aedfaab7b858fc68a848ba (diff) | |
ata: libata: Move quirk flags to their own enum
The anonymous enum in include/linux/libata.h that is used to store
various global constants can currently be backed by type int.
(It contains both negative and positive constants.)
__ATA_QUIRK_MAX is currently 31.
The quirk flags in the various global constants enum are defined as
"1U << quirk_flag_bit".
Thus if we simply add an additional quirk, the quirk flag will be 1 << 31,
which is a value that is too large to be represented by a signed int.
The various global constants enum will thus therefore be backed by type
long.
This will lead to error prints like e.g.:
ata_port_err(ap, "EH pending after %d tries, giving up\n",
ATA_EH_MAX_TRIES);
now failing to build, with build error:
error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long int’ [-Werror=format=]
This is because all constants in the various global constants enum now
has to be printed as a long, as that is now the backing type of the enum.
Since the compiler will use the smallest possible backing type for an
enum, it is good practice to not mix unrelated things in a single enum.
Move the quirk flags to a separate enum, so that we don't need to change
the printf specifier for all other constants in the "various global
constants" enum when adding an additional quirk.
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Niklas Cassel <cassel@kernel.org>
Diffstat (limited to 'samples/rust/rust_i2c_client.rs')
0 files changed, 0 insertions, 0 deletions
