Skip to content
Commit 6270f4de authored by Kees Cook's avatar Kees Cook
Browse files

string.h: Use ARRAY_SIZE() for memtostr*()/strtomem*()



The destination argument of memtostr*() and strtomem*() must be a
fixed-size char array at compile time, so there is no need to use
__builtin_object_size() (which is useful for when an argument is
either a pointer or unknown). Instead use ARRAY_SIZE(), which has the
benefit of working around a bug in Clang (fixed[1] in 15+) that got
__builtin_object_size() wrong sometimes.

Reported-by: default avatarkernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202501310832.kiAeOt2z-lkp@intel.com/


Suggested-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
Link: https://github.com/llvm/llvm-project/commit/d8e0a6d5e9dd2311641f9a8a5d2bf90829951ddc

 [1]
Tested-by: default avatarSuren Baghdasaryan <surenb@google.com>
Signed-off-by: default avatarKees Cook <kees@kernel.org>
parent 20e5cc26
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment