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

From: Ard Biesheuvel
Date: Thu Feb 02 2017 - 15:52:43 EST



> On 2 Feb 2017, at 20:49, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Thu, Feb 2, 2017 at 9:04 AM, Ard Biesheuvel
> <ard.biesheuvel@xxxxxxxxxx> 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.
>

Yeah I cloned roundup_pow_of_2, and failed to spot that ilog2 returns an int. I sent out the v2 already

> Which is plenty big enough of a type.
>
> Linus