[PATCH] log2: make order_base_2() behave correctly on const input value zero

Linus Torvalds torvalds at linux-foundation.org
Thu Feb 2 12:49:05 PST 2017


On Thu, Feb 2, 2017 at 9:04 AM, Ard Biesheuvel
<ard.biesheuvel at linaro.org> wrote:
>
> So update order_base_2() to adhere to its own documented interface.

Ok, looks like you screwed up the types according to the build server.

Making the return type "unsigned long" is slightly excessive. If you
need an unsigned long to describe the log2 of a number in the kernel,
you're playing with numbers that are *way* too big.

The old code used "ilog2()", which returns an int.

Which is plenty big enough of a type.

                Linus



More information about the linux-arm-kernel mailing list