]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ata: libata: Move quirk flags to their own enum
authorNiklas Cassel <cassel@kernel.org>
Mon, 1 Dec 2025 12:35:03 +0000 (13:35 +0100)
committerNiklas Cassel <cassel@kernel.org>
Tue, 2 Dec 2025 10:17:56 +0000 (11:17 +0100)
commita42b71d49945aac0b943987cbdec1d1c805caab3
tree7163d289685a54b6226d1528341ba0223a360c0d
parent6ce0dd9f54ea9773c0aedfaab7b858fc68a848ba
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>
include/linux/libata.h