Skip to content

fix: Resolve compiler warnings across multiple modules#5103

Merged
matejk merged 1 commit intomainfrom
fix/compiler-warnings-cleanup
Dec 17, 2025
Merged

fix: Resolve compiler warnings across multiple modules#5103
matejk merged 1 commit intomainfrom
fix/compiler-warnings-cleanup

Conversation

@matejk
Copy link
Copy Markdown
Contributor

@matejk matejk commented Dec 17, 2025

Summary

This PR addresses compiler warnings reported in CI builds (GCC, Clang, MSVC) across multiple modules, improving code quality and C++ standards compliance.

80 files changed across Foundation, Net, Crypto, Data, JSON, MongoDB, Redis, XML, and Zip modules.


1. Stream Buffer Return Types

Changed readFromDevice() and writeToDevice() return types from int to std::streamsize to match the C++ standard library interface.

Affected files:

  • Foundation/include/Poco/BufferedStreamBuf.h, BufferedBidirectionalStreamBuf.h
  • Foundation/include/Poco/DeflatingStream.h, InflatingStream.h, DigestStream.h, FIFOBufferStream.h, FileStream_*.h, PipeStream.h, RandomStream.h
  • Foundation/src/DeflatingStream.cpp, InflatingStream.cpp, DigestStream.cpp, FIFOBufferStream.cpp, FileStream_*.cpp, PipeStream.cpp, RandomStream.cpp, StreamConverter.cpp
  • Net/include/Poco/Net/HTTPChunkedStream.h, HTTPFixedLengthStream.h, HTTPHeaderStream.h, HTTPStream.h, MultipartReader.h, SocketStream.h, HTTPReactorServerSession.h
  • Net/src/HTTPChunkedStream.cpp, HTTPFixedLengthStream.cpp, HTTPHeaderStream.cpp, HTTPStream.cpp, MultipartReader.cpp, SocketStream.cpp, HTTPReactorServerSession.cpp
  • Crypto/include/Poco/Crypto/CryptoStream.h, Crypto/src/CryptoStream.cpp
  • Redis/include/Poco/Redis/RedisStream.h, Redis/src/RedisStream.cpp
  • Zip/include/Poco/Zip/AutoDetectStream.h, PartialStream.h, ZipStream.h
  • Zip/src/AutoDetectStream.cpp, PartialStream.cpp, ZipStream.cpp

2. Signed/Unsigned Comparison Warnings (C4244, C4245)

Added explicit static_cast<> to fix comparisons between signed and unsigned types.

File Change
Foundation/src/DateTime.cpp static_cast<short>() for int-to-short member initialization
Foundation/src/Path.cpp static_cast<std::size_t>() for int-to-size_t comparisons
Foundation/src/ThreadPool.cpp static_cast<std::size_t>() for capacity comparisons
Foundation/src/Logger.cpp Changed int addr to std::size_t addr
Crypto/src/CipherImpl.cpp static_cast<int>() and static_cast<std::streamsize>()
Crypto/src/Envelope.cpp, EVPCipherImpl.cpp, RSACipherImpl.cpp Similar casts for size comparisons
JSON/include/Poco/JSON/Object.h, Array.h, Stringifier.h Kept unsigned int indent, fixed internal loop variables and arithmetic with static_cast<unsigned int>(step)
JSON/src/Object.cpp, Array.cpp, Stringifier.cpp Matching implementation changes
Zip/src/ZipUtil.cpp Size comparison fix

3. Constructor Member Initializer Order

Fixed member initializer list order to match declaration order (GCC -Wreorder).

  • Net/src/TCPReactorAcceptor.cpp
  • Net/src/TCPReactorServer.cpp

4. Unused Result Warnings

Added [[maybe_unused]] for system call return values.

  • Net/src/PollSet.cpp: read() and write() on eventfd

5. Unused Variable Warnings (C4189)

Added [[maybe_unused]] attribute or (void) cast for intentionally unused variables.

File Variable
Net/src/WebSocketImpl.cpp n in debug assertion
MongoDB/src/TopologyDescription.cpp unknownCount
MongoDB/testsuite/src/MongoDBTestOpMsg.cpp lastupdatedTimestamp
MongoDB/testsuite/src/ReplicaSetTest.cpp foundTaggedServer
Foundation/src/Timezone_WIN32.cpp dstFlag from GetTimeZoneInformation()
Zip/testsuite/src/ZipTest.cpp Multiple test variables (changed POCO_UNUSED to [[maybe_unused]])

6. Missing Field Initializers (C4351)

Changed = {0} and = {nullptr} to = {} for proper aggregate initialization.

  • Data/MySQL/src/Binder.cpp: MYSQL_TIME and MYSQL_BIND structs
  • Data/MySQL/src/Extractor.cpp: MYSQL_TIME and MYSQL_BIND structs
  • Data/PostgreSQL/src/StatementExecutor.cpp: RegularExpression::Match struct

7. Parameter/Variable Shadowing (C4456, C4457, C4458)

Renamed variables to avoid shadowing.

File Change
Zip/include/Poco/Zip/PartialStream.h endendPos (shadows std::ios::end)
Zip/src/PartialStream.cpp endendPos
Net/src/HTMLForm.cpp istrpartStream (shadows function parameter)
JSON/testsuite/src/JSONTest.cpp Inner scope vars renamed to parser1/2, result1/2, json1/2, ss1/2

8. Other Fixes

File Change
Data/ODBC/src/Binder.cpp Cast fix
Data/ODBC/src/Unicode_UNIXODBC.cpp Cast fix
XML/src/ParserEngine.cpp Warning fix
Net/src/HTTPClientSession.cpp Removed unused variable
Net/testsuite/src/MailMessageTest.cpp Added #include <algorithm>, use std::min()
Foundation/src/UUID.cpp, Foundation/include/Poco/UUID.h Type consistency
Crypto/src/CipherKeyImpl.cpp, ECKeyImpl.cpp Size comparison fixes

Test plan

  • CI builds pass on Linux (GCC/Clang)
  • CI builds pass on Windows (MSVC)
  • CI builds pass on macOS
  • No new warnings introduced
  • All existing tests pass

@matejk matejk added this to the Release 1.15.0 milestone Dec 17, 2025
@matejk matejk force-pushed the fix/compiler-warnings-cleanup branch from ef9d209 to 7c374de Compare December 17, 2025 15:14
@matejk matejk merged commit 7addcfb into main Dec 17, 2025
86 checks passed
@matejk matejk deleted the fix/compiler-warnings-cleanup branch December 17, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant