summaryrefslogtreecommitdiffstats
path: root/tools/include/linux/bitops.h
diff options
context:
space:
mode:
authorThorsten Blum <thorsten.blum@toblux.com>2024-04-21 00:38:37 +0200
committerArnd Bergmann <arnd@arndb.de>2024-05-03 17:04:50 +0200
commit9c313ccdfc079f71f16c9b3d3a6c6d60996b9367 (patch)
treef02cf54d4387467cf9f7b844afb2d62f7754c3dc /tools/include/linux/bitops.h
parente67572cd2204894179d89bd7b984072f19313b03 (diff)
downloadlinux-stable-9c313ccdfc079f71f16c9b3d3a6c6d60996b9367.tar.gz
linux-stable-9c313ccdfc079f71f16c9b3d3a6c6d60996b9367.tar.bz2
linux-stable-9c313ccdfc079f71f16c9b3d3a6c6d60996b9367.zip
bitops: Change function return types from long to int
Change the return types of bitops functions (ffs, fls, and fns) from long to int. The expected return values are in the range [0, 64], for which int is sufficient. Additionally, int aligns well with the return types of the corresponding __builtin_* functions, potentially reducing overall type conversions. Many of the existing bitops functions already return an int and don't need to be changed. The bitops functions in arch/ should be considered separately. Adjust some return variables to match the function return types. With GCC 13 and defconfig, these changes reduced the size of a test kernel image by 5,432 bytes on arm64 and by 248 bytes on riscv; there were no changes in size on x86_64, powerpc, or m68k. Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'tools/include/linux/bitops.h')
-rw-r--r--tools/include/linux/bitops.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/include/linux/bitops.h b/tools/include/linux/bitops.h
index 7319f6ced108..8e073a111d2a 100644
--- a/tools/include/linux/bitops.h
+++ b/tools/include/linux/bitops.h
@@ -70,7 +70,7 @@ static inline unsigned long hweight_long(unsigned long w)
return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
}
-static inline unsigned fls_long(unsigned long l)
+static inline unsigned int fls_long(unsigned long l)
{
if (sizeof(l) == 4)
return fls(l);