guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#29132] [PATCH] system: vm: Use 2^32 - 1 as hash size.


From: Ludovic Courtès
Subject: [bug#29132] [PATCH] system: vm: Use 2^32 - 1 as hash size.
Date: Sun, 05 Nov 2017 21:48:52 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

Hello!

Mathieu Othacehe <address@hidden> skribis:

> * gnu/system/vm.scm (operating-system-uuid): Use 2^32 - 1 instead of
>   2^32 as hash size.
>
> On some 32 bit system (ARM for example), 2^32 exceeds hash max
> size (ULONG_MAX = 2^32 - 1).
> ---
>  gnu/system/vm.scm | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
> index 3127b30..4424608 100644
> --- a/gnu/system/vm.scm
> +++ b/gnu/system/vm.scm
> @@ -372,13 +372,13 @@ TYPE (one of 'iso9660 or 'dce).  Return a UUID object."
>        (bytevector->uuid
>         (uint-list->bytevector
>          (list (hash file-system-type
> -                    (expt 2 32))
> +                    (- (expt 2 32) 1))

‘hash’ is documented like this:

  -- Scheme Procedure: hash key size
  -- Scheme Procedure: hashq key size
  -- Scheme Procedure: hashv key size
  -- C Function: scm_hash (key, size)
  -- C Function: scm_hashq (key, size)
  -- C Function: scm_hashv (key, size)
      Return a hash value for KEY.  This is a number in the range 0 to
      SIZE-1, which is suitable for use in a hash table of the given
      SIZE.

So I take it that you always get something in the range 0–2³²-1, no?

Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]