compiler_types: add Endianness-dependent __counted_by_{le,be}
authorAlexander Lobakin <aleksander.lobakin@intel.com>
Wed, 27 Mar 2024 14:22:39 +0000 (15:22 +0100)
committerJakub Kicinski <kuba@kernel.org>
Fri, 29 Mar 2024 01:50:47 +0000 (18:50 -0700)
commitca7e324e8ad385a2da15049953c04ea7310687f7
treecebfe830c0eabe5ac3d900dba2e78149be16cfe7
parent6e9b01909a811555ff3326cf80a5847169c57806
compiler_types: add Endianness-dependent __counted_by_{le,be}

Some structures contain flexible arrays at the end and the counter for
them, but the counter has explicit Endianness and thus __counted_by()
can't be used directly.

To increase test coverage for potential problems without breaking
anything, introduce __counted_by_{le,be}() defined depending on
platform's Endianness to either __counted_by() when applicable or noop
otherwise.
Maybe it would be a good idea to introduce such attributes on compiler
level if possible, but for now let's stop on what we have.

Acked-by: Kees Cook <keescook@chromium.org>
Acked-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Link: https://lore.kernel.org/r/20240327142241.1745989-2-aleksander.lobakin@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Documentation/conf.py
include/linux/compiler_types.h
scripts/kernel-doc