summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-02-14 06:39:54 -0800
committerKaz Kylheku <kaz@kylheku.com>2022-02-14 06:39:54 -0800
commit4355d30b13d462ab334380a3dd45258811d1690e (patch)
tree113077bbd0d3c491f14027ee087f16fd800fdcae /hash.c
parent835fbf4248cce666199f41a118befd1063fdea2e (diff)
downloadtxr-4355d30b13d462ab334380a3dd45258811d1690e.tar.gz
txr-4355d30b13d462ab334380a3dd45258811d1690e.tar.bz2
txr-4355d30b13d462ab334380a3dd45258811d1690e.zip
Fix more -fsanitize=implicit-conversion findings.
* arith.c (highest_significant_bit): Bugfix: do not pass a negative value to highest_bit, where we will get then get the wrong idea about the number of significant bits in the value, since the __builtin_clz primitives will include the sign bit. We want to complement the all the bits, so that the sign bit will go to zero. We can do this arithmetically by taking the additive inverse (which is the two's complement (which is the complement plus one)) and subtracting one. (ash): Avoid left shifting a negative number in HAVE_UBSAN mode using the same trick as in num_fast. * ffi.c (ffi_swap_u16): Here the shift and or calculation is producing a value beyond 16 bits which we are relying on the implicit conversion back to uin16_t to trim away. We add the cast to uint16_t to make it explicit. * hash.c (equal_hash): Also handle the CHR and NUM cases here via c_u like in eql_hash and eq_hash.
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/hash.c b/hash.c
index 1a481061..abefdf24 100644
--- a/hash.c
+++ b/hash.c
@@ -317,9 +317,8 @@ ucnum equal_hash(val obj, int *count, ucnum seed)
case STR:
return hash_c_str(obj->st.str, seed, count);
case CHR:
- return c_chr(obj);
case NUM:
- return c_num(obj, self);
+ return c_u(obj);
case SYM:
case PKG:
case ENV: