OSDN Git Service

fls: change parameter to unsigned int
authorMatthew Wilcox <willy@infradead.org>
Thu, 3 Jan 2019 23:26:41 +0000 (15:26 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 4 Jan 2019 21:13:46 +0000 (13:13 -0800)
commit3fc2579e6f162fcff964f5aa01c8a29438ca5c05
treea90c733a19c07e111d9195181d1f3a37e92ef0eb
parente6310f0fb5cd3f65244dbdef2fb264859891c7ec
fls: change parameter to unsigned int

When testing in userspace, UBSAN pointed out that shifting into the sign
bit is undefined behaviour.  It doesn't really make sense to ask for the
highest set bit of a negative value, so just turn the argument type into
an unsigned int.

Some architectures (eg ppc) already had it declared as an unsigned int,
so I don't expect too many problems.

Link: http://lkml.kernel.org/r/20181105221117.31828-1-willy@infradead.org
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
16 files changed:
arch/alpha/include/asm/bitops.h
arch/arc/include/asm/bitops.h
arch/c6x/include/asm/bitops.h
arch/csky/include/asm/bitops.h
arch/hexagon/include/asm/bitops.h
arch/ia64/include/asm/bitops.h
arch/m68k/include/asm/bitops.h
arch/mips/include/asm/bitops.h
arch/openrisc/include/asm/bitops/fls.h
arch/parisc/include/asm/bitops.h
arch/s390/include/asm/bitops.h
arch/unicore32/include/asm/bitops.h
arch/x86/include/asm/bitops.h
include/asm-generic/bitops/builtin-fls.h
include/asm-generic/bitops/fls.h
tools/include/asm-generic/bitops/fls.h