Source-Changes-D archive

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

lint and '<<' in src/common/lib/libc/hash/murmurhash



Am 15.09.2025 um 23:26 schrieb Christos Zoulas:
> Module Name:	src
> Committed By:	christos
> Date:		Mon Sep 15 21:26:19 UTC 2025
> 
> Modified Files:
> 	src/common/lib/libc/hash/murmurhash: murmurhash.c
> 
> Log Message:
> pacify lint
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.8 -r1.9 src/common/lib/libc/hash/murmurhash/murmurhash.c
> 
> -	k |= data[3] << 24;
> +	k |= (uint32_t)data[3] << 24;
Since this file lives in src/common, it has the chance of being used in
kernel mode. There, KUBSAN crashes due to the undefined behavior when a
uint8_t is promoted to int and then gets shifted into the sign bit of a
signed int, as this shift operation is not value-preserving.

Therefore, the main point of this commit is "fix undefined behavior"
instead of "pacify lint".

See usr.bin/xlint/lint1/tree.c, typeok_shl_signed_to_msb.

Roland



Home | Main Index | Thread Index | Old Index