From c045ce324b2dbb762c6a54122a709dbde4e4d534 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Jul 2025 11:53:21 +1000 Subject: [PATCH] Cleanup: remove redundant checks in BLI_snprintf functions Checking for -1 only makes sense for signed types. --- source/blender/blenlib/intern/string.cc | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/source/blender/blenlib/intern/string.cc b/source/blender/blenlib/intern/string.cc index 47633733773..21e2feb39d0 100644 --- a/source/blender/blenlib/intern/string.cc +++ b/source/blender/blenlib/intern/string.cc @@ -158,15 +158,12 @@ size_t BLI_vsnprintf(char *__restrict dst, { BLI_string_debug_size(dst, dst_maxncpy); - size_t n; - BLI_assert(dst != nullptr); BLI_assert(dst_maxncpy > 0); BLI_assert(format != nullptr); - n = size_t(vsnprintf(dst, dst_maxncpy, format, arg)); - - if (n != size_t(-1) && n < dst_maxncpy) { + const size_t n = size_t(vsnprintf(dst, dst_maxncpy, format, arg)); + if (n < dst_maxncpy) { dst[n] = '\0'; } else { @@ -183,15 +180,12 @@ size_t BLI_vsnprintf_rlen(char *__restrict dst, { BLI_string_debug_size(dst, dst_maxncpy); - size_t n; - BLI_assert(dst != nullptr); BLI_assert(dst_maxncpy > 0); BLI_assert(format != nullptr); - n = size_t(vsnprintf(dst, dst_maxncpy, format, arg)); - - if (n != size_t(-1) && n < dst_maxncpy) { + size_t n = size_t(vsnprintf(dst, dst_maxncpy, format, arg)); + if (n < dst_maxncpy) { /* pass */ } else {