From 7addcfbc810e759ac4da28ed7648edd8ea00bebb Mon Sep 17 00:00:00 2001 From: Matej Kenda Date: Wed, 17 Dec 2025 14:04:42 +0100 Subject: [PATCH] fix: Resolve compiler warnings across multiple modules --- Crypto/include/Poco/Crypto/CryptoStream.h | 4 +- Crypto/src/CipherImpl.cpp | 6 +- Crypto/src/CipherKeyImpl.cpp | 2 +- Crypto/src/CryptoStream.cpp | 28 ++++----- Crypto/src/ECKeyImpl.cpp | 5 +- Crypto/src/EVPCipherImpl.cpp | 6 +- Crypto/src/Envelope.cpp | 12 ++-- Crypto/src/RSACipherImpl.cpp | 6 +- Data/MySQL/src/Binder.cpp | 8 +-- Data/MySQL/src/Extractor.cpp | 8 +-- Data/ODBC/src/Binder.cpp | 3 +- Data/ODBC/src/Unicode_UNIXODBC.cpp | 3 +- Data/PostgreSQL/src/StatementExecutor.cpp | 2 +- .../Poco/BufferedBidirectionalStreamBuf.h | 12 ++-- Foundation/include/Poco/BufferedStreamBuf.h | 12 ++-- Foundation/include/Poco/DeflatingStream.h | 4 +- Foundation/include/Poco/DigestStream.h | 4 +- Foundation/include/Poco/FIFOBufferStream.h | 4 +- Foundation/include/Poco/FileStream_POSIX.h | 4 +- Foundation/include/Poco/FileStream_WIN32.h | 4 +- Foundation/include/Poco/InflatingStream.h | 4 +- Foundation/include/Poco/PipeStream.h | 4 +- Foundation/include/Poco/RandomStream.h | 2 +- Foundation/include/Poco/UUID.h | 2 +- Foundation/src/DateTime.cpp | 60 ++++++++++--------- Foundation/src/DeflatingStream.cpp | 10 ++-- Foundation/src/DigestStream.cpp | 8 +-- Foundation/src/FIFOBufferStream.cpp | 8 +-- Foundation/src/FileStream_POSIX.cpp | 14 ++--- Foundation/src/FileStream_WIN32.cpp | 8 +-- Foundation/src/InflatingStream.cpp | 12 ++-- Foundation/src/Logger.cpp | 2 +- Foundation/src/Path.cpp | 10 ++-- Foundation/src/PipeStream.cpp | 8 +-- Foundation/src/RandomStream.cpp | 6 +- Foundation/src/StreamConverter.cpp | 8 +-- Foundation/src/ThreadPool.cpp | 4 +- Foundation/src/Timezone_WIN32.cpp | 6 +- Foundation/src/UUID.cpp | 2 +- JSON/include/Poco/JSON/Object.h | 6 +- JSON/src/Array.cpp | 10 ++-- JSON/src/Object.cpp | 2 +- JSON/src/Stringifier.cpp | 2 +- JSON/src/Template.cpp | 4 +- JSON/testsuite/src/JSONTest.cpp | 32 +++++----- MongoDB/src/TopologyDescription.cpp | 2 +- MongoDB/testsuite/src/MongoDBTestOpMsg.cpp | 2 +- MongoDB/testsuite/src/ReplicaSetTest.cpp | 2 +- Net/include/Poco/Net/HTTPChunkedStream.h | 4 +- Net/include/Poco/Net/HTTPFixedLengthStream.h | 4 +- Net/include/Poco/Net/HTTPHeaderStream.h | 4 +- .../Poco/Net/HTTPReactorServerSession.h | 8 +-- Net/include/Poco/Net/HTTPStream.h | 4 +- Net/include/Poco/Net/MultipartReader.h | 2 +- Net/include/Poco/Net/SocketStream.h | 4 +- Net/src/HTMLForm.cpp | 6 +- Net/src/HTTPChunkedStream.cpp | 8 +-- Net/src/HTTPClientSession.cpp | 1 - Net/src/HTTPFixedLengthStream.cpp | 8 +-- Net/src/HTTPHeaderStream.cpp | 6 +- Net/src/HTTPReactorServerSession.cpp | 3 +- Net/src/HTTPStream.cpp | 4 +- Net/src/MultipartReader.cpp | 6 +- Net/src/PollSet.cpp | 4 +- Net/src/SocketStream.cpp | 8 +-- Net/src/TCPReactorAcceptor.cpp | 6 +- Net/src/TCPReactorServer.cpp | 6 +- Net/src/WebSocketImpl.cpp | 2 +- Net/testsuite/src/MailMessageTest.cpp | 7 ++- Redis/include/Poco/Redis/RedisStream.h | 4 +- Redis/src/RedisStream.cpp | 4 +- XML/src/ParserEngine.cpp | 3 +- Zip/include/Poco/Zip/AutoDetectStream.h | 4 +- Zip/include/Poco/Zip/PartialStream.h | 16 ++--- Zip/include/Poco/Zip/ZipStream.h | 4 +- Zip/src/AutoDetectStream.cpp | 46 +++++++------- Zip/src/PartialStream.cpp | 54 ++++++++--------- Zip/src/ZipStream.cpp | 10 ++-- Zip/src/ZipUtil.cpp | 2 +- Zip/testsuite/src/ZipTest.cpp | 10 ++-- 80 files changed, 324 insertions(+), 315 deletions(-) diff --git a/Crypto/include/Poco/Crypto/CryptoStream.h b/Crypto/include/Poco/Crypto/CryptoStream.h index e82373392..8a4c55c23 100644 --- a/Crypto/include/Poco/Crypto/CryptoStream.h +++ b/Crypto/include/Poco/Crypto/CryptoStream.h @@ -48,8 +48,8 @@ public: /// Flushes all buffers and finishes the encryption. protected: - int readFromDevice(char* buffer, std::streamsize length); - int writeToDevice(const char* buffer, std::streamsize length); + std::streamsize readFromDevice(char* buffer, std::streamsize length); + std::streamsize writeToDevice(const char* buffer, std::streamsize length); private: CryptoTransform::Ptr _pTransform; diff --git a/Crypto/src/CipherImpl.cpp b/Crypto/src/CipherImpl.cpp index 8aa67e4df..14b007d25 100644 --- a/Crypto/src/CipherImpl.cpp +++ b/Crypto/src/CipherImpl.cpp @@ -116,7 +116,7 @@ namespace if (rc == 0) throwError(); #if OPENSSL_VERSION_NUMBER >= 0x10001000L - if (_iv.size() != EVP_CIPHER_iv_length(_pCipher) && EVP_CIPHER_mode(_pCipher) == EVP_CIPH_GCM_MODE) + if (static_cast(_iv.size()) != EVP_CIPHER_iv_length(_pCipher) && EVP_CIPHER_mode(_pCipher) == EVP_CIPH_GCM_MODE) { #if OPENSSL_VERSION_NUMBER >= 0x10100000L int rc = EVP_CIPHER_CTX_ctrl(_pContext, EVP_CTRL_GCM_SET_IVLEN, static_cast(_iv.size()), nullptr); @@ -196,7 +196,7 @@ namespace unsigned char* output, std::streamsize outputLength) { - poco_assert (outputLength >= (inputLength + blockSize() - 1)); + poco_assert (outputLength >= (inputLength + static_cast(blockSize()) - 1)); int outLen = static_cast(outputLength); #if OPENSSL_VERSION_NUMBER >= 0x10100000L @@ -225,7 +225,7 @@ namespace unsigned char* output, std::streamsize length) { - poco_assert (length >= blockSize()); + poco_assert (length >= static_cast(blockSize())); int len = static_cast(length); diff --git a/Crypto/src/CipherKeyImpl.cpp b/Crypto/src/CipherKeyImpl.cpp index 130e02c98..d25cc1663 100644 --- a/Crypto/src/CipherKeyImpl.cpp +++ b/Crypto/src/CipherKeyImpl.cpp @@ -168,7 +168,7 @@ void CipherKeyImpl::getRandomBytes(ByteVec& vec, std::size_t count) vec.clear(); vec.reserve(count); - for (int i = 0; i < count; ++i) + for (std::size_t i = 0; i < count; ++i) vec.push_back(static_cast(random.get())); } diff --git a/Crypto/src/CryptoStream.cpp b/Crypto/src/CryptoStream.cpp index 71fc51152..6914a7feb 100644 --- a/Crypto/src/CryptoStream.cpp +++ b/Crypto/src/CryptoStream.cpp @@ -41,7 +41,7 @@ CryptoStreamBuf::CryptoStreamBuf(std::istream& istr, CryptoTransform::Ptr pTrans _buffer(static_cast(bufferSize)) { poco_check_ptr (pTransform); - poco_assert (bufferSize > 2 * pTransform->blockSize()); + poco_assert (bufferSize > static_cast(2 * pTransform->blockSize())); } @@ -54,7 +54,7 @@ CryptoStreamBuf::CryptoStreamBuf(std::ostream& ostr, CryptoTransform::Ptr pTrans _buffer(static_cast(bufferSize)) { poco_check_ptr (pTransform); - poco_assert (bufferSize > 2 * pTransform->blockSize()); + poco_assert (bufferSize > static_cast(2 * pTransform->blockSize())); } @@ -99,16 +99,16 @@ void CryptoStreamBuf::close() } -int CryptoStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize CryptoStreamBuf::readFromDevice(char* buffer, std::streamsize length) { if (!_pIstr) return 0; - int count = 0; + std::streamsize count = 0; while (!_eof) { - int m = (static_cast(length) - count)/2 - static_cast(_pTransform->blockSize()); + std::streamsize m = (length - count)/2 - static_cast(_pTransform->blockSize()); // Make sure we can read at least one more block. Explicitely check // for m < 0 since blockSize() returns an unsigned int and the @@ -116,12 +116,12 @@ int CryptoStreamBuf::readFromDevice(char* buffer, std::streamsize length) if (m <= 0) break; - int n = 0; + std::streamsize n = 0; if (_pIstr->good()) { _pIstr->read(reinterpret_cast(_buffer.begin()), m); - n = static_cast(_pIstr->gcount()); + n = _pIstr->gcount(); } if (n == 0) @@ -129,18 +129,18 @@ int CryptoStreamBuf::readFromDevice(char* buffer, std::streamsize length) _eof = true; // No more data, finalize transformation - count += static_cast(_pTransform->finalize( + count += _pTransform->finalize( reinterpret_cast(buffer + count), - static_cast(length) - count)); + length - count); } else { // Transform next chunk of data - count += static_cast(_pTransform->transform( + count += _pTransform->transform( _buffer.begin(), n, reinterpret_cast(buffer + count), - static_cast(length) - count)); + length - count); } } @@ -148,7 +148,7 @@ int CryptoStreamBuf::readFromDevice(char* buffer, std::streamsize length) } -int CryptoStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize CryptoStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { if (!_pOstr) return 0; @@ -156,7 +156,7 @@ int CryptoStreamBuf::writeToDevice(const char* buffer, std::streamsize length) std::size_t maxChunkSize = _buffer.size()/2; std::size_t count = 0; - while (count < length) + while (count < static_cast(length)) { // Truncate chunk size so that the maximum output fits into _buffer. std::size_t n = static_cast(length) - count; @@ -183,7 +183,7 @@ int CryptoStreamBuf::writeToDevice(const char* buffer, std::streamsize length) } } - return static_cast(count); + return static_cast(count); } diff --git a/Crypto/src/ECKeyImpl.cpp b/Crypto/src/ECKeyImpl.cpp index 2a89d3694..7662138e2 100644 --- a/Crypto/src/ECKeyImpl.cpp +++ b/Crypto/src/ECKeyImpl.cpp @@ -19,6 +19,7 @@ #include "Poco/FileStream.h" #include "Poco/Format.h" #include "Poco/StreamCopier.h" +#include #include #include #include @@ -229,11 +230,11 @@ int ECKeyImpl::getCurveNID(std::string& name) } else { - for (int i = 0; i < len; ++i) + for (std::size_t i = 0; i < len; ++i) { std::memset(buf, 0, bufLen); OBJ_obj2txt(buf, bufLen, OBJ_nid2obj(pCurves[i].nid), 0); - if (strncmp(name.c_str(), buf, name.size() > bufLen ? bufLen : name.size()) == 0) + if (strncmp(name.c_str(), buf, std::min(name.size(), static_cast(bufLen))) == 0) { nid = pCurves[i].nid; break; diff --git a/Crypto/src/EVPCipherImpl.cpp b/Crypto/src/EVPCipherImpl.cpp index 64f9110de..afb653f97 100644 --- a/Crypto/src/EVPCipherImpl.cpp +++ b/Crypto/src/EVPCipherImpl.cpp @@ -150,8 +150,8 @@ namespace std::streamsize finalize(unsigned char* output, std::streamsize length) { - poco_assert (length >= blockSize()); - poco_assert (_pos <= maxDataSize(output, length)); + poco_assert (length >= static_cast(blockSize())); + poco_assert (static_cast(_pos) <= maxDataSize(output, length)); std::string fmt = "EVPEncryptImpl::finalize():%s()"; std::size_t outLen = 0; if (_pos > 0) @@ -265,7 +265,7 @@ namespace std::size_t outLen = 0; if (EVP_PKEY_decrypt(_pCtx, nullptr, &outLen, _pBuf, static_cast(_pos)) <= 0) throwError(Poco::format(fmt, std::string("EVP_PKEY_decrypt(NULL)"))); - poco_assert (length >= outLen); + poco_assert (static_cast(length) >= outLen); if (_pos > 0) { if (EVP_PKEY_decrypt(_pCtx, output, &outLen, _pBuf, static_cast(_pos)) <= 0) diff --git a/Crypto/src/Envelope.cpp b/Crypto/src/Envelope.cpp index f19a95d78..40c4fe364 100644 --- a/Crypto/src/Envelope.cpp +++ b/Crypto/src/Envelope.cpp @@ -67,12 +67,12 @@ const Envelope::ByteVec& Envelope::seal(const ByteVec& plainData) { std::vector pEncKeys(_encKeys.size(), nullptr); std::vector encKeysSizes(_encKeys.size(), 0); - int i = 0; + std::size_t i = 0; for (const auto& k : _encKeys) pEncKeys[i++] = new Byte[k.size()]; int noOfKeys = static_cast(_pubKeys.size()); - if (_encKeys.size() != EVP_SealInit(_pCtx, _pCipher, &pEncKeys[0], &encKeysSizes[0], &_iv[0], &_pubKeys[0], noOfKeys)) + if (static_cast(_encKeys.size()) != EVP_SealInit(_pCtx, _pCipher, &pEncKeys[0], &encKeysSizes[0], &_iv[0], &_pubKeys[0], noOfKeys)) { i = 0; for (; i < _encKeys.size(); ++i) delete [] pEncKeys[i]; @@ -81,7 +81,7 @@ const Envelope::ByteVec& Envelope::seal(const ByteVec& plainData) i = 0; for (auto& k : _encKeys) { - if (encKeysSizes[i] != k.size()) + if (static_cast(encKeysSizes[i]) != k.size()) k.resize(encKeysSizes[i]); std::memcpy(&k[0], pEncKeys[i], encKeysSizes[i]); ++i; @@ -95,14 +95,14 @@ const Envelope::ByteVec& Envelope::seal(const ByteVec& plainData) _encContent.resize(plainDataSize + blockSize()); if (1 != EVP_SealUpdate(_pCtx, &_encContent[0], &len, &plainData[0], plainDataSize)) handleErrors(std::string("Envelope::seal():EVP_SealUpdate()")); - + cipherTextLen = len; - poco_assert (cipherTextLen < _encContent.size()); + poco_assert (static_cast(cipherTextLen) < _encContent.size()); if(1 != EVP_SealFinal(_pCtx, &_encContent[len], &len)) handleErrors(std::string("Envelope::seal():EVP_SealFinal()")); cipherTextLen += len; - poco_assert (cipherTextLen <= _encContent.size()); + poco_assert (static_cast(cipherTextLen) <= _encContent.size()); _encContent.resize(cipherTextLen); return _encContent; diff --git a/Crypto/src/RSACipherImpl.cpp b/Crypto/src/RSACipherImpl.cpp index 50228ca98..704ce1741 100644 --- a/Crypto/src/RSACipherImpl.cpp +++ b/Crypto/src/RSACipherImpl.cpp @@ -183,8 +183,8 @@ namespace std::streamsize RSAEncryptImpl::finalize(unsigned char* output, std::streamsize length) { - poco_assert (length >= blockSize()); - poco_assert (_pos <= maxDataSize()); + poco_assert (length >= static_cast(blockSize())); + poco_assert (static_cast(_pos) <= maxDataSize()); int rc = 0; if (_pos > 0) { @@ -301,7 +301,7 @@ namespace std::streamsize RSADecryptImpl::finalize(unsigned char* output, std::streamsize length) { - poco_assert (length >= blockSize()); + poco_assert (length >= static_cast(blockSize())); int rc = 0; if (_pos > 0) { diff --git a/Data/MySQL/src/Binder.cpp b/Data/MySQL/src/Binder.cpp index 66b189073..a7f1a80f8 100644 --- a/Data/MySQL/src/Binder.cpp +++ b/Data/MySQL/src/Binder.cpp @@ -159,7 +159,7 @@ void Binder::bind(std::size_t pos, const Poco::Data::CLOB& val, Direction dir) void Binder::bind(std::size_t pos, const DateTime& val, Direction dir) { poco_assert(dir == PD_IN); - MYSQL_TIME mt = {0}; + MYSQL_TIME mt = {}; mt.year = val.year(); mt.month = val.month(); @@ -180,7 +180,7 @@ void Binder::bind(std::size_t pos, const DateTime& val, Direction dir) void Binder::bind(std::size_t pos, const Date& val, Direction dir) { poco_assert(dir == PD_IN); - MYSQL_TIME mt = {0}; + MYSQL_TIME mt = {}; mt.year = val.year(); mt.month = val.month(); @@ -197,7 +197,7 @@ void Binder::bind(std::size_t pos, const Date& val, Direction dir) void Binder::bind(std::size_t pos, const Time& val, Direction dir) { poco_assert(dir == PD_IN); - MYSQL_TIME mt = {0}; + MYSQL_TIME mt = {}; mt.hour = val.hour(); mt.minute = val.minute(); @@ -286,7 +286,7 @@ void Binder::realBind(std::size_t pos, enum_field_types type, const void* buffer std::memset(&_bindArray[s], 0, sizeof(MYSQL_BIND) * (_bindArray.size() - s)); } - MYSQL_BIND b = {nullptr}; + MYSQL_BIND b = {}; b.buffer_type = type; b.buffer = const_cast(buffer); diff --git a/Data/MySQL/src/Extractor.cpp b/Data/MySQL/src/Extractor.cpp index b31dffe33..b4114f1c0 100644 --- a/Data/MySQL/src/Extractor.cpp +++ b/Data/MySQL/src/Extractor.cpp @@ -186,7 +186,7 @@ bool Extractor::extract(std::size_t pos, Poco::Data::CLOB& val) bool Extractor::extract(std::size_t pos, DateTime& val) { - MYSQL_TIME mt = {0}; + MYSQL_TIME mt = {}; if (!realExtractFixed(pos, MYSQL_TYPE_DATETIME, &mt)) return false; @@ -198,7 +198,7 @@ bool Extractor::extract(std::size_t pos, DateTime& val) bool Extractor::extract(std::size_t pos, Date& val) { - MYSQL_TIME mt = {0}; + MYSQL_TIME mt = {}; if (!realExtractFixed(pos, MYSQL_TYPE_DATE, &mt)) return false; @@ -210,7 +210,7 @@ bool Extractor::extract(std::size_t pos, Date& val) bool Extractor::extract(std::size_t pos, Time& val) { - MYSQL_TIME mt = {0}; + MYSQL_TIME mt = {}; if (!realExtractFixed(pos, MYSQL_TYPE_TIME, &mt)) return false; @@ -265,7 +265,7 @@ void Extractor::reset() bool Extractor::realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, bool isUnsigned) { - MYSQL_BIND bind = {nullptr}; + MYSQL_BIND bind = {}; my_bool isNull = 0; bind.is_null = &isNull; diff --git a/Data/ODBC/src/Binder.cpp b/Data/ODBC/src/Binder.cpp index 5ffba609d..dcf1b58b5 100644 --- a/Data/ODBC/src/Binder.cpp +++ b/Data/ODBC/src/Binder.cpp @@ -19,6 +19,7 @@ #include "Poco/Data/ODBC/ODBCException.h" #include "Poco/DateTime.h" #include "Poco/Exception.h" +#include #include @@ -649,7 +650,7 @@ void Binder::getColumnOrParameterSize(std::size_t pos, SQLINTEGER& size) paramSize = getParamSizeDirect(pos, size); if (colSize > 0 && paramSize > 0) - size = colSize < paramSize ? static_cast(colSize) : static_cast(paramSize); + size = static_cast(std::min(colSize, paramSize)); else if (colSize > 0) size = static_cast(colSize); else if (paramSize > 0) diff --git a/Data/ODBC/src/Unicode_UNIXODBC.cpp b/Data/ODBC/src/Unicode_UNIXODBC.cpp index 6e3783007..628ca938a 100644 --- a/Data/ODBC/src/Unicode_UNIXODBC.cpp +++ b/Data/ODBC/src/Unicode_UNIXODBC.cpp @@ -20,6 +20,7 @@ #include "Poco/UTF16Encoding.h" #include "Poco/Buffer.h" #include "Poco/Exception.h" +#include #include @@ -62,7 +63,7 @@ void makeUTF8(Poco::Buffer& buffer, SQLINTEGER length, SQLPOINTER pTar throw DataFormatException("Error converting UTF-16 to UTF-8"); std::memset(pTarget, 0, targetLength); - std::strncpy((char*) pTarget, result.c_str(), result.size() < targetLength ? result.size() : targetLength); + std::strncpy((char*) pTarget, result.c_str(), std::min(result.size(), static_cast(targetLength))); } diff --git a/Data/PostgreSQL/src/StatementExecutor.cpp b/Data/PostgreSQL/src/StatementExecutor.cpp index 3bd800d03..a9b31680a 100644 --- a/Data/PostgreSQL/src/StatementExecutor.cpp +++ b/Data/PostgreSQL/src/StatementExecutor.cpp @@ -43,7 +43,7 @@ namespace std::set placeholderSet; Poco::RegularExpression placeholderRE("[$][0-9]+"); - Poco::RegularExpression::Match match = { 0 , 0 }; // Match is a struct, not a class :-( + Poco::RegularExpression::Match match = {}; // Match is a struct, not a class :-( std::size_t startingPosition = 0; while (match.offset != std::string::npos) diff --git a/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h b/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h index 5c4e63572..4d9530b09 100644 --- a/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h +++ b/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h @@ -98,7 +98,7 @@ public: char_traits::move(_pReadBuffer + (4 - putback), this->gptr() - putback, putback); - int n = readFromDevice(_pReadBuffer + 4, _bufsize - 4); + std::streamsize n = readFromDevice(_pReadBuffer + 4, _bufsize - 4); if (n <= 0) return char_traits::eof(); this->setg(_pReadBuffer + (4 - putback), _pReadBuffer + 4, _pReadBuffer + 4 + n); @@ -150,22 +150,22 @@ protected: } private: - virtual int readFromDevice(char_type* /*buffer*/, std::streamsize /*length*/) + virtual std::streamsize readFromDevice(char_type* /*buffer*/, std::streamsize /*length*/) { return 0; } - virtual int writeToDevice(const char_type* /*buffer*/, std::streamsize /*length*/) + virtual std::streamsize writeToDevice(const char_type* /*buffer*/, std::streamsize /*length*/) { return 0; } - int flushBuffer() + std::streamsize flushBuffer() { - int n = int(this->pptr() - this->pbase()); + std::streamsize n = this->pptr() - this->pbase(); if (writeToDevice(this->pbase(), n) == n) { - this->pbump(-n); + this->pbump(static_cast(-n)); return n; } return -1; diff --git a/Foundation/include/Poco/BufferedStreamBuf.h b/Foundation/include/Poco/BufferedStreamBuf.h index 1e5acbcf2..23c687e1e 100644 --- a/Foundation/include/Poco/BufferedStreamBuf.h +++ b/Foundation/include/Poco/BufferedStreamBuf.h @@ -104,7 +104,7 @@ public: char_traits::move(_pBuffer + (4 - putback), this->gptr() - putback, putback); - int n = readFromDevice(_pBuffer + 4, _bufsize - 4); + std::streamsize n = readFromDevice(_pBuffer + 4, _bufsize - 4); if (n <= 0) return char_traits::eof(); this->setg(_pBuffer + (4 - putback), _pBuffer + 4, _pBuffer + 4 + n); @@ -134,22 +134,22 @@ protected: } private: - virtual int readFromDevice(char_type* /*buffer*/, std::streamsize /*length*/) + virtual std::streamsize readFromDevice(char_type* /*buffer*/, std::streamsize /*length*/) { return 0; } - virtual int writeToDevice(const char_type* /*buffer*/, std::streamsize /*length*/) + virtual std::streamsize writeToDevice(const char_type* /*buffer*/, std::streamsize /*length*/) { return 0; } - int flushBuffer() + std::streamsize flushBuffer() { - int n = int(this->pptr() - this->pbase()); + std::streamsize n = this->pptr() - this->pbase(); if (writeToDevice(this->pbase(), n) == n) { - this->pbump(-n); + this->pbump(static_cast(-n)); return n; } return -1; diff --git a/Foundation/include/Poco/DeflatingStream.h b/Foundation/include/Poco/DeflatingStream.h index 5cc1bd246..90b0a05b3 100644 --- a/Foundation/include/Poco/DeflatingStream.h +++ b/Foundation/include/Poco/DeflatingStream.h @@ -86,8 +86,8 @@ public: /// Must be called when deflating to an output stream. protected: - int readFromDevice(char* buffer, std::streamsize length) override; - int writeToDevice(const char* buffer, std::streamsize length) override; + std::streamsize readFromDevice(char* buffer, std::streamsize length) override; + std::streamsize writeToDevice(const char* buffer, std::streamsize length) override; int sync() override; private: diff --git a/Foundation/include/Poco/DigestStream.h b/Foundation/include/Poco/DigestStream.h index 1881bdc4e..ba0a438d2 100644 --- a/Foundation/include/Poco/DigestStream.h +++ b/Foundation/include/Poco/DigestStream.h @@ -37,8 +37,8 @@ public: DigestBuf(DigestEngine& eng, std::istream& istr); DigestBuf(DigestEngine& eng, std::ostream& ostr); ~DigestBuf() override; - int readFromDevice(char *buffer, std::streamsize length) override; - int writeToDevice(const char *buffer, std::streamsize length) override; + std::streamsize readFromDevice(char *buffer, std::streamsize length) override; + std::streamsize writeToDevice(const char *buffer, std::streamsize length) override; void close(); private: diff --git a/Foundation/include/Poco/FIFOBufferStream.h b/Foundation/include/Poco/FIFOBufferStream.h index 93d3ec7da..d98507df2 100644 --- a/Foundation/include/Poco/FIFOBufferStream.h +++ b/Foundation/include/Poco/FIFOBufferStream.h @@ -56,8 +56,8 @@ public: /// Returns the underlying FIFO buffer reference. protected: - int readFromDevice(char* buffer, std::streamsize length) override; - int writeToDevice(const char* buffer, std::streamsize length) override; + std::streamsize readFromDevice(char* buffer, std::streamsize length) override; + std::streamsize writeToDevice(const char* buffer, std::streamsize length) override; private: enum diff --git a/Foundation/include/Poco/FileStream_POSIX.h b/Foundation/include/Poco/FileStream_POSIX.h index 73458353d..3f31dc8bc 100644 --- a/Foundation/include/Poco/FileStream_POSIX.h +++ b/Foundation/include/Poco/FileStream_POSIX.h @@ -76,8 +76,8 @@ protected: BUFFER_SIZE = 4096 }; - int readFromDevice(char* buffer, std::streamsize length) override; - int writeToDevice(const char* buffer, std::streamsize length) override; + std::streamsize readFromDevice(char* buffer, std::streamsize length) override; + std::streamsize writeToDevice(const char* buffer, std::streamsize length) override; private: std::string _path; diff --git a/Foundation/include/Poco/FileStream_WIN32.h b/Foundation/include/Poco/FileStream_WIN32.h index f4b8c15b2..115eace86 100644 --- a/Foundation/include/Poco/FileStream_WIN32.h +++ b/Foundation/include/Poco/FileStream_WIN32.h @@ -74,8 +74,8 @@ protected: BUFFER_SIZE = 4096 }; - int readFromDevice(char* buffer, std::streamsize length) override; - int writeToDevice(const char* buffer, std::streamsize length) override; + std::streamsize readFromDevice(char* buffer, std::streamsize length) override; + std::streamsize writeToDevice(const char* buffer, std::streamsize length) override; private: std::string _path; diff --git a/Foundation/include/Poco/InflatingStream.h b/Foundation/include/Poco/InflatingStream.h index 0205a93f9..946f4336d 100644 --- a/Foundation/include/Poco/InflatingStream.h +++ b/Foundation/include/Poco/InflatingStream.h @@ -78,8 +78,8 @@ public: /// Resets the stream buffer. protected: - int readFromDevice(char* buffer, std::streamsize length) override; - int writeToDevice(const char* buffer, std::streamsize length) override; + std::streamsize readFromDevice(char* buffer, std::streamsize length) override; + std::streamsize writeToDevice(const char* buffer, std::streamsize length) override; int sync() override; private: diff --git a/Foundation/include/Poco/PipeStream.h b/Foundation/include/Poco/PipeStream.h index ac3f65c30..f1a26cd8f 100644 --- a/Foundation/include/Poco/PipeStream.h +++ b/Foundation/include/Poco/PipeStream.h @@ -44,8 +44,8 @@ public: /// Closes the pipe. protected: - int readFromDevice(char* buffer, std::streamsize length) override; - int writeToDevice(const char* buffer, std::streamsize length) override; + std::streamsize readFromDevice(char* buffer, std::streamsize length) override; + std::streamsize writeToDevice(const char* buffer, std::streamsize length) override; private: enum diff --git a/Foundation/include/Poco/RandomStream.h b/Foundation/include/Poco/RandomStream.h index 720ed9327..d5e5e3e82 100644 --- a/Foundation/include/Poco/RandomStream.h +++ b/Foundation/include/Poco/RandomStream.h @@ -37,7 +37,7 @@ class Foundation_API RandomBuf: public BufferedStreamBuf public: RandomBuf(); ~RandomBuf() override; - int readFromDevice(char* buffer, std::streamsize length) override; + std::streamsize readFromDevice(char* buffer, std::streamsize length) override; }; diff --git a/Foundation/include/Poco/UUID.h b/Foundation/include/Poco/UUID.h index 3ffda7368..e4e383c35 100644 --- a/Foundation/include/Poco/UUID.h +++ b/Foundation/include/Poco/UUID.h @@ -138,7 +138,7 @@ public: /// Returns the namespace identifier for the X500 namespace. protected: - UUID(UInt32 timeLow, UInt32 timeMid, UInt32 timeHiAndVersion, UInt16 clockSeq, UInt8 node[]); + UUID(UInt32 timeLow, UInt16 timeMid, UInt16 timeHiAndVersion, UInt16 clockSeq, UInt8 node[]); UUID(const char* bytes, Version version); int compare(const UUID& uuid) const; static void appendHex(std::string& str, UInt8 n); diff --git a/Foundation/src/DateTime.cpp b/Foundation/src/DateTime.cpp index ea8108098..fd8795285 100644 --- a/Foundation/src/DateTime.cpp +++ b/Foundation/src/DateTime.cpp @@ -35,12 +35,14 @@ DateTime::DateTime() DateTime::DateTime(const tm& tmStruct): - _year(tmStruct.tm_year + 1900), - _month(tmStruct.tm_mon + 1), - _day(tmStruct.tm_mday), - _hour(tmStruct.tm_hour), - _minute(tmStruct.tm_min), - _second(tmStruct.tm_sec), + // Note: Member variables are short to minimize memory footprint. + // All valid DateTime values fit within short range; inputs are validated by checkValid(). + _year(static_cast(tmStruct.tm_year + 1900)), + _month(static_cast(tmStruct.tm_mon + 1)), + _day(static_cast(tmStruct.tm_mday)), + _hour(static_cast(tmStruct.tm_hour)), + _minute(static_cast(tmStruct.tm_min)), + _second(static_cast(tmStruct.tm_sec)), _millisecond(0), _microsecond(0) { @@ -60,14 +62,14 @@ DateTime::DateTime(const Timestamp& timestamp): DateTime::DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond): - _year(year), - _month(month), - _day(day), - _hour(hour), - _minute(minute), - _second(second), - _millisecond(millisecond), - _microsecond(microsecond) + _year(static_cast(year)), + _month(static_cast(month)), + _day(static_cast(day)), + _hour(static_cast(hour)), + _minute(static_cast(minute)), + _second(static_cast(second)), + _millisecond(static_cast(millisecond)), + _microsecond(static_cast(microsecond)) { checkValid(); _utcTime = toUtcTime(toJulianDay(year, month, day)) + @@ -152,14 +154,14 @@ DateTime& DateTime::operator = (double julianDay) DateTime& DateTime::assign(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond) { _utcTime = toUtcTime(toJulianDay(year, month, day)) + 10*(hour*Timespan::HOURS + minute*Timespan::MINUTES + second*Timespan::SECONDS + millisecond*Timespan::MILLISECONDS + microsecond); - _year = year; - _month = month; - _day = day; - _hour = hour; - _minute = minute; - _second = second; - _millisecond = millisecond; - _microsecond = microsecond; + _year = static_cast(year); + _month = static_cast(month); + _day = static_cast(day); + _hour = static_cast(hour); + _minute = static_cast(minute); + _second = static_cast(second); + _millisecond = static_cast(millisecond); + _microsecond = static_cast(microsecond); checkValid(); return *this; @@ -373,7 +375,7 @@ void DateTime::normalize() if (_day > daysOfMonth(_year, _month)) { - _day -= daysOfMonth(_year, _month); + _day = static_cast(_day - daysOfMonth(_year, _month)); if (++_month > 12) { ++_year; @@ -443,7 +445,7 @@ void DateTime::computeDaytime() _month = 12; _year--; } - _day = daysOfMonth(_year, _month); + _day = static_cast(daysOfMonth(_year, _month)); } } else if (hour == 0 && _hour == 23) @@ -460,11 +462,11 @@ void DateTime::computeDaytime() _day = 1; } } - _hour = hour; - _minute = span.minutes(); - _second = span.seconds(); - _millisecond = span.milliseconds(); - _microsecond = span.microseconds(); + _hour = static_cast(hour); + _minute = static_cast(span.minutes()); + _second = static_cast(span.seconds()); + _millisecond = static_cast(span.milliseconds()); + _microsecond = static_cast(span.microseconds()); } diff --git a/Foundation/src/DeflatingStream.cpp b/Foundation/src/DeflatingStream.cpp index 875728468..508f34311 100644 --- a/Foundation/src/DeflatingStream.cpp +++ b/Foundation/src/DeflatingStream.cpp @@ -180,7 +180,7 @@ int DeflatingStreamBuf::sync() } -int DeflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize DeflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length) { if (!_pIstr) return 0; if (_pZstr->avail_in == 0 && !_eof) @@ -211,12 +211,12 @@ int DeflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length) if (_eof && rc == Z_STREAM_END) { _pIstr = nullptr; - return static_cast(length) - _pZstr->avail_out; + return length - _pZstr->avail_out; } if (rc != Z_OK) throw IOException(zError(rc)); if (_pZstr->avail_out == 0) { - return static_cast(length); + return length; } if (_pZstr->avail_in == 0) { @@ -242,7 +242,7 @@ int DeflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length) } -int DeflatingStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize DeflatingStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { if (length == 0 || !_pOstr) return 0; @@ -270,7 +270,7 @@ int DeflatingStreamBuf::writeToDevice(const char* buffer, std::streamsize length break; } } - return static_cast(length); + return length; } diff --git a/Foundation/src/DigestStream.cpp b/Foundation/src/DigestStream.cpp index 0ceed3403..d9590189a 100644 --- a/Foundation/src/DigestStream.cpp +++ b/Foundation/src/DigestStream.cpp @@ -53,24 +53,24 @@ DigestBuf::~DigestBuf() } -int DigestBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize DigestBuf::readFromDevice(char* buffer, std::streamsize length) { if (_pIstr && _pIstr->good()) { _pIstr->read(buffer, length); std::streamsize n = _pIstr->gcount(); if (n > 0) _eng.update(buffer, static_cast(n)); - return static_cast(n); + return n; } return -1; } -int DigestBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize DigestBuf::writeToDevice(const char* buffer, std::streamsize length) { _eng.update(buffer, (unsigned) length); if (_pOstr) _pOstr->write(buffer, length); - return static_cast(length); + return length; } diff --git a/Foundation/src/FIFOBufferStream.cpp b/Foundation/src/FIFOBufferStream.cpp index 90902868a..ffcc8190a 100644 --- a/Foundation/src/FIFOBufferStream.cpp +++ b/Foundation/src/FIFOBufferStream.cpp @@ -70,17 +70,17 @@ FIFOBufferStreamBuf::~FIFOBufferStreamBuf() } -int FIFOBufferStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize FIFOBufferStreamBuf::readFromDevice(char* buffer, std::streamsize length) { poco_assert (length > 0); - return static_cast(_fifoBuffer.read(buffer, static_cast(length))); + return static_cast(_fifoBuffer.read(buffer, static_cast(length))); } -int FIFOBufferStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize FIFOBufferStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { poco_assert (length > 0); - return static_cast(_fifoBuffer.write(buffer, static_cast(length))); + return static_cast(_fifoBuffer.write(buffer, static_cast(length))); } diff --git a/Foundation/src/FileStream_POSIX.cpp b/Foundation/src/FileStream_POSIX.cpp index 1293edd2e..140ce79f9 100644 --- a/Foundation/src/FileStream_POSIX.cpp +++ b/Foundation/src/FileStream_POSIX.cpp @@ -88,34 +88,34 @@ void FileStreamBuf::openHandle(NativeHandle fd, std::ios::openmode mode) } -int FileStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize FileStreamBuf::readFromDevice(char* buffer, std::streamsize length) { if (_fd == -1) return -1; if (getMode() & std::ios::out) sync(); - int n = ::read(_fd, buffer, length); + auto n = ::read(_fd, buffer, length); if (n == -1) File::handleLastError(_path); _pos += n; - return n; + return static_cast(n); } -int FileStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize FileStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { if (_fd == -1) return -1; #if defined(POCO_VXWORKS) - int n = ::write(_fd, const_cast(buffer), length); + auto n = ::write(_fd, const_cast(buffer), length); #else - int n = ::write(_fd, buffer, length); + auto n = ::write(_fd, buffer, length); #endif if (n == -1) File::handleLastError(_path); _pos += n; - return n; + return static_cast(n); } diff --git a/Foundation/src/FileStream_WIN32.cpp b/Foundation/src/FileStream_WIN32.cpp index f8a1a9c5b..f2872e650 100644 --- a/Foundation/src/FileStream_WIN32.cpp +++ b/Foundation/src/FileStream_WIN32.cpp @@ -89,7 +89,7 @@ void FileStreamBuf::openHandle(NativeHandle handle, std::ios::openmode mode) } -int FileStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize FileStreamBuf::readFromDevice(char* buffer, std::streamsize length) { if (INVALID_HANDLE_VALUE == _handle || !(getMode() & std::ios::in)) return -1; @@ -111,11 +111,11 @@ int FileStreamBuf::readFromDevice(char* buffer, std::streamsize length) _pos += bytesRead; - return static_cast(bytesRead); + return static_cast(bytesRead); } -int FileStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize FileStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { if (INVALID_HANDLE_VALUE == _handle || !(getMode() & std::ios::out)) return -1; @@ -137,7 +137,7 @@ int FileStreamBuf::writeToDevice(const char* buffer, std::streamsize length) _pos += bytesWritten; - return static_cast(bytesWritten); + return static_cast(bytesWritten); } diff --git a/Foundation/src/InflatingStream.cpp b/Foundation/src/InflatingStream.cpp index 9e5b06c3b..1e3ae8ca4 100644 --- a/Foundation/src/InflatingStream.cpp +++ b/Foundation/src/InflatingStream.cpp @@ -140,7 +140,7 @@ void InflatingStreamBuf::reset() } -int InflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize InflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length) { if (_eof || !_pIstr) return 0; @@ -173,11 +173,11 @@ int InflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length) if (rc == Z_STREAM_END) { _eof = true; - return static_cast(length) - _pZstr->avail_out; + return length - _pZstr->avail_out; } if (rc != Z_OK) throw IOException(zError(rc)); if (_pZstr->avail_out == 0) - return static_cast(length); + return length; if (_pZstr->avail_in == 0) { int n = 0; @@ -191,13 +191,13 @@ int InflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length) _pZstr->next_in = (unsigned char*) _buffer; _pZstr->avail_in = n; } - else return static_cast(length) - _pZstr->avail_out; + else return length - _pZstr->avail_out; } } } -int InflatingStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize InflatingStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { if (length == 0 || !_pOstr) return 0; @@ -231,7 +231,7 @@ int InflatingStreamBuf::writeToDevice(const char* buffer, std::streamsize length break; } } - return static_cast(length); + return length; } diff --git a/Foundation/src/Logger.cpp b/Foundation/src/Logger.cpp index 01c00c2a5..1b8a90d19 100644 --- a/Foundation/src/Logger.cpp +++ b/Foundation/src/Logger.cpp @@ -245,7 +245,7 @@ void Logger::formatDump(std::string& message, const void* buffer, std::size_t le message.reserve(message.size() + length*6); if (!message.empty()) message.append("\n"); unsigned char* base = (unsigned char*) buffer; - int addr = 0; + std::size_t addr = 0; while (addr < length) { if (addr > 0) message.append("\n"); diff --git a/Foundation/src/Path.cpp b/Foundation/src/Path.cpp index e2a4f6bab..96d8fc8e5 100644 --- a/Foundation/src/Path.cpp +++ b/Foundation/src/Path.cpp @@ -454,9 +454,9 @@ Path& Path::setDevice(const std::string& device) const std::string& Path::directory(int n) const { - poco_assert (0 <= n && n <= _dirs.size()); + poco_assert (0 <= n && static_cast(n) <= _dirs.size()); - if (n < _dirs.size()) + if (static_cast(n) < _dirs.size()) return _dirs[n]; else return _name; @@ -465,9 +465,9 @@ const std::string& Path::directory(int n) const const std::string& Path::operator [] (int n) const { - poco_assert (0 <= n && n <= _dirs.size()); + poco_assert (0 <= n && static_cast(n) <= _dirs.size()); - if (n < _dirs.size()) + if (static_cast(n) < _dirs.size()) return _dirs[n]; else return _name; @@ -929,7 +929,7 @@ void Path::parseVMS(const std::string& path) if (!_absolute) throw PathSyntaxException(path); ++it; if (it != end && *it == '.') throw PathSyntaxException(path); - int d = int(_dirs.size()); + auto d = _dirs.size(); while (it != end && *it != ']') { name.clear(); diff --git a/Foundation/src/PipeStream.cpp b/Foundation/src/PipeStream.cpp index 9d40bd3a3..43886cc36 100644 --- a/Foundation/src/PipeStream.cpp +++ b/Foundation/src/PipeStream.cpp @@ -35,15 +35,15 @@ PipeStreamBuf::~PipeStreamBuf() } -int PipeStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize PipeStreamBuf::readFromDevice(char* buffer, std::streamsize length) { - return _pipe.readBytes(buffer, (int) length); + return _pipe.readBytes(buffer, static_cast(length)); } -int PipeStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize PipeStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { - return _pipe.writeBytes(buffer, (int) length); + return _pipe.writeBytes(buffer, static_cast(length)); } diff --git a/Foundation/src/RandomStream.cpp b/Foundation/src/RandomStream.cpp index 22f5f18dc..3cad0b118 100644 --- a/Foundation/src/RandomStream.cpp +++ b/Foundation/src/RandomStream.cpp @@ -38,16 +38,16 @@ RandomBuf::~RandomBuf() } -int RandomBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize RandomBuf::readFromDevice(char* buffer, std::streamsize length) { - int n = 0; + std::streamsize n = 0; #if defined(POCO_OS_FAMILY_WINDOWS) HCRYPTPROV hProvider = 0; CryptAcquireContext(&hProvider, nullptr, nullptr, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); CryptGenRandom(hProvider, (DWORD) length, (BYTE*) buffer); CryptReleaseContext(hProvider, 0); - n = static_cast(length); + n = length; #else #if defined(POCO_OS_FAMILY_UNIX) int fd = open("/dev/urandom", O_RDONLY, 0); diff --git a/Foundation/src/StreamConverter.cpp b/Foundation/src/StreamConverter.cpp index 769b51c24..48189369a 100644 --- a/Foundation/src/StreamConverter.cpp +++ b/Foundation/src/StreamConverter.cpp @@ -111,10 +111,10 @@ int StreamConverterBuf::writeToDevice(char c) ++_errors; return -1; } - int n = _outEncoding.convert(uc, _buffer, sizeof(_buffer)); - if (n == 0) n = _outEncoding.convert(_defaultChar, _buffer, sizeof(_buffer)); - poco_assert_dbg (n <= sizeof(_buffer)); - _pOstr->write((char*) _buffer, n); + int written = _outEncoding.convert(uc, _buffer, sizeof(_buffer)); + if (written == 0) written = _outEncoding.convert(_defaultChar, _buffer, sizeof(_buffer)); + poco_assert_dbg (written <= sizeof(_buffer)); + _pOstr->write((char*) _buffer, written); _sequenceLength = 0; _pos = 0; } diff --git a/Foundation/src/ThreadPool.cpp b/Foundation/src/ThreadPool.cpp index b722c14a4..a970649b6 100644 --- a/Foundation/src/ThreadPool.cpp +++ b/Foundation/src/ThreadPool.cpp @@ -385,7 +385,7 @@ void ThreadPool::collect() void ThreadPool::housekeep() { _age = 0; - if (_threads.size() <= _minCapacity) + if (_threads.size() <= static_cast(_minCapacity)) return; ThreadVec idleThreads; @@ -438,7 +438,7 @@ PooledThread* ThreadPool::getThread() } if (!pThread) { - if (_threads.size() < _maxCapacity) + if (_threads.size() < static_cast(_maxCapacity)) { pThread = createThread(); try diff --git a/Foundation/src/Timezone_WIN32.cpp b/Foundation/src/Timezone_WIN32.cpp index 7ea0375d1..0126a07c2 100644 --- a/Foundation/src/Timezone_WIN32.cpp +++ b/Foundation/src/Timezone_WIN32.cpp @@ -25,7 +25,7 @@ namespace Poco { int Timezone::utcOffset() { TIME_ZONE_INFORMATION tzInfo; - DWORD dstFlag = GetTimeZoneInformation(&tzInfo); + (void) GetTimeZoneInformation(&tzInfo); return -tzInfo.Bias*60; } @@ -75,7 +75,7 @@ std::string Timezone::standardName() { std::string result; TIME_ZONE_INFORMATION tzInfo; - DWORD dstFlag = GetTimeZoneInformation(&tzInfo); + (void) GetTimeZoneInformation(&tzInfo); WCHAR* ptr = tzInfo.StandardName; UnicodeConverter::toUTF8(ptr, result); return result; @@ -86,7 +86,7 @@ std::string Timezone::dstName() { std::string result; TIME_ZONE_INFORMATION tzInfo; - DWORD dstFlag = GetTimeZoneInformation(&tzInfo); + (void) GetTimeZoneInformation(&tzInfo); WCHAR* ptr = tzInfo.DaylightName; UnicodeConverter::toUTF8(ptr, result); return result; diff --git a/Foundation/src/UUID.cpp b/Foundation/src/UUID.cpp index 885708c0a..8819b651f 100644 --- a/Foundation/src/UUID.cpp +++ b/Foundation/src/UUID.cpp @@ -55,7 +55,7 @@ UUID::UUID(const char* uuid) } -UUID::UUID(UInt32 timeLow, UInt32 timeMid, UInt32 timeHiAndVersion, UInt16 clockSeq, UInt8 node[]): +UUID::UUID(UInt32 timeLow, UInt16 timeMid, UInt16 timeHiAndVersion, UInt16 clockSeq, UInt8 node[]): _timeLow(timeLow), _timeMid(timeMid), _timeHiAndVersion(timeHiAndVersion), diff --git a/JSON/include/Poco/JSON/Object.h b/JSON/include/Poco/JSON/Object.h index 5913b9208..a1949b87c 100644 --- a/JSON/include/Poco/JSON/Object.h +++ b/JSON/include/Poco/JSON/Object.h @@ -271,7 +271,7 @@ private: } template - void doStringify(const C& container, std::ostream& out, unsigned int indent, unsigned int step) const + void doStringify(const C& container, std::ostream& out, unsigned int indent, int step) const { int options = Poco::JSON_WRAP_STRINGS; options |= _escapeUnicode ? Poco::JSON_ESCAPE_UNICODE : 0; @@ -290,14 +290,14 @@ private: Stringifier::stringify(getKey(it), out, indent, step, options); out << ((indent > 0) ? ": " : ":"); - Stringifier::stringify(getValue(it), out, indent + step, step, options); + Stringifier::stringify(getValue(it), out, indent + static_cast(step), step, options); if (++it != container.end()) out << ','; if (step > 0) out << std::endl; } - if (indent >= step) indent -= step; + if (step > 0 && indent >= static_cast(step)) indent -= static_cast(step); for (unsigned int i = 0; i < indent; i++) out << ' '; diff --git a/JSON/src/Array.cpp b/JSON/src/Array.cpp index 230153d27..c74b25d31 100644 --- a/JSON/src/Array.cpp +++ b/JSON/src/Array.cpp @@ -161,7 +161,7 @@ void Array::stringify(std::ostream& out, unsigned int indent, int step) const options |= _escapeUnicode ? Poco::JSON_ESCAPE_UNICODE : 0; options |= _lowercaseHex ? Poco::JSON_LOWERCASE_HEX : 0; - if (step == -1) step = indent; + if (step == -1) step = static_cast(indent); out << "["; @@ -169,9 +169,9 @@ void Array::stringify(std::ostream& out, unsigned int indent, int step) const for (auto it = _values.begin(); it != _values.end();) { - for (int i = 0; i < indent; i++) out << ' '; + for (unsigned int i = 0; i < indent; i++) out << ' '; - Stringifier::stringify(*it, out, indent + step, step, options); + Stringifier::stringify(*it, out, indent + static_cast(step), step, options); if (++it != _values.end()) { @@ -182,9 +182,9 @@ void Array::stringify(std::ostream& out, unsigned int indent, int step) const if (step > 0) out << '\n'; - if (indent >= step) indent -= step; + if (step > 0 && indent >= static_cast(step)) indent -= static_cast(step); - for (int i = 0; i < indent; i++) out << ' '; + for (unsigned int i = 0; i < indent; i++) out << ' '; out << "]"; } diff --git a/JSON/src/Object.cpp b/JSON/src/Object.cpp index e96cdbce7..2cee3b700 100644 --- a/JSON/src/Object.cpp +++ b/JSON/src/Object.cpp @@ -186,7 +186,7 @@ Object::NameList Object::getNames() const void Object::stringify(std::ostream& out, unsigned int indent, int step) const { - if (step < 0) step = indent; + if (step < 0) step = static_cast(indent); if (!_preserveInsOrder) doStringify(_values, out, indent, step); diff --git a/JSON/src/Stringifier.cpp b/JSON/src/Stringifier.cpp index e1f37de2f..0a7a8f8a2 100644 --- a/JSON/src/Stringifier.cpp +++ b/JSON/src/Stringifier.cpp @@ -29,7 +29,7 @@ void Stringifier::stringify(const Var& any, std::ostream& out, unsigned int inde bool escapeUnicode = ((options & Poco::JSON_ESCAPE_UNICODE) != 0); bool lowercaseHex = ((options & Poco::JSON_LOWERCASE_HEX) != 0); - if (step == -1) step = indent; + if (step == -1) step = static_cast(indent); if (any.type() == typeid(Object)) { diff --git a/JSON/src/Template.cpp b/JSON/src/Template.cpp index c9878a537..c12559b5d 100644 --- a/JSON/src/Template.cpp +++ b/JSON/src/Template.cpp @@ -225,7 +225,7 @@ public: void render(const Var& data, std::ostream& out) const override { - int count = 0; + std::size_t count = 0; for (auto it = _queries.begin(); it != _queries.end(); ++it, ++count) { if ((*it)->apply(data) && _parts.size() > count) @@ -260,7 +260,7 @@ public: Array::Ptr array = query.findArray(_query); if (!array.isNull()) { - for (int i = 0; i < array->size(); i++) + for (std::size_t i = 0; i < array->size(); i++) { Var value = array->get(i); dataObject->set(_name, value); diff --git a/JSON/testsuite/src/JSONTest.cpp b/JSON/testsuite/src/JSONTest.cpp index 30cca35ca..fd2a91ad4 100644 --- a/JSON/testsuite/src/JSONTest.cpp +++ b/JSON/testsuite/src/JSONTest.cpp @@ -1587,29 +1587,29 @@ void JSONTest::testStringify() { std::string jsonStr = R"json({"default":"\u0007\u0007"})json"; auto jsonStrUnescape = Poco::UTF8::unescape(jsonStr); - Poco::JSON::Parser parser; - Poco::Dynamic::Var result = parser.parse(jsonStr); - const auto & obj = result.extract(); + Poco::JSON::Parser parser1; + Poco::Dynamic::Var result1 = parser1.parse(jsonStr); + const auto & obj = result1.extract(); auto default_val = obj->get("default"); - Poco::JSON::Object::Ptr json = new Poco::JSON::Object(); - json->set("default", default_val); - std::stringstream ss; - json->stringify(ss); - assertEqual(ss.str(), jsonStr); + Poco::JSON::Object::Ptr json1 = new Poco::JSON::Object(); + json1->set("default", default_val); + std::stringstream ss1; + json1->stringify(ss1); + assertEqual(ss1.str(), jsonStr); } { std::string jsonStr = R"json({"default":"\u0050\u0050"})json"; auto jsonStrUnescape = Poco::UTF8::unescape(jsonStr); - Poco::JSON::Parser parser; - Poco::Dynamic::Var result = parser.parse(jsonStr); - const auto & obj = result.extract(); + Poco::JSON::Parser parser2; + Poco::Dynamic::Var result2 = parser2.parse(jsonStr); + const auto & obj = result2.extract(); auto default_val = obj->get("default"); - Poco::JSON::Object::Ptr json = new Poco::JSON::Object(); - json->set("default", default_val); - std::stringstream ss; - json->stringify(ss); - assertEqual(ss.str(), jsonStrUnescape); + Poco::JSON::Object::Ptr json2 = new Poco::JSON::Object(); + json2->set("default", default_val); + std::stringstream ss2; + json2->stringify(ss2); + assertEqual(ss2.str(), jsonStrUnescape); } } diff --git a/MongoDB/src/TopologyDescription.cpp b/MongoDB/src/TopologyDescription.cpp index 73789df0a..9b634d744 100644 --- a/MongoDB/src/TopologyDescription.cpp +++ b/MongoDB/src/TopologyDescription.cpp @@ -336,7 +336,7 @@ void TopologyDescription::updateTopologyType() int otherRsMembers = 0; // Non-primary replica set members (secondaries, arbiters, etc.) int mongosCount = 0; int standaloneCount = 0; - int unknownCount = 0; + [[maybe_unused]] int unknownCount = 0; for (const auto& [address, server] : _servers) { diff --git a/MongoDB/testsuite/src/MongoDBTestOpMsg.cpp b/MongoDB/testsuite/src/MongoDBTestOpMsg.cpp index f46d49d89..82fd6393b 100644 --- a/MongoDB/testsuite/src/MongoDBTestOpMsg.cpp +++ b/MongoDB/testsuite/src/MongoDBTestOpMsg.cpp @@ -148,7 +148,7 @@ void MongoDBTest::testOpCmdFind() const auto& birthDateTimestamp = doc->get("birthdate"); Poco::DateTime birthDate(birthDateTimestamp); assertTrue (birthDate.year() == 1969 && birthDate.month() == 3 && birthDate.day() == 9); - const auto& lastupdatedTimestamp = doc->get("lastupdated"); + [[maybe_unused]] const auto& lastupdatedTimestamp = doc->get("lastupdated"); assertTrue (doc->isType("unknown")); bool active = doc->get("active"); assertEquals (false, active); diff --git a/MongoDB/testsuite/src/ReplicaSetTest.cpp b/MongoDB/testsuite/src/ReplicaSetTest.cpp index 49643f705..516991294 100644 --- a/MongoDB/testsuite/src/ReplicaSetTest.cpp +++ b/MongoDB/testsuite/src/ReplicaSetTest.cpp @@ -1314,7 +1314,7 @@ void ReplicaSetTest::testReadPreferenceWithTags() auto selected = pref.selectServers(topology); // At least the tagged server should be selected - bool foundTaggedServer = false; + [[maybe_unused]] bool foundTaggedServer = false; for (const auto& server : selected) { if (server.address().toString() == "localhost:27018"s) diff --git a/Net/include/Poco/Net/HTTPChunkedStream.h b/Net/include/Poco/Net/HTTPChunkedStream.h index d9c8029e4..d2d70aa4d 100644 --- a/Net/include/Poco/Net/HTTPChunkedStream.h +++ b/Net/include/Poco/Net/HTTPChunkedStream.h @@ -46,8 +46,8 @@ public: void close(); protected: - int readFromDevice(char* buffer, std::streamsize length); - int writeToDevice(const char* buffer, std::streamsize length); + std::streamsize readFromDevice(char* buffer, std::streamsize length); + std::streamsize writeToDevice(const char* buffer, std::streamsize length); private: HTTPSession& _session; diff --git a/Net/include/Poco/Net/HTTPFixedLengthStream.h b/Net/include/Poco/Net/HTTPFixedLengthStream.h index 921fa2b7b..26468fff9 100644 --- a/Net/include/Poco/Net/HTTPFixedLengthStream.h +++ b/Net/include/Poco/Net/HTTPFixedLengthStream.h @@ -51,8 +51,8 @@ public: ~HTTPFixedLengthStreamBuf(); protected: - int readFromDevice(char* buffer, std::streamsize length); - int writeToDevice(const char* buffer, std::streamsize length); + std::streamsize readFromDevice(char* buffer, std::streamsize length); + std::streamsize writeToDevice(const char* buffer, std::streamsize length); private: HTTPSession& _session; diff --git a/Net/include/Poco/Net/HTTPHeaderStream.h b/Net/include/Poco/Net/HTTPHeaderStream.h index 985ff56d5..61da780e8 100644 --- a/Net/include/Poco/Net/HTTPHeaderStream.h +++ b/Net/include/Poco/Net/HTTPHeaderStream.h @@ -44,8 +44,8 @@ public: ~HTTPHeaderStreamBuf(); protected: - int readFromDevice(char* buffer, std::streamsize length); - int writeToDevice(const char* buffer, std::streamsize length); + std::streamsize readFromDevice(char* buffer, std::streamsize length); + std::streamsize writeToDevice(const char* buffer, std::streamsize length); private: HTTPSession& _session; diff --git a/Net/include/Poco/Net/HTTPReactorServerSession.h b/Net/include/Poco/Net/HTTPReactorServerSession.h index 22e897f16..11e73f03a 100644 --- a/Net/include/Poco/Net/HTTPReactorServerSession.h +++ b/Net/include/Poco/Net/HTTPReactorServerSession.h @@ -51,10 +51,10 @@ private: private: std::string& _buf; - char* _pcur; - char* _pend; - int _idx; - int _complete; + char* _pcur{nullptr}; + char* _pend{nullptr}; + int _idx{0}; + int _complete{0}; StreamSocket _realsocket; }; diff --git a/Net/include/Poco/Net/HTTPStream.h b/Net/include/Poco/Net/HTTPStream.h index 2837c24cf..7c309c574 100644 --- a/Net/include/Poco/Net/HTTPStream.h +++ b/Net/include/Poco/Net/HTTPStream.h @@ -45,8 +45,8 @@ public: void close(); protected: - int readFromDevice(char* buffer, std::streamsize length); - int writeToDevice(const char* buffer, std::streamsize length); + std::streamsize readFromDevice(char* buffer, std::streamsize length); + std::streamsize writeToDevice(const char* buffer, std::streamsize length); private: HTTPSession& _session; diff --git a/Net/include/Poco/Net/MultipartReader.h b/Net/include/Poco/Net/MultipartReader.h index f35c9c337..99c739c9c 100644 --- a/Net/include/Poco/Net/MultipartReader.h +++ b/Net/include/Poco/Net/MultipartReader.h @@ -40,7 +40,7 @@ public: bool lastPart() const; protected: - int readFromDevice(char* buffer, std::streamsize length); + std::streamsize readFromDevice(char* buffer, std::streamsize length); private: enum diff --git a/Net/include/Poco/Net/SocketStream.h b/Net/include/Poco/Net/SocketStream.h index d7cc5d6f1..cde8c7131 100644 --- a/Net/include/Poco/Net/SocketStream.h +++ b/Net/include/Poco/Net/SocketStream.h @@ -49,8 +49,8 @@ public: /// Returns the internal SocketImpl. protected: - int readFromDevice(char* buffer, std::streamsize length) override; - int writeToDevice(const char* buffer, std::streamsize length) override; + std::streamsize readFromDevice(char* buffer, std::streamsize length) override; + std::streamsize writeToDevice(const char* buffer, std::streamsize length) override; private: enum diff --git a/Net/src/HTMLForm.cpp b/Net/src/HTMLForm.cpp index 92955d80a..a06602c91 100644 --- a/Net/src/HTMLForm.cpp +++ b/Net/src/HTMLForm.cpp @@ -368,15 +368,15 @@ void HTMLForm::readMultipart(std::istream& istr, PartHandler& handler) { std::string name = params["name"]; std::string value; - std::istream& istr = reader.stream(); - int ch = istr.get(); + std::istream& partStream = reader.stream(); + int ch = partStream.get(); while (ch != eof) { if (value.size() < _valueLengthLimit) value += (char) ch; else throw HTMLFormException("Field value too long"); - ch = istr.get(); + ch = partStream.get(); } add(name, value); } diff --git a/Net/src/HTTPChunkedStream.cpp b/Net/src/HTTPChunkedStream.cpp index f62bddc71..8191f575e 100644 --- a/Net/src/HTTPChunkedStream.cpp +++ b/Net/src/HTTPChunkedStream.cpp @@ -68,7 +68,7 @@ void HTTPChunkedStreamBuf::close() } -int HTTPChunkedStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize HTTPChunkedStreamBuf::readFromDevice(char* buffer, std::streamsize length) { static const int eof = std::char_traits::eof(); @@ -94,7 +94,7 @@ int HTTPChunkedStreamBuf::readFromDevice(char* buffer, std::streamsize length) if (_chunk > 0) { if (length > _chunk) length = _chunk; - int n = _session.read(buffer, length); + std::streamsize n = _session.read(buffer, length); if (n > 0) _chunk -= n; return n; } @@ -126,7 +126,7 @@ int HTTPChunkedStreamBuf::readFromDevice(char* buffer, std::streamsize length) } -int HTTPChunkedStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize HTTPChunkedStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { _chunkBuffer.clear(); NumberFormatter::appendHex(_chunkBuffer, length); @@ -134,7 +134,7 @@ int HTTPChunkedStreamBuf::writeToDevice(const char* buffer, std::streamsize leng _chunkBuffer.append(buffer, static_cast(length)); _chunkBuffer.append("\r\n", 2); _session.write(_chunkBuffer.data(), static_cast(_chunkBuffer.size())); - return static_cast(length); + return length; } diff --git a/Net/src/HTTPClientSession.cpp b/Net/src/HTTPClientSession.cpp index 1ee4dd103..baec1397e 100644 --- a/Net/src/HTTPClientSession.cpp +++ b/Net/src/HTTPClientSession.cpp @@ -304,7 +304,6 @@ std::ostream& HTTPClientSession::sendRequestImpl(const HTTPRequest& request) clearException(); _responseReceived = false; _expectResponseBody = request.getMethod() != HTTPRequest::HTTP_HEAD; - const std::string& method = request.getMethod(); if (request.getChunkedTransferEncoding()) { HTTPHeaderOutputStream hos(*this); diff --git a/Net/src/HTTPFixedLengthStream.cpp b/Net/src/HTTPFixedLengthStream.cpp index 7a2e597cc..8b4d897f2 100644 --- a/Net/src/HTTPFixedLengthStream.cpp +++ b/Net/src/HTTPFixedLengthStream.cpp @@ -42,9 +42,9 @@ HTTPFixedLengthStreamBuf::~HTTPFixedLengthStreamBuf() } -int HTTPFixedLengthStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize HTTPFixedLengthStreamBuf::readFromDevice(char* buffer, std::streamsize length) { - int n = 0; + std::streamsize n = 0; if (_count < _length) { if (_count + length > _length) @@ -56,9 +56,9 @@ int HTTPFixedLengthStreamBuf::readFromDevice(char* buffer, std::streamsize lengt } -int HTTPFixedLengthStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize HTTPFixedLengthStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { - int n = 0; + std::streamsize n = 0; if (_count < _length) { if (_count + length > _length) diff --git a/Net/src/HTTPHeaderStream.cpp b/Net/src/HTTPHeaderStream.cpp index 8e0091fcb..fa925f653 100644 --- a/Net/src/HTTPHeaderStream.cpp +++ b/Net/src/HTTPHeaderStream.cpp @@ -38,14 +38,14 @@ HTTPHeaderStreamBuf::~HTTPHeaderStreamBuf() } -int HTTPHeaderStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize HTTPHeaderStreamBuf::readFromDevice(char* buffer, std::streamsize length) { // read line-by-line; an empty line denotes the end of the headers. static const int eof = std::char_traits::eof(); if (_end) return 0; - int n = 0; + std::streamsize n = 0; int ch = _session.get(); while (ch != eof && ch != '\n' && n < length - 1) { @@ -61,7 +61,7 @@ int HTTPHeaderStreamBuf::readFromDevice(char* buffer, std::streamsize length) } -int HTTPHeaderStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize HTTPHeaderStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { return _session.write(buffer, length); } diff --git a/Net/src/HTTPReactorServerSession.cpp b/Net/src/HTTPReactorServerSession.cpp index 0692c62ae..98cbfbd8c 100644 --- a/Net/src/HTTPReactorServerSession.cpp +++ b/Net/src/HTTPReactorServerSession.cpp @@ -10,10 +10,9 @@ namespace Net { HTTPReactorServerSession::HTTPReactorServerSession( const StreamSocket& socket, std::string& buf, HTTPServerParams::Ptr pParams) : // do not deliver socket to HTTPSession - HTTPSession(), _buf(buf), _realsocket(socket), _complete(0), _idx(0) + HTTPSession(), _buf(buf), _realsocket(socket) { _pcur = const_cast(_buf.c_str()); - _idx = 0; } /// Creates the HTTPReactorServerSession. diff --git a/Net/src/HTTPStream.cpp b/Net/src/HTTPStream.cpp index 61fce2baa..d6919ef48 100644 --- a/Net/src/HTTPStream.cpp +++ b/Net/src/HTTPStream.cpp @@ -48,13 +48,13 @@ void HTTPStreamBuf::close() } -int HTTPStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize HTTPStreamBuf::readFromDevice(char* buffer, std::streamsize length) { return _session.read(buffer, length); } -int HTTPStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize HTTPStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { return _session.write(buffer, length); diff --git a/Net/src/MultipartReader.cpp b/Net/src/MultipartReader.cpp index f4aa27dd8..09d5cf746 100644 --- a/Net/src/MultipartReader.cpp +++ b/Net/src/MultipartReader.cpp @@ -44,14 +44,14 @@ MultipartStreamBuf::~MultipartStreamBuf() } -int MultipartStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize MultipartStreamBuf::readFromDevice(char* buffer, std::streamsize length) { - poco_assert (!_boundary.empty() && _boundary.length() < length - 6); + poco_assert (!_boundary.empty() && _boundary.length() < static_cast(length - 6)); static const int eof = std::char_traits::eof(); std::streambuf& buf = *_istr.rdbuf(); - int n = 0; + std::streamsize n = 0; int ch = buf.sbumpc(); if (ch == eof) return -1; *buffer++ = (char) ch; ++n; diff --git a/Net/src/PollSet.cpp b/Net/src/PollSet.cpp index dc38126e0..ce8b7ddbf 100644 --- a/Net/src/PollSet.cpp +++ b/Net/src/PollSet.cpp @@ -221,7 +221,7 @@ public: } #else std::uint64_t val; - (void) read(_eventfd, &val, sizeof(val)); + [[maybe_unused]] auto n = read(_eventfd, &val, sizeof(val)); #endif } } @@ -238,7 +238,7 @@ public: // or 0 (meaning PollSet is being destroyed). // Errors are ignored. std::uint64_t val = 1; - (void) write(_eventfd, &val, sizeof(val)); + [[maybe_unused]] auto n = write(_eventfd, &val, sizeof(val)); #endif } diff --git a/Net/src/SocketStream.cpp b/Net/src/SocketStream.cpp index 5fc5d3f39..3386866c2 100644 --- a/Net/src/SocketStream.cpp +++ b/Net/src/SocketStream.cpp @@ -47,15 +47,15 @@ SocketStreamBuf::~SocketStreamBuf() } -int SocketStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize SocketStreamBuf::readFromDevice(char* buffer, std::streamsize length) { - return _pImpl->receiveBytes(buffer, (int) length); + return _pImpl->receiveBytes(buffer, static_cast(length)); } -int SocketStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize SocketStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { - return _pImpl->sendBytes(buffer, (int) length); + return _pImpl->sendBytes(buffer, static_cast(length)); } diff --git a/Net/src/TCPReactorAcceptor.cpp b/Net/src/TCPReactorAcceptor.cpp index 71b8c86e6..4eb332158 100644 --- a/Net/src/TCPReactorAcceptor.cpp +++ b/Net/src/TCPReactorAcceptor.cpp @@ -8,8 +8,10 @@ namespace Net { TCPReactorAcceptor::TCPReactorAcceptor( Poco::Net::ServerSocket& socket, Poco::Net::SocketReactor& reactor, TCPServerParams::Ptr pParams) - : Poco::Net::SocketAcceptor(socket, reactor), _pParams(pParams), _selfReactor(reactor), - _useSelfReactor(pParams->getUseSelfReactor()) + : Poco::Net::SocketAcceptor(socket, reactor), + _selfReactor(reactor), + _useSelfReactor(pParams->getUseSelfReactor()), + _pParams(pParams) { int workerThreads = _useSelfReactor ? 0 : _pParams->getMaxThreads(); if (workerThreads > 0) diff --git a/Net/src/TCPReactorServer.cpp b/Net/src/TCPReactorServer.cpp index e463680da..67123e3c4 100644 --- a/Net/src/TCPReactorServer.cpp +++ b/Net/src/TCPReactorServer.cpp @@ -9,8 +9,10 @@ namespace Net { TCPReactorServer::TCPReactorServer(int port, TCPServerParams::Ptr pParams) - : _threadPool("TCPR", pParams->getAcceptorNum()), _reactors(pParams->getAcceptorNum()), _port(port), - _pParams(pParams) + : _threadPool("TCPR", pParams->getAcceptorNum()), + _reactors(pParams->getAcceptorNum()), + _pParams(pParams), + _port(port) { for (auto& reactor : _reactors) { diff --git a/Net/src/WebSocketImpl.cpp b/Net/src/WebSocketImpl.cpp index 392036a3b..d55ac3fc4 100644 --- a/Net/src/WebSocketImpl.cpp +++ b/Net/src/WebSocketImpl.cpp @@ -266,7 +266,7 @@ void WebSocketImpl::skipHeader(int headerLength) if (headerLength > 0) { char header[MAX_HEADER_LENGTH]; - int n = receiveNBytes(header, headerLength); + [[maybe_unused]] int n = receiveNBytes(header, headerLength); poco_assert_dbg (n == headerLength); } } diff --git a/Net/testsuite/src/MailMessageTest.cpp b/Net/testsuite/src/MailMessageTest.cpp index 61d749c85..05b72aa7c 100644 --- a/Net/testsuite/src/MailMessageTest.cpp +++ b/Net/testsuite/src/MailMessageTest.cpp @@ -22,10 +22,11 @@ #include "Poco/FileStream.h" #include "Poco/String.h" #include "Poco/TemporaryFile.h" -#include +#include #include -#include #include +#include +#include using Poco::Net::MailMessage; @@ -727,7 +728,7 @@ void MailMessageTest::testReadWriteMultiPartStore() std::string path = fps->path(); // for security reasons, the filesystem temporary // filename is not the same as attachment name - std::size_t sz = (path.size() > filename.size()) ? filename.size() : path.size(); + std::size_t sz = std::min(path.size(), filename.size()); assertTrue (0 != icompare(path, path.size() - sz, sz, path)); Poco::FileInputStream fis(path); diff --git a/Redis/include/Poco/Redis/RedisStream.h b/Redis/include/Poco/Redis/RedisStream.h index c750f38a1..d6a0a819c 100644 --- a/Redis/include/Poco/Redis/RedisStream.h +++ b/Redis/include/Poco/Redis/RedisStream.h @@ -43,8 +43,8 @@ public: /// Reads a line from Redis (until \r\n is encountered). protected: - int readFromDevice(char* buffer, std::streamsize length); - int writeToDevice(const char* buffer, std::streamsize length); + std::streamsize readFromDevice(char* buffer, std::streamsize length); + std::streamsize writeToDevice(const char* buffer, std::streamsize length); private: enum diff --git a/Redis/src/RedisStream.cpp b/Redis/src/RedisStream.cpp index 1a8a507f4..8a15c6f78 100644 --- a/Redis/src/RedisStream.cpp +++ b/Redis/src/RedisStream.cpp @@ -39,13 +39,13 @@ RedisStreamBuf::~RedisStreamBuf() } -int RedisStreamBuf::readFromDevice(char* buffer, std::streamsize len) +std::streamsize RedisStreamBuf::readFromDevice(char* buffer, std::streamsize len) { return _redis.receiveBytes(buffer, static_cast(len)); } -int RedisStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize RedisStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { return _redis.sendBytes(buffer, static_cast(length)); } diff --git a/XML/src/ParserEngine.cpp b/XML/src/ParserEngine.cpp index 06cb1d357..956a90e0f 100644 --- a/XML/src/ParserEngine.cpp +++ b/XML/src/ParserEngine.cpp @@ -27,6 +27,7 @@ #include "Poco/SAX/LocatorImpl.h" #include "Poco/SAX/SAXException.h" #include "Poco/URI.h" +#include #include @@ -262,7 +263,7 @@ void ParserEngine::parse(const char* pBuffer, std::size_t size) std::size_t processed = 0; while (processed < size) { - const int bufferSize = processed + PARSE_BUFFER_SIZE < size ? PARSE_BUFFER_SIZE : static_cast(size - processed); + const int bufferSize = static_cast(std::min(static_cast(PARSE_BUFFER_SIZE), size - processed)); if (!XML_Parse(_parser, pBuffer + processed, bufferSize, 0)) handleError(XML_GetErrorCode(_parser)); processed += bufferSize; diff --git a/Zip/include/Poco/Zip/AutoDetectStream.h b/Zip/include/Poco/Zip/AutoDetectStream.h index 37c7b6963..6ad716eca 100644 --- a/Zip/include/Poco/Zip/AutoDetectStream.h +++ b/Zip/include/Poco/Zip/AutoDetectStream.h @@ -39,8 +39,8 @@ public: /// Destroys the AutoDetectStream. protected: - int readFromDevice(char* buffer, std::streamsize length); - int writeToDevice(const char* buffer, std::streamsize length); + std::streamsize readFromDevice(char* buffer, std::streamsize length); + std::streamsize writeToDevice(const char* buffer, std::streamsize length); private: enum diff --git a/Zip/include/Poco/Zip/PartialStream.h b/Zip/include/Poco/Zip/PartialStream.h index a1601e86a..b611b4c6f 100644 --- a/Zip/include/Poco/Zip/PartialStream.h +++ b/Zip/include/Poco/Zip/PartialStream.h @@ -33,12 +33,12 @@ class Zip_API PartialStreamBuf: public Poco::BufferedStreamBuf /// A PartialStreamBuf is a class that limits one view on an inputstream to a selected view range { public: - PartialStreamBuf(std::istream& in, std::ios::pos_type start, std::ios::pos_type end, const std::string& prefix, const std::string& postfix, bool initStream); + PartialStreamBuf(std::istream& in, std::ios::pos_type start, std::ios::pos_type endPos, const std::string& prefix, const std::string& postfix, bool initStream); /// Creates the PartialStream. /// If initStream is true the status of the stream will be cleared on the first access, and the stream will be repositioned /// to position start - PartialStreamBuf(std::ostream& out, std::size_t start, std::size_t end, bool initStream); + PartialStreamBuf(std::ostream& out, std::size_t start, std::size_t endPos, bool initStream); /// Creates the PartialStream. /// If initStream is true the status of the stream will be cleared on the first access. /// start and end acts as offset values for the written content. A start value greater than zero, @@ -57,9 +57,9 @@ public: Poco::UInt64 bytesWritten() const; protected: - int readFromDevice(char* buffer, std::streamsize length); + std::streamsize readFromDevice(char* buffer, std::streamsize length); - int writeToDevice(const char* buffer, std::streamsize length); + std::streamsize writeToDevice(const char* buffer, std::streamsize length); private: enum @@ -94,13 +94,13 @@ class Zip_API PartialIOS: public virtual std::ios /// order of the stream buffer and base classes. { public: - PartialIOS(std::istream& istr, std::ios::pos_type start, std::ios::pos_type end, const std::string& prefix, const std::string& postfix, bool initStream); + PartialIOS(std::istream& istr, std::ios::pos_type start, std::ios::pos_type endPos, const std::string& prefix, const std::string& postfix, bool initStream); /// Creates the basic stream and connects it /// to the given input stream. /// If initStream is true the status of the stream will be cleared on the first access, and the stream will be repositioned /// to position start - PartialIOS(std::ostream& ostr, std::size_t start, std::size_t end, bool initStream); + PartialIOS(std::ostream& ostr, std::size_t start, std::size_t endPos, bool initStream); /// Creates the basic stream and connects it /// to the given output stream. /// If initStream is true the status of the stream will be cleared on the first access. @@ -127,7 +127,7 @@ class Zip_API PartialInputStream: public PartialIOS, public std::istream /// to one or multiple output streams. { public: - PartialInputStream(std::istream& istr, std::ios::pos_type start, std::ios::pos_type end, bool initStream = true, const std::string& prefix = std::string(), const std::string& postfix = std::string()); + PartialInputStream(std::istream& istr, std::ios::pos_type start, std::ios::pos_type endPos, bool initStream = true, const std::string& prefix = std::string(), const std::string& postfix = std::string()); /// Creates the PartialInputStream and connects it /// to the given input stream. Bytes read are guaranteed to be in the range [start, end-1] /// If initStream is true the status of the stream will be cleared on the first access, and the stream will be repositioned @@ -143,7 +143,7 @@ class Zip_API PartialOutputStream: public PartialIOS, public std::ostream /// to one or multiple output streams. { public: - PartialOutputStream(std::ostream& ostr, std::size_t start, std::size_t end, bool initStream = true); + PartialOutputStream(std::ostream& ostr, std::size_t start, std::size_t endPos, bool initStream = true); /// Creates the PartialOutputStream and connects it /// to the given output stream. Bytes written are guaranteed to be in the range [start, realEnd - end]. /// If initStream is true the status of the stream will be cleared on the first access. diff --git a/Zip/include/Poco/Zip/ZipStream.h b/Zip/include/Poco/Zip/ZipStream.h index 8280a7473..1aa2c5099 100644 --- a/Zip/include/Poco/Zip/ZipStream.h +++ b/Zip/include/Poco/Zip/ZipStream.h @@ -55,9 +55,9 @@ public: /// Call this method once all bytes were read from the input stream to determine if the CRC is valid protected: - int readFromDevice(char* buffer, std::streamsize length); + std::streamsize readFromDevice(char* buffer, std::streamsize length); - int writeToDevice(const char* buffer, std::streamsize length); + std::streamsize writeToDevice(const char* buffer, std::streamsize length); private: enum diff --git a/Zip/src/AutoDetectStream.cpp b/Zip/src/AutoDetectStream.cpp index 61211c913..8aed0db59 100644 --- a/Zip/src/AutoDetectStream.cpp +++ b/Zip/src/AutoDetectStream.cpp @@ -45,7 +45,7 @@ AutoDetectStreamBuf::~AutoDetectStreamBuf() } -int AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length) { poco_assert_dbg(length >= 8); if (_pIstr == nullptr || length == 0) return -1; @@ -59,20 +59,20 @@ int AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length) if (!_prefix.empty()) { - std::streamsize n = (_prefix.size() > length) ? length : static_cast(_prefix.size()); + std::streamsize n = std::min(static_cast(_prefix.size()), length); std::memcpy(buffer, _prefix.data(), n); - _prefix.erase(0, n); - return static_cast(n); + _prefix.erase(0, static_cast(n)); + return n; } if (_eofDetected) { if (!_postfix.empty()) { - std::streamsize n = (_postfix.size() > length) ? length : static_cast(_postfix.size()); + std::streamsize n = std::min(static_cast(_postfix.size()), length); std::memcpy(buffer, _postfix.data(), n); - _postfix.erase(0, n); - return static_cast(n); + _postfix.erase(0, static_cast(n)); + return n; } else return -1; } @@ -120,9 +120,9 @@ int AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length) if (!_pIstr->good()) throw Poco::IOException("Failed to read data descriptor"); dataInfoSize = dataInfo.getFullHeaderSize(); - if (dataInfo.getCompressedSize() == _length + offset) + if (dataInfo.getCompressedSize() == static_cast(_length + offset)) { - _pIstr->seekg(-static_cast(dataInfoSize), std::ios::cur); + _pIstr->seekg(-static_cast(dataInfoSize), std::ios::cur); if (!_pIstr->good()) throw Poco::IOException("Failed to seek on input stream"); _eofDetected = true; @@ -130,12 +130,12 @@ int AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length) if (offset == 0 && !_postfix.empty()) { - offset = (_postfix.size() > length) ? length : static_cast(_postfix.size()); - std::memcpy(buffer, _postfix.data(), offset); - _postfix.erase(0, offset); + offset = std::min(static_cast(_postfix.size()), length); + std::memcpy(buffer, _postfix.data(), static_cast(offset)); + _postfix.erase(0, static_cast(offset)); } - return static_cast(offset); + return offset; } } else @@ -144,9 +144,9 @@ int AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length) if (!_pIstr->good()) throw Poco::IOException("Failed to read data descriptor"); dataInfoSize = dataInfo.getFullHeaderSize(); - if (dataInfo.getCompressedSize() == _length + offset) + if (dataInfo.getCompressedSize() == static_cast(_length + offset)) { - _pIstr->seekg(-static_cast(dataInfoSize), std::ios::cur); + _pIstr->seekg(-static_cast(dataInfoSize), std::ios::cur); if (!_pIstr->good()) throw Poco::IOException("Failed to seek on input stream"); _eofDetected = true; @@ -154,16 +154,16 @@ int AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length) if (offset == 0 && !_postfix.empty()) { - offset = (_postfix.size() > length) ? length : static_cast(_postfix.size()); - std::memcpy(buffer, _postfix.data(), offset); - _postfix.erase(0, offset); + offset = std::min(static_cast(_postfix.size()), length); + std::memcpy(buffer, _postfix.data(), static_cast(offset)); + _postfix.erase(0, static_cast(offset)); } - return static_cast(offset); + return offset; } } - _pIstr->seekg(-static_cast(dataInfoSize - 4), std::ios::cur); + _pIstr->seekg(-static_cast(dataInfoSize - 4), std::ios::cur); if (!_pIstr->good()) throw Poco::IOException("Failed to seek on input stream"); buffer[offset++] = ZipDataInfo::HEADER[0]; @@ -177,7 +177,7 @@ int AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length) buffer[offset++] = ZipDataInfo::HEADER[0]; buffer[offset++] = ZipDataInfo::HEADER[1]; buffer[offset++] = ZipDataInfo::HEADER[2]; - buffer[offset++] = c; + buffer[offset++] = static_cast(c); _matchCnt = 0; } } @@ -185,12 +185,12 @@ int AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length) } _length += offset; - return static_cast(offset); + return offset; } -int AutoDetectStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize AutoDetectStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { return -1; // not supported } diff --git a/Zip/src/PartialStream.cpp b/Zip/src/PartialStream.cpp index 32a4513c2..d1b3cfe92 100644 --- a/Zip/src/PartialStream.cpp +++ b/Zip/src/PartialStream.cpp @@ -21,11 +21,11 @@ namespace Poco { namespace Zip { -PartialStreamBuf::PartialStreamBuf(std::istream& in, std::ios::pos_type start, std::ios::pos_type end, const std::string& pre, const std::string& post, bool initStream): +PartialStreamBuf::PartialStreamBuf(std::istream& in, std::ios::pos_type start, std::ios::pos_type endPos, const std::string& pre, const std::string& post, bool initStream): Poco::BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in), _initialized(!initStream), _start(start), - _numBytes(end-start), + _numBytes(endPos-start), _bytesWritten(0), _pIstr(&in), _pOstr(nullptr), @@ -38,7 +38,7 @@ PartialStreamBuf::PartialStreamBuf(std::istream& in, std::ios::pos_type start, s } -PartialStreamBuf::PartialStreamBuf(std::ostream& out, std::size_t start, std::size_t end, bool initStream): +PartialStreamBuf::PartialStreamBuf(std::ostream& out, std::size_t start, std::size_t endPos, bool initStream): Poco::BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::out), _initialized(!initStream), _start(0), @@ -47,7 +47,7 @@ PartialStreamBuf::PartialStreamBuf(std::ostream& out, std::size_t start, std::si _pIstr(nullptr), _pOstr(&out), _ignoreStart(start), - _buffer(end), + _buffer(endPos), _bufferOffset(0) { } @@ -58,7 +58,7 @@ PartialStreamBuf::~PartialStreamBuf() } -int PartialStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize PartialStreamBuf::readFromDevice(char* buffer, std::streamsize length) { if (_pIstr == nullptr ||length == 0) return -1; if (!_initialized) @@ -71,20 +71,20 @@ int PartialStreamBuf::readFromDevice(char* buffer, std::streamsize length) } if (!_prefix.empty()) { - std::streamsize tmp = (_prefix.size() > length)? length: static_cast(_prefix.size()); + std::streamsize tmp = std::min(static_cast(_prefix.size()), length); std::memcpy(buffer, _prefix.c_str(), tmp); - _prefix = _prefix.substr(tmp); - return static_cast(tmp); + _prefix = _prefix.substr(static_cast(tmp)); + return tmp; } if (_numBytes == 0) { if (!_postfix.empty()) { - std::streamsize tmp = (_postfix.size() > length)? length: static_cast(_postfix.size()); + std::streamsize tmp = std::min(static_cast(_postfix.size()), length); std::memcpy(buffer, _postfix.c_str(), tmp); - _postfix = _postfix.substr(tmp); - return static_cast(tmp); + _postfix = _postfix.substr(static_cast(tmp)); + return tmp; } else return -1; @@ -93,18 +93,18 @@ int PartialStreamBuf::readFromDevice(char* buffer, std::streamsize length) if (!_pIstr->good()) return -1; - if (_numBytes < length) + if (static_cast(_numBytes) < length) length = static_cast(_numBytes); _pIstr->read(buffer, length); std::streamsize bytesRead = _pIstr->gcount(); _numBytes -= bytesRead; - return static_cast(bytesRead); + return bytesRead; } -int PartialStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize PartialStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { if (_pOstr == nullptr || length == 0) return -1; if (!_initialized) @@ -117,11 +117,11 @@ int PartialStreamBuf::writeToDevice(const char* buffer, std::streamsize length) if (_ignoreStart > 0) { - if (_ignoreStart > length) + if (static_cast(_ignoreStart) > length) { - _ignoreStart -= length; + _ignoreStart -= static_cast(length); // fake return values - return static_cast(length); + return length; } else { @@ -139,7 +139,7 @@ int PartialStreamBuf::writeToDevice(const char* buffer, std::streamsize length) _bufferOffset = static_cast(length - cnt); std::memcpy(_buffer.begin(), buffer + cnt, _bufferOffset); - return static_cast(length); + return length; } } if (_buffer.size() > 0) @@ -152,7 +152,7 @@ int PartialStreamBuf::writeToDevice(const char* buffer, std::streamsize length) static_cast(length) - static_cast(_buffer.size())); if (cache > 0) { - if (cache > _bufferOffset) + if (static_cast(cache) > _bufferOffset) cache = _bufferOffset; _pOstr->write(_buffer.begin(), cache); _bytesWritten += cache; @@ -166,7 +166,7 @@ int PartialStreamBuf::writeToDevice(const char* buffer, std::streamsize length) if (pos <= 0) { // all of the message goes to _buffer - std::memcpy(_buffer.begin() + _bufferOffset, buffer, length); + std::memcpy(_buffer.begin() + _bufferOffset, buffer, static_cast(length)); } else { @@ -185,7 +185,7 @@ int PartialStreamBuf::writeToDevice(const char* buffer, std::streamsize length) } if (_pOstr->good()) - return static_cast(length); + return length; throw Poco::IOException("Failed to write to output stream"); } @@ -197,13 +197,13 @@ void PartialStreamBuf::close() } -PartialIOS::PartialIOS(std::istream& istr, std::ios::pos_type start, std::ios::pos_type end, const std::string& pre, const std::string& post, bool initStream): _buf(istr, start, end, pre, post, initStream) +PartialIOS::PartialIOS(std::istream& istr, std::ios::pos_type start, std::ios::pos_type endPos, const std::string& pre, const std::string& post, bool initStream): _buf(istr, start, endPos, pre, post, initStream) { poco_ios_init(&_buf); } -PartialIOS::PartialIOS(std::ostream& ostr, std::size_t start, std::size_t end, bool initStream): _buf(ostr, start, end, initStream) +PartialIOS::PartialIOS(std::ostream& ostr, std::size_t start, std::size_t endPos, bool initStream): _buf(ostr, start, endPos, initStream) { poco_ios_init(&_buf); } @@ -220,8 +220,8 @@ PartialStreamBuf* PartialIOS::rdbuf() } -PartialInputStream::PartialInputStream(std::istream& istr, std::ios::pos_type start, std::ios::pos_type end, bool initStream, const std::string& pre, const std::string& post): - PartialIOS(istr, start, end, pre, post, initStream), +PartialInputStream::PartialInputStream(std::istream& istr, std::ios::pos_type start, std::ios::pos_type endPos, bool initStream, const std::string& pre, const std::string& post): + PartialIOS(istr, start, endPos, pre, post, initStream), std::istream(&_buf) { } @@ -232,8 +232,8 @@ PartialInputStream::~PartialInputStream() } -PartialOutputStream::PartialOutputStream(std::ostream& ostr, std::size_t start, std::size_t end, bool initStream): - PartialIOS(ostr, start, end, initStream), +PartialOutputStream::PartialOutputStream(std::ostream& ostr, std::size_t start, std::size_t endPos, bool initStream): + PartialIOS(ostr, start, endPos, initStream), std::ostream(&_buf) { } diff --git a/Zip/src/ZipStream.cpp b/Zip/src/ZipStream.cpp index f0227ca1c..19d8609ac 100644 --- a/Zip/src/ZipStream.cpp +++ b/Zip/src/ZipStream.cpp @@ -147,14 +147,14 @@ ZipStreamBuf::~ZipStreamBuf() } -int ZipStreamBuf::readFromDevice(char* buffer, std::streamsize length) +std::streamsize ZipStreamBuf::readFromDevice(char* buffer, std::streamsize length) { if (!_ptrBuf) return 0; // directory entry _ptrBuf->read(buffer, length); - int cnt = static_cast(_ptrBuf->gcount()); + std::streamsize cnt = _ptrBuf->gcount(); if (cnt > 0) { - _crc32.update(buffer, cnt); + _crc32.update(buffer, static_cast(cnt)); } else { @@ -181,7 +181,7 @@ int ZipStreamBuf::readFromDevice(char* buffer, std::streamsize length) } -int ZipStreamBuf::writeToDevice(const char* buffer, std::streamsize length) +std::streamsize ZipStreamBuf::writeToDevice(const char* buffer, std::streamsize length) { if (!_ptrOBuf) return 0; // directory entry if (length == 0) @@ -189,7 +189,7 @@ int ZipStreamBuf::writeToDevice(const char* buffer, std::streamsize length) _bytesWritten += length; _ptrOBuf->write(buffer, length); _crc32.update(buffer, static_cast(length)); - return static_cast(length); + return length; } diff --git a/Zip/src/ZipUtil.cpp b/Zip/src/ZipUtil.cpp index 0cad5c90a..d357a721d 100644 --- a/Zip/src/ZipUtil.cpp +++ b/Zip/src/ZipUtil.cpp @@ -189,7 +189,7 @@ void ZipUtil::syncDataDescriptor(std::istream & in, bool force64) ZipDataInfo64 nfo(in, true); if (nfo.isValid()) { - if (end - start == nfo.getCompressedSize() + 4) + if (static_cast(end - start) == nfo.getCompressedSize() + 4) { in.seekg(-static_cast(ZipDataInfo64::getFullHeaderSize()), std::ios::cur); if (!in.good()) throw Poco::IOException("Failed to seek on input stream"); diff --git a/Zip/testsuite/src/ZipTest.cpp b/Zip/testsuite/src/ZipTest.cpp index 61b48570d..e7f401131 100644 --- a/Zip/testsuite/src/ZipTest.cpp +++ b/Zip/testsuite/src/ZipTest.cpp @@ -54,16 +54,16 @@ void ZipTest::testSkipSingleFile() ZipLocalFileHeader hdr(inp, false, skip); assertTrue (ZipCommon::HS_FAT == hdr.getHostSystem()); int major = hdr.getMajorVersionNumber(); - int POCO_UNUSED minor = hdr.getMinorVersionNumber(); + [[maybe_unused]] int minor = hdr.getMinorVersionNumber(); assertTrue (major <= 2); std::size_t hdrSize = hdr.getHeaderSize(); assertTrue (hdrSize > 30); - ZipCommon::CompressionMethod POCO_UNUSED cm = hdr.getCompressionMethod(); + [[maybe_unused]] ZipCommon::CompressionMethod cm = hdr.getCompressionMethod(); assertTrue (!hdr.isEncrypted()); Poco::DateTime aDate = hdr.lastModifiedAt(); - Poco::UInt64 POCO_UNUSED cS = hdr.getCompressedSize(); - Poco::UInt64 POCO_UNUSED uS = hdr.getUncompressedSize(); - const std::string& POCO_UNUSED fileName = hdr.getFileName(); + [[maybe_unused]] Poco::UInt64 cS = hdr.getCompressedSize(); + [[maybe_unused]] Poco::UInt64 uS = hdr.getUncompressedSize(); + [[maybe_unused]] const std::string& fileName = hdr.getFileName(); }