lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 10 Aug 2017 09:30:31 +0200
From:   Rasmus Villemoes <linux@...musvillemoes.dk>
To:     Yury Norov <ynorov@...iumnetworks.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        kbuild test robot <lkp@...el.com>, kbuild-all@...org,
        Noam Camus <noamca@...lanox.com>,
        Matthew Wilcox <mawilcox@...rosoft.com>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] lib: add test for bitmap_parselist()

> From be0e663b804daff0d0512e72cf94b5143270bd29 Mon Sep 17 00:00:00 2001
> From: Yury Norov <ynorov@...iumnetworks.com>
> Date: Thu, 10 Aug 2017 01:25:46 +0300
> Subject: [PATCH] bitmap: introduce BITMAP_FROM_U64() and use it in test for
>  bitmap_parselist()
>
> The macro is the compile-time analogue of bitmap_from_u64() with the
> same purpose: convert the 64-bit number to the properly ordered pair
> of 32-bit parts to be suitable for filling the bitmap.
>
> Signed-off-by: Yury Norov <ynorov@...iumnetworks.com>
> ---
>  include/linux/bitmap.h |  6 ++++++
>  lib/test_bitmap.c      | 23 +++++++++++++++++++----
>  2 files changed, 25 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
> index 5797ca6fdfe2..bdc487e47de1 100644
> --- a/include/linux/bitmap.h
> +++ b/include/linux/bitmap.h
> @@ -378,6 +378,12 @@ static inline void bitmap_from_u64(unsigned long *dst, u64 mask)
>                 dst[1] = mask >> 32;
>  }
>
> +#if __BITS_PER_LONG == 64
> +#define BITMAP_FROM_U64(n) (n)
> +#else
> +#define BITMAP_FROM_U64(n) ((n) & ULONG_MAX), ((unsigned long long) (n) >> 32)
> +#endif
> +

The 32 bit version probably needs to come in two flavours depending on
little/big endian, no?

Could you also throw in some casts so that the behaviour is consistent
regardless of the type of the expression n, and so that both elements
in the pair are guaranteed to have the same type (unsigned long,
preferably, since that's what we're initializing). I.e., cast n to
(u64), do arithmetic, cast result to (unsigned long).

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ