From 91c9e5064397bc7a9a28c781ac29c71c6489b8b6 Mon Sep 17 00:00:00 2001 From: "Dr. Mohammed Lubbad" Date: Fri, 27 Nov 2026 11:33:02 +0300 Subject: [PATCH] fix(core): resolve C pointer qualifier errors and implement BLI_strncpy_wchar_from_utf8 - Cast int * to unsigned int * in BLI_endian_switch_int32 to prevent pointer sign mismatch warnings/errors. - Drop const cast passed to MEM_freeN(void *) in BLI_ghashutil_pairfree. - Swap const float * segment pointers explicitly in isect_seg_seg_v2_point_ex instead of BUI_SWAP, which fails when typeof preserves const on the temporary variable. - Implement UTF-8 to wchar_t decoding loop in BLI_strncpy_wchar_from_utf8, which had an empty function body missing a return statement. Signed-off-by: Dr. Mohammed Lubbad --- core/include/BLI_endian_switch_inline.h | 2 +- core/intern/BLI_ghash_utils.c | 2 +- core/intern/math_geom.c | 9 +++++++-- core/intern/string_utf8.c | 12 +++++++++++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/core/include/BLI_endian_switch_inline.h b/core/include/BLI_endian_switch_inline.h index 4afc3283..793f9930 100644 --- a/core/include/BLI_endian_switch_inline.h +++ b/core/include/BLI_endian_switch_inline.h @@ -39,7 +39,7 @@ BLI_INLINE void BLI_endian_switch_uint16(unsigned short *val) BLI_INLINE void BLI_endian_switch_int32(int *val) { - BLI_endian_switch_uint32((val)); + BLI_endian_switch_uint32((unsigned int *)(val)); } BLI_INLINE void BLI_endian_switch_uint32(unsigned int *val) { diff --git a/core/intern/BLI_ghash_utils.c b/core/intern/BLI_ghash_utils.c index 09e23803..ad626ffe 100644 --- a/core/intern/BLI_ghash_utils.c +++ b/core/intern/BLI_ghash_utils.c @@ -177,7 +177,7 @@ bool BLI_ghashutil_paircmp(const void *a, const void *b) void BLI_ghashutil_pairfree(void *ptr) { - MEM_freeN((const GHashPair *)(ptr)); + MEM_freeN(ptr); } /** \} */ diff --git a/core/intern/math_geom.c b/core/intern/math_geom.c index fc395cb3..6b0e77ba 100644 --- a/core/intern/math_geom.c +++ b/core/intern/math_geom.c @@ -1297,8 +1297,13 @@ int isect_seg_seg_v2_point_ex(const float v0[2], if (equals_v2v2(v0, v1)) { if (len_squared_v2v2(v2, v3) > square_f(eps)) { /* use non-point segment as basis */ - BUI_SWAP(v0, v2); - BUI_SWAP(v1, v3); + const float *v_tmp; + v_tmp = v0; + v0 = v2; + v2 = v_tmp; + v_tmp = v1; + v1 = v3; + v3 = v_tmp; sub_v2_v2v2(s10, v1, v0); sub_v2_v2v2(s30, v3, v0); diff --git a/core/intern/string_utf8.c b/core/intern/string_utf8.c index afb7a608..5abbc0e6 100644 --- a/core/intern/string_utf8.c +++ b/core/intern/string_utf8.c @@ -527,7 +527,17 @@ size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w, const char *__restrict src_c, const size_t dst_w_maxncpy) { - /* WIN32 branch dropped with the utfconv C++ dependency; UTF-32 path below. */ + if (dst_w_maxncpy == 0) { + return 0; + } + const size_t src_len = strlen(src_c); + size_t index = 0; + size_t len = 0; + while (index < src_len && len + 1 < dst_w_maxncpy) { + dst_w[len++] = (wchar_t)BLI_str_utf8_as_unicode_step_safe(src_c, src_len, &index); + } + dst_w[len] = 0; + return len; } /* End wchar_t / UTF8 functions. */