This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Make locale archive hash function architecture-independent
- From: Andreas Schwab <schwab at suse dot de>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: <libc-alpha at sourceware dot org>
- Date: Thu, 12 Sep 2013 10:20:16 +0200
- Subject: Re: Make locale archive hash function architecture-independent
- Authentication-results: sourceware.org; auth=none
- References: <Pine dot LNX dot 4 dot 64 dot 1309112218400 dot 27435 at digraph dot polyomino dot org dot uk>
"Joseph S. Myers" <joseph@codesourcery.com> writes:
> diff --git a/locale/hashval.h b/locale/hashval.h
> index 737162f..c714ec6 100644
> --- a/locale/hashval.h
> +++ b/locale/hashval.h
> @@ -37,7 +37,7 @@ compute_hashval (const void *key, size_t keylen)
> while (cnt < keylen)
> {
> hval = (hval << 9) | (hval >> (sizeof hval * CHAR_BIT - 9));
> - hval += (hashval_t) *(((char *) key) + cnt++);
> + hval += (hashval_t) *(((unsigned char *) key) + cnt++);
IMHO writing it like this is easier to parse:
hval += (hashval_t) ((unsigned char *) key)[cnt++];
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."