all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Mathieu Othacehe <m.othacehe@gmail.com>
Cc: 29132@debbugs.gnu.org
Subject: [bug#29132] [PATCH] system: vm: Use 2^32 - 1 as hash size.
Date: Sun, 05 Nov 2017 21:48:52 +0100	[thread overview]
Message-ID: <87bmkgo3ij.fsf@gnu.org> (raw)
In-Reply-To: <1509713344-16963-1-git-send-email-m.othacehe@gmail.com> (Mathieu Othacehe's message of "Fri, 3 Nov 2017 13:49:04 +0100")

Hello!

Mathieu Othacehe <m.othacehe@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’.

  reply	other threads:[~2017-11-05 20:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-03 12:49 [bug#29132] [PATCH] system: vm: Use 2^32 - 1 as hash size Mathieu Othacehe
2017-11-05 20:48 ` Ludovic Courtès [this message]
2017-11-05 20:56   ` Mathieu Othacehe
2017-11-06  8:41     ` Ludovic Courtès
2017-11-06 19:04       ` Mathieu Othacehe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bmkgo3ij.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=29132@debbugs.gnu.org \
    --cc=m.othacehe@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.