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: Roland McGrath <roland at hack dot frob dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: Andreas Schwab <schwab at suse dot de>, <libc-alpha at sourceware dot org>
- Date: Mon, 23 Sep 2013 15:54:00 -0700 (PDT)
- 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> <mvm38pa5u4f dot fsf at hawking dot suse dot de> <Pine dot LNX dot 4 dot 64 dot 1309121630350 dot 5614 at digraph dot polyomino dot org dot uk>
> --- 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++];
Use const in the cast since we don't intend to drop constness.
Otherwise this looks fine to me (and I concur about using array syntax
whenever possible).
Thanks,
Roland