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

Previous Next

Package: guix-patches;

Reported by: Mathieu Othacehe <m.othacehe <at> gmail.com>

Date: Fri, 3 Nov 2017 12:50:01 UTC

Severity: normal

Tags: fixed, patch

Done: Mathieu Othacehe <m.othacehe <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 29132 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mathieu Othacehe <m.othacehe <at> gmail.com>
Cc: 29132 <at> debbugs.gnu.org
Subject: Re: [bug#29132] [PATCH] system: vm: Use 2^32 - 1 as hash size.
Date: Sun, 05 Nov 2017 21:48:52 +0100
Hello!

Mathieu Othacehe <m.othacehe <at> gmail.com> 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’.




This bug report was last modified 7 years and 259 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.