From 2db9ec131279f665c6d5d8764c26e22328e70a38 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Fri, 2 Oct 2026 08:17:06 -0700 Subject: [PATCH] fix ub reported by gcc builds --- src/draw/draw.c | 3 --- src/eval/eval_core.c | 6 +++--- src/font_cache/font_cache.c | 4 ++-- src/linux/shell/linux_shell.c | 2 +- src/linux/window_manager/linux_window_manager.c | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/draw/draw.c b/src/draw/draw.c index 517cad79..1a747687 100644 --- a/src/draw/draw.c +++ b/src/draw/draw.c @@ -437,13 +437,10 @@ dr_mesh(R_Handle mesh_vertices, R_Handle mesh_indices, R_GeoTopologyKind mesh_ge U64 buffer[] = { mesh_vertices.u64[0], - mesh_vertices.u64[1], mesh_indices.u64[0], - mesh_indices.u64[1], (U64)mesh_geo_topology, (U64)mesh_geo_vertex_flags, albedo_tex.u64[0], - albedo_tex.u64[1], (U64)dr_top_tex2d_sample_kind(), }; hash = dr_hash_from_string(str8((U8 *)buffer, sizeof(buffer))); diff --git a/src/eval/eval_core.c b/src/eval/eval_core.c index e46fcf29..dee9fde4 100644 --- a/src/eval/eval_core.c +++ b/src/eval/eval_core.c @@ -1251,11 +1251,11 @@ e_value_eval_from_eval(E_Eval eval) { default:{}break; case E_TypeKind_Char8: - case E_TypeKind_S8: {eval.value.s64 = (S64)*((S8 *)&eval.value.u64);}break; + case E_TypeKind_S8: {eval.value.s64 = (S64)*((S8 *)&eval.value.u128.u8[0]);}break; case E_TypeKind_Char16: - case E_TypeKind_S16: {eval.value.s64 = (S64)*((S16 *)&eval.value.u64);}break; + case E_TypeKind_S16: {eval.value.s64 = (S64)*((S16 *)&eval.value.u128.u8[0]);}break; case E_TypeKind_Char32: - case E_TypeKind_S32: {eval.value.s64 = (S64)*((S32 *)&eval.value.u64);}break; + case E_TypeKind_S32: {eval.value.s64 = (S64)*((S32 *)&eval.value.u128.u8[0]);}break; } } } diff --git a/src/font_cache/font_cache.c b/src/font_cache/font_cache.c index c84cb17b..061261a6 100644 --- a/src/font_cache/font_cache.c +++ b/src/font_cache/font_cache.c @@ -516,12 +516,12 @@ fnt_hash2style_from_tag_size_flags(FNT_Tag tag, F32 size, FNT_RasterFlags flags) //- rjf: tag * size -> style hash U64 style_hash = {0}; { - F64 size_f64 = size; + union { F64 size_f64; U64 size_u64; } size_pun = {.size_f64 = (F64)size}; U64 buffer[] = { tag.u64[0], tag.u64[1], - *(U64 *)(&size_f64), + size_pun.size_u64, (U64)flags, }; style_hash = fnt_little_hash_from_string(5381, str8((U8 *)buffer, sizeof(buffer))); diff --git a/src/linux/shell/linux_shell.c b/src/linux/shell/linux_shell.c index 06ce8320..abbd453f 100644 --- a/src/linux/shell/linux_shell.c +++ b/src/linux/shell/linux_shell.c @@ -189,7 +189,7 @@ sh_install_or_uninstall_self(B32 write, B32 install) //- rjf: make symlink in binary path to this exe make_directory(str8_chop_last_slash(symlink_path)); - symlink((char *)get_process_info()->binary_file_path.str, (char *)symlink_path.str); + LNX_RETRY_ON_EINTR(symlink((char *)get_process_info()->binary_file_path.str, (char *)symlink_path.str)); } //- rjf: uninstall -> delete files diff --git a/src/linux/window_manager/linux_window_manager.c b/src/linux/window_manager/linux_window_manager.c index cda0a06a..f2957383 100644 --- a/src/linux/window_manager/linux_window_manager.c +++ b/src/linux/window_manager/linux_window_manager.c @@ -1141,7 +1141,7 @@ wm_get_events(Arena *arena, B32 wait) if(poll_fds[1].revents & POLLIN) { U64 dummy = 0; - read(lnx_wm_state->wakeup_fd, &dummy, sizeof(dummy)); + LNX_RETRY_ON_EINTR(read(lnx_wm_state->wakeup_fd, &dummy, sizeof(dummy))); wait = 0; } }