lkml.org 
[lkml]   [2021]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v2 18/20] linux/power_of_2.h: Add __IS_POWER_OF_2(n) and __IS_POWER_OF_2_OR_0(n) macros
Date
On Sun, 21 Nov 2021, Arnd Bergmann <arnd@arndb.de> wrote:
> On Sat, Nov 20, 2021 at 2:01 PM Alejandro Colomar
> <alx.manpages@gmail.com> wrote:
>> +
>> +#define __IS_POWER_OF_2_OR_0(n) (((n) & ((n) - 1)) == 0)
>> +#define __IS_POWER_OF_2(n) (__IS_POWER_OF_2_OR_0(n) && ((n) != 0))
>> +
>
> There is already is_power_of_2() in include/linux/log2.h, which would
> be preferred
> in most cases. If you need a macro version, put it in the same file
> and explain why it's
> needed.

Also, the macro argument n is evaluated 2-3 times. Please use
checkpatch.pl --strict argument on the patches, and it'll give you hints
about this stuff too.

BR,
Jani.


--
Jani Nikula, Intel Open Source Graphics Center

\
 
 \ /
  Last update: 2021-11-22 09:56    [W:0.107 / U:28.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site