[CRIU] [PATCH 1/2] compiler: Add comment about is_log2 helper
Pavel Emelyanov
xemul at parallels.com
Tue Dec 11 10:03:24 EST 2012
On 12/10/2012 06:07 PM, Cyrill Gorcunov wrote:
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
> include/compiler.h | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/include/compiler.h b/include/compiler.h
> index 621cedb..fd8fd2f 100644
> --- a/include/compiler.h
> +++ b/include/compiler.h
> @@ -66,6 +66,10 @@
> (void) (&_max1 == &_max2); \
> _max1 > _max2 ? _max1 : _max2; })
>
> -#define is_log2(v) (((v) & ((v) - 1)) == 0)
> +/*
> + * Note the side effects here: if v = [0;1] it will
> + * return true for obvious reason
> + */
> +#define is_log2(v) (((v) & ((v) - 1)) == 0)
So fix IT to report result properly, not callers. If you care
about having "pure" is_log2, then rename this one into __is_log2,
and make the is_log2 do proper checks.
> #endif /* CR_COMPILER_H_ */
>
More information about the CRIU
mailing list