Re: [ANNOUNCE] Git v2.23.0-rc0 - Initial test failures on NonStop

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

 



Jeff King <peff@xxxxxxxx> writes:

> @@ -116,19 +116,11 @@ unsigned int memihash_cont(unsigned int hash_seed, const void *buf, size_t len);
>   * Converts a cryptographic hash (e.g. SHA-1) into an int-sized hash code
>   * for use in hash tables. Cryptographic hashes are supposed to have
>   * uniform distribution, so in contrast to `memhash()`, this just copies
> - * the first `sizeof(int)` bytes without shuffling any bits. Note that
> - * the results will be different on big-endian and little-endian
> - * platforms, so they should not be stored or transferred over the net.

;-)

> + * the first `sizeof(int)` bytes without shuffling any bits.
>   */
>  static inline unsigned int oidhash(const struct object_id *oid)
>  {
> -	/*
> -	 * Equivalent to 'return *(unsigned int *)oid->hash;', but safe on
> -	 * platforms that don't support unaligned reads.
> -	 */
> -	unsigned int hash;
> -	memcpy(&hash, oid->hash, sizeof(hash));
> -	return hash;
> +	return get_be32(oid->hash);
>  }
>  
>  /*
> diff --git a/t/t0016-oidmap.sh b/t/t0016-oidmap.sh
> index bbe719e950..6656db9d69 100755
> --- a/t/t0016-oidmap.sh
> +++ b/t/t0016-oidmap.sh
> @@ -93,9 +93,9 @@ put three 3
>  iterate" "NULL
>  NULL
>  NULL
> +$(git rev-parse three) 3
>  $(git rev-parse two) 2
> -$(git rev-parse one) 1
> -$(git rev-parse three) 3"
> +$(git rev-parse one) 1"
>  
>  '
>
> which not only fixes this test but any other hash-based oddities. I
> wonder if it's appreciably less efficient. I'll bet I could nerd-snipe
> René into doing a bunch of measurements and explorations of the
> disassembled code. ;)

I'd rather see us go in the direction of discouraging people from
relying on the hash order.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux