From 25cd740a78b2397160db4d7cf37bb844ae48d651 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 28 Oct 2025 01:51:47 +0100 Subject: [PATCH 1/3] build: resolve 2 instances of -Wpessimizing-move clang 19 on FreeBSD 14.3 warns: ``` /usr/bin/c++ -DDEBUG -Dwmime_EXPORTS -I/home/ej/vmime -I/home/ej/vmime/src -I/usr/local/include -D_REENTRANT=1 -W -Wall -pedantic -Warray-bounds-pointer-arithmetic -Wold-style-cast -Wconversion -Wcast-align -Wno-sign-conversion -fvisibility=hidden -fvisibility-inlines-hidden -O0 -g -std=c++17 -fPIC -DVMIME_SHARED -MD -MT CMakeFiles/wmime.dir/src/vmime/net/imap/IMAPCommand.cpp.o -MF CMakeFiles/wmime.dir/src/vmime/net/imap/IMAPCommand.cpp.o.d -o CMakeFiles/wmime.dir/src/vmime/net/imap/IMAPCommand.cpp.o -c /home/ej/vmime/src/vmime/net/imap/IMAPCommand.cpp In file included from IMAPCommand.cpp:31: In file included from IMAPConnection.hpp:40: IMAPParser.hpp:3715:20: warning: moving a temporary object prevents copy elision [-Wpessimizing-move] | items.push_back(std::move(std::unique_ptr (parser.get (line, &pos)))); IMAPParser.hpp:3715:20: note: remove std::move call here | items.push_back(std::move(std::unique_ptr (parser.get (line, &pos)))); IMAPParser.hpp:4504:6: warning: moving a temporary object prevents copy elision [-Wpessimizing-move] | std::move( IMAPParser.hpp:4504:6: note: remove std::move call here | std::move( ``` std::unique_ptr(expr) is already an rvalue; invoking move() is just redundant there. --- src/vmime/net/imap/IMAPParser.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/vmime/net/imap/IMAPParser.hpp b/src/vmime/net/imap/IMAPParser.hpp index e71b403f..0e3d8137 100644 --- a/src/vmime/net/imap/IMAPParser.hpp +++ b/src/vmime/net/imap/IMAPParser.hpp @@ -3712,7 +3712,7 @@ class VMIME_EXPORT IMAPParser : public object { VIMAP_PARSER_CHECK(one_char <'('> ); - items.push_back(std::move(std::unique_ptr (parser.get (line, &pos)))); + items.push_back(std::unique_ptr (parser.get (line, &pos))); while (!VIMAP_PARSER_TRY_CHECK(one_char <')'> )) { VIMAP_PARSER_CHECK(SPACE); @@ -4501,9 +4501,7 @@ class VMIME_EXPORT IMAPParser : public object { while ((resp = parser.get (curLine, &pos))) { continue_req_or_response_data.push_back( - std::move( - std::unique_ptr (resp) - ) + std::unique_ptr (resp) ); // Partial response (continue_req) From 50752a3eb46833c63aeb45e6c3b20838ee98f279 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 28 Oct 2025 01:54:15 +0100 Subject: [PATCH 2/3] build: resolve 1 instance of -Wunused-but-set-variable clang 19 on FreeBSD 14.3 warns: ``` In file included from IMAPCommand.cpp:31: In file included from IMAPConnection.hpp:40: IMAPParser.hpp:959:11: warning: variable 'len' set but not used [-Wunused-but-set-variable] | size_t len = 0; ``` --- src/vmime/net/imap/IMAPParser.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/vmime/net/imap/IMAPParser.hpp b/src/vmime/net/imap/IMAPParser.hpp index 0e3d8137..78b76973 100644 --- a/src/vmime/net/imap/IMAPParser.hpp +++ b/src/vmime/net/imap/IMAPParser.hpp @@ -956,7 +956,6 @@ class VMIME_EXPORT IMAPParser : public object { bool parseImpl(IMAPParser& parser, string& line, size_t* currentPos) { size_t pos = *currentPos; - size_t len = 0; bool valid = false; value.reserve(line.length() - pos); @@ -977,7 +976,6 @@ class VMIME_EXPORT IMAPParser : public object { quoted = false; ++pos; - ++len; } else { @@ -986,7 +984,6 @@ class VMIME_EXPORT IMAPParser : public object { quoted = true; ++pos; - ++len; } else if (c == '"') { @@ -999,7 +996,6 @@ class VMIME_EXPORT IMAPParser : public object { value += c; ++pos; - ++len; } else { From 5c9b31a8b712c64c518530c1faac2493702017d0 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 28 Oct 2025 02:01:17 +0100 Subject: [PATCH 3/3] build: resolve 2 instances of -Wimplicit-int-conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clang 19 on FreeBSD 14.3 warns: ``` IMAPMessage.cpp:112:11: warning: higher order bits are zeroes after implicit conversion [-Wimplicit-int-conversion] 112 | m_size(-1U), | ~^~~ IMAPMessage.cpp:183:16: warning: higher order bits are zeroes after implicit conversion [-Wimplicit-int-conversion] 183 | if (m_size == -1U) { | ~~ ^~~ ``` -1U is UINT_MAX; assigning that to size_t does not change the value (stays UINT_MAX, does not become SIZE_MAX). What is really intended here is ``size_t(-1)`` (or syntactically equivalents). This is equal to ``size_t(0) - 1`` as per https://en.cppreference.com/w/c/language/conversion.html § Integer conversions ("repeatedly subtracted"), and because unsigned integers implement modulo arithmetic, we get SIZE_MAX as desired. --- src/vmime/net/imap/IMAPMessage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vmime/net/imap/IMAPMessage.cpp b/src/vmime/net/imap/IMAPMessage.cpp index 0bf8fbe6..fa33b83a 100644 --- a/src/vmime/net/imap/IMAPMessage.cpp +++ b/src/vmime/net/imap/IMAPMessage.cpp @@ -109,7 +109,7 @@ IMAPMessage::IMAPMessage( ) : m_folder(folder), m_num(num), - m_size(-1U), + m_size(-1), m_flags(FLAG_UNDEFINED), m_expunged(false), m_modseq(0), @@ -180,7 +180,7 @@ vmime_uint64 IMAPMessage::getModSequence() const { size_t IMAPMessage::getSize() const { - if (m_size == -1U) { + if (m_size == static_cast(-1)) { throw exceptions::unfetched_object(); }