From 9fb899849d5ac0758422c0519971cd086441f1e3 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 30 Sep 2024 13:25:55 +0200 Subject: [PATCH] stream: weasel around false-positive GCC warning As _countof is manually implemented on non-Windows platforms, GCC knows it returns size_t, but fails to realize it will never be more than 0x400 in our case making truncation harmless. Signed-off-by: Simon Rozman --- include/stdex/stream.hpp | 5 +++-- include/stdex/uuid.hpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/stdex/stream.hpp b/include/stdex/stream.hpp index 651006956..b7e20b42b 100644 --- a/include/stdex/stream.hpp +++ b/include/stdex/stream.hpp @@ -479,8 +479,9 @@ namespace stdex return *this; data.reserve(num_chars); for (;;) { - T buf[0x400]; - uint32_t num_read = static_cast(read_array(buf, sizeof(T), std::min(num_chars, _countof(buf)))); + constexpr uint32_t buf_chars = 0x400; + T buf[buf_chars]; + uint32_t num_read = static_cast(read_array(buf, sizeof(T), std::min(num_chars, buf_chars))); data.append(buf, num_read); num_chars -= num_read; if (!num_chars || !ok()) diff --git a/include/stdex/uuid.hpp b/include/stdex/uuid.hpp index ca8040116..78c50317e 100644 --- a/include/stdex/uuid.hpp +++ b/include/stdex/uuid.hpp @@ -1,4 +1,4 @@ -/* +/* SPDX-License-Identifier: MIT Copyright © 2016-2024 Amebis */