From 59df2db7b7d892846e8774a593e82fc378c60a10 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 30 Apr 2025 11:07:28 +1000 Subject: [PATCH] chore: Silence two compiler signedness warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both trigger: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] In the first hunk we already checked for i < 0 so casting to size_t is fine. In the second hunk we don't use i so we can pick the right type. --- src/lib/base/String.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/base/String.cpp b/src/lib/base/String.cpp index 4a91027d8..bb673950d 100644 --- a/src/lib/base/String.cpp +++ b/src/lib/base/String.cpp @@ -56,7 +56,7 @@ std::string vformat(const char *fmt, va_list args) index.push_back(i); pos.push_back(static_cast((scan - 1) - fmt)); width.push_back(static_cast((end - scan) + 2)); - if (i > maxIndex) { + if (static_cast(i) > maxIndex) { maxIndex = i; } scan = end; @@ -74,7 +74,7 @@ std::string vformat(const char *fmt, va_list args) std::vector length; value.push_back("%"); length.push_back(1); - for (int i = 0; i < maxIndex; ++i) { + for (size_t i = 0; i < maxIndex; ++i) { const char *arg = va_arg(args, const char *); size_t len = strnlen(arg, SIZE_MAX); value.push_back(arg);