[ubsan] fix some warnings on 32bit arches

Mostly from the use of ssize_t which does not play well with printf and
32bit arches on LK for underlying type reasons that haven't really ever
been sorted out properly.
This commit is contained in:
Travis Geiselbrecht
2025-10-05 14:41:56 -07:00
parent 355b62b13a
commit ac6468c916

View File

@@ -100,7 +100,7 @@ struct val
small_string<36> s; small_string<36> s;
if (ubsan_type_is_signed_int(type_)) if (ubsan_type_is_signed_int(type_))
{ {
snprintf(s.buf, 36, "%zd", (ssize_t) val_); snprintf(s.buf, 36, "%ld", (long)val_);
} }
else if (ubsan_type_is_uint(type_)) else if (ubsan_type_is_uint(type_))
{ {
@@ -393,11 +393,11 @@ void ubsan_handle_shift_out_of_bounds(const ubsan_shift_oob_data *data, ssize_t
if (ubsan_type_is_signed_int(rhs_t) && rhs < 0) if (ubsan_type_is_signed_int(rhs_t) && rhs < 0)
{ {
printf("shift exponent %zd is negative\n", rhs); printf("shift exponent %ld is negative\n", rhs);
} }
else if ((size_t) rhs >= ubsan_type_get_int_width(lhs_t)) else if ((size_t) rhs >= ubsan_type_get_int_width(lhs_t))
{ {
printf("shift exponent %zu is too large for %zu-bit type %s\n", rhs, printf("shift exponent %ld is too large for %zu-bit type %s\n", rhs,
ubsan_type_get_int_width(lhs_t), lhs_t->typename_); ubsan_type_get_int_width(lhs_t), lhs_t->typename_);
} }
else else
@@ -547,7 +547,7 @@ struct ubsan_vla_bound_data
__USED void __ubsan_handle_vla_bound_not_positive(ubsan_vla_bound_data *data, ssize_t val) __USED void __ubsan_handle_vla_bound_not_positive(ubsan_vla_bound_data *data, ssize_t val)
{ {
ubsan_report_start(&data->location, "vla bound not positive"); ubsan_report_start(&data->location, "vla bound not positive");
printf("vla bound not positive (%zd)\n", val); printf("vla bound not positive (%ld)\n", val);
ubsan_report_end(); ubsan_report_end();
} }