chore(Poco): Resolve a lot of warnings, reported by g++ 13.

This commit is contained in:
Matej Kenda 2024-10-10 09:11:15 +02:00
parent 88c4958032
commit c038b52f36
13 changed files with 58 additions and 56 deletions

View File

@ -575,11 +575,11 @@ private:
getColumnOrParameterSize(pos, size); getColumnOrParameterSize(pos, size);
poco_assert (size > 0); poco_assert (size > 0);
if (size == _maxFieldSize) if (static_cast<std::size_t>(size) == _maxFieldSize)
{ {
getMinValueSize(*pVal, size); getMinValueSize(*pVal, size);
// accommodate for terminating zero // accommodate for terminating zero
if (size != _maxFieldSize) ++size; if (static_cast<std::size_t>(size) != _maxFieldSize) ++size;
} }
if (_vecLengthIndicator.size() <= pos) if (_vecLengthIndicator.size() <= pos)
@ -601,7 +601,7 @@ private:
for (; it != end; ++it) for (; it != end; ++it)
{ {
strSize = it->size(); strSize = it->size();
if (strSize > size) if (strSize > static_cast<std::size_t>(size))
{ {
if (transcodeRequired()) delete pVal; if (transcodeRequired()) delete pVal;
throw LengthExceededException(Poco::format("SQLBindParameter(%s)", typeID)); throw LengthExceededException(Poco::format("SQLBindParameter(%s)", typeID));
@ -646,11 +646,11 @@ private:
getColumnOrParameterSize(pos, size); getColumnOrParameterSize(pos, size);
poco_assert(size > 0); poco_assert(size > 0);
if (size == _maxFieldSize) if (static_cast<std::size_t>(size) == _maxFieldSize)
{ {
getMinValueSize(val, size); getMinValueSize(val, size);
// accomodate for terminating zero // accomodate for terminating zero
if (size != _maxFieldSize) size += sizeof(UTF16Char); if (static_cast<std::size_t>(size) != _maxFieldSize) size += sizeof(UTF16Char);
} }
if (_vecLengthIndicator.size() <= pos) if (_vecLengthIndicator.size() <= pos)
@ -672,7 +672,7 @@ private:
for (; it != end; ++it) for (; it != end; ++it)
{ {
strSize = it->size() * sizeof(UTF16Char); strSize = it->size() * sizeof(UTF16Char);
if (strSize > size) if (strSize > static_cast<std::size_t>(size))
throw LengthExceededException("ODBC::Binder::bindImplContainerUTF16String:SQLBindParameter(std::vector<UTF16String>)"); throw LengthExceededException("ODBC::Binder::bindImplContainerUTF16String:SQLBindParameter(std::vector<UTF16String>)");
std::memcpy(pBuf + offset, it->data(), strSize); std::memcpy(pBuf + offset, it->data(), strSize);
offset += size; offset += size;
@ -742,7 +742,7 @@ private:
for (; cIt != cEnd; ++cIt) for (; cIt != cEnd; ++cIt)
{ {
blobSize = cIt->size(); blobSize = cIt->size();
if (blobSize > size) if (blobSize > static_cast<std::size_t>(size))
throw LengthExceededException("ODBC::Binder::bindImplContainerLOB():SQLBindParameter(std::vector<BLOB>)"); throw LengthExceededException("ODBC::Binder::bindImplContainerLOB():SQLBindParameter(std::vector<BLOB>)");
std::memcpy(_charPtrs[pos] + offset, cIt->rawContent(), blobSize * sizeof(CharType)); std::memcpy(_charPtrs[pos] + offset, cIt->rawContent(), blobSize * sizeof(CharType));
offset += size; offset += size;

View File

@ -526,7 +526,7 @@ void Binder::getColSizeAndPrecision(std::size_t pos,
else foundSize = _pTypeInfo->tryGetInfo(sqlDataType, "COLUMN_SIZE", tmp); else foundSize = _pTypeInfo->tryGetInfo(sqlDataType, "COLUMN_SIZE", tmp);
if (foundSize) colSize = tmp; if (foundSize) colSize = tmp;
if (actualSize > colSize) if (actualSize > static_cast<std::size_t>(colSize))
{ {
throw LengthExceededException(Poco::format("ODBC::Binder::getColSizeAndPrecision();%d: Error binding column %z size=%z, max size=%ld)", throw LengthExceededException(Poco::format("ODBC::Binder::getColSizeAndPrecision();%d: Error binding column %z size=%z, max size=%ld)",
__LINE__, pos, actualSize, static_cast<long>(colSize))); __LINE__, pos, actualSize, static_cast<long>(colSize)));

View File

@ -171,7 +171,7 @@ public:
C5 dateTimes(size); C5 dateTimes(size);
C6 bools; C6 bools;
for (int i = 0; i < size; ++i) for (Poco::UInt32 i = 0; i < size; ++i)
{ {
ints.push_back(i); ints.push_back(i);
strings.push_back(std::string("xyz" + Poco::NumberFormatter::format(i))); strings.push_back(std::string("xyz" + Poco::NumberFormatter::format(i)));
@ -313,7 +313,7 @@ public:
C4 floats; C4 floats;
C5 dateTimes(size); C5 dateTimes(size);
for (int i = 0; i < size; ++i) for (Poco::UInt32 i = 0; i < size; ++i)
{ {
ints.push_back(i); ints.push_back(i);
strings.push_back(std::string("xyz" + Poco::NumberFormatter::format(i))); strings.push_back(std::string("xyz" + Poco::NumberFormatter::format(i)));

View File

@ -403,19 +403,19 @@ public:
/// to start iteration from beginning or end, /// to start iteration from beginning or end,
/// depending on the position requested. /// depending on the position requested.
{ {
if (row <= (std::size_t) (_pData->size() / 2)) if (row <= (_pData->size() / 2))
{ {
Iterator it = _pData->begin(); Iterator it = _pData->begin();
Iterator end = _pData->end(); Iterator end = _pData->end();
for (int i = 0; it != end; ++it, ++i) for (std::size_t i = 0; it != end; ++it, ++i)
if (i == row) return *it; if (i == row) return *it;
} }
else else
{ {
row = _pData->size() - row; row = _pData->size() - row;
RIterator it = _pData->rbegin(); RIterator it = _pData->rbegin();
RIterator end = _pData->rend(); const RIterator end = _pData->rend();
for (int i = 1; it != end; ++it, ++i) for (std::size_t i = 1; it != end; ++it, ++i)
if (i == row) return *it; if (i == row) return *it;
} }

View File

@ -137,7 +137,7 @@ private:
{ {
poco_assert (bufferSize > 0); poco_assert (bufferSize > 0);
if (bufferSize > rangeLength) if (bufferSize > static_cast<std::size_t>(rangeLength))
bufferSize = rangeLength; bufferSize = rangeLength;
Buffer<char> buffer(bufferSize); Buffer<char> buffer(bufferSize);
@ -153,8 +153,9 @@ private:
ostr.write(buffer.begin(), n); ostr.write(buffer.begin(), n);
if ((len < rangeLength) && istr && ostr) if ((len < rangeLength) && istr && ostr)
{ {
if (bufferSize > (rangeLength - len)) const std::size_t inputLen = rangeLength - len;
bufferSize = rangeLength - len; if (bufferSize > inputLen)
bufferSize = inputLen;
istr.read(buffer.begin(), bufferSize); istr.read(buffer.begin(), bufferSize);
n = istr.gcount(); n = istr.gcount();
} }
@ -211,7 +212,7 @@ private:
{ {
istr.seekg(rangeStart, std::ios_base::beg); istr.seekg(rangeStart, std::ios_base::beg);
istr.get(c); istr.get(c);
while (istr && ostr && (len < rangeLength)) while (istr && ostr && (static_cast<std::streamsize>(len) < rangeLength))
{ {
ostr.put(c); ostr.put(c);
++len; ++len;

View File

@ -71,7 +71,7 @@ public:
/// startInterval expires. /// startInterval expires.
/// To start the timer, call the Start() method. /// To start the timer, call the Start() method.
virtual ~Timer(); ~Timer() override;
/// Stops and destroys the timer. /// Stops and destroys the timer.
void start(const AbstractTimerCallback& method); void start(const AbstractTimerCallback& method);
@ -138,7 +138,7 @@ public:
/// longer to execute than the timer interval. /// longer to execute than the timer interval.
protected: protected:
void run(); void run() override;
private: private:
long _startInterval; long _startInterval;
@ -181,19 +181,19 @@ class TimerCallback: public AbstractTimerCallback
/// to use this template class. /// to use this template class.
{ {
public: public:
typedef void (C::*Callback)(Timer&); using Callback = void (C::*)(Timer &);
TimerCallback() = delete;
TimerCallback(C& object, Callback method): _pObject(&object), _method(method) TimerCallback(C& object, Callback method): _pObject(&object), _method(method)
{ {
} }
TimerCallback(const TimerCallback& callback): _pObject(callback._pObject), _method(callback._method) TimerCallback(const TimerCallback& callback): AbstractTimerCallback(callback), _pObject(callback._pObject), _method(callback._method)
{ {
} }
~TimerCallback() ~TimerCallback() override = default;
{
}
TimerCallback& operator = (const TimerCallback& callback) TimerCallback& operator = (const TimerCallback& callback)
{ {
@ -205,19 +205,17 @@ public:
return *this; return *this;
} }
void invoke(Timer& timer) const void invoke(Timer& timer) const override
{ {
(_pObject->*_method)(timer); (_pObject->*_method)(timer);
} }
AbstractTimerCallback* clone() const AbstractTimerCallback* clone() const override
{ {
return new TimerCallback(*this); return new TimerCallback(*this);
} }
private: private:
TimerCallback();
C* _pObject; C* _pObject;
Callback _method; Callback _method;
}; };

View File

@ -54,9 +54,11 @@ public:
{ {
} }
virtual ~DirectoryWatcherStrategy() virtual ~DirectoryWatcherStrategy() = default;
{
} DirectoryWatcherStrategy() = delete;
DirectoryWatcherStrategy(const DirectoryWatcherStrategy&) = delete;
DirectoryWatcherStrategy& operator = (const DirectoryWatcherStrategy&) = delete;
DirectoryWatcher& owner() DirectoryWatcher& owner()
{ {
@ -75,12 +77,11 @@ protected:
{ {
} }
ItemInfo(const ItemInfo& other): ItemInfo(const ItemInfo& other) = default;
path(other.path), ItemInfo& operator=(const ItemInfo& ) = default;
size(other.size),
lastModified(other.lastModified) ItemInfo(ItemInfo&& other) = default;
{ ItemInfo& operator=(ItemInfo&& ) = default;
}
explicit ItemInfo(const File& f): explicit ItemInfo(const File& f):
path(f.path()), path(f.path()),
@ -93,12 +94,12 @@ protected:
File::FileSize size; File::FileSize size;
Timestamp lastModified; Timestamp lastModified;
}; };
typedef std::map<std::string, ItemInfo> ItemInfoMap; using ItemInfoMap = std::map<std::string, ItemInfo>;
void scan(ItemInfoMap& entries) void scan(ItemInfoMap& entries)
{ {
DirectoryIterator it(owner().directory()); DirectoryIterator it(owner().directory());
DirectoryIterator end; const DirectoryIterator end;
while (it != end) while (it != end)
{ {
entries[it.path().getFileName()] = ItemInfo(*it); entries[it.path().getFileName()] = ItemInfo(*it);
@ -110,14 +111,14 @@ protected:
{ {
for (auto& np: newEntries) for (auto& np: newEntries)
{ {
ItemInfoMap::iterator ito = oldEntries.find(np.first); const auto ito = oldEntries.find(np.first);
if (ito != oldEntries.end()) if (ito != oldEntries.end())
{ {
if ((owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED) && !owner().eventsSuspended()) if ((owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED) && !owner().eventsSuspended())
{ {
if (np.second.size != ito->second.size || np.second.lastModified != ito->second.lastModified) if (np.second.size != ito->second.size || np.second.lastModified != ito->second.lastModified)
{ {
Poco::File f(np.second.path); const Poco::File f(np.second.path);
DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_MODIFIED); DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_MODIFIED);
owner().itemModified(&owner(), ev); owner().itemModified(&owner(), ev);
} }
@ -143,10 +144,6 @@ protected:
} }
private: private:
DirectoryWatcherStrategy();
DirectoryWatcherStrategy(const DirectoryWatcherStrategy&);
DirectoryWatcherStrategy& operator = (const DirectoryWatcherStrategy&);
DirectoryWatcher& _owner; DirectoryWatcher& _owner;
}; };

View File

@ -518,8 +518,6 @@ X509* SecureSocketImpl::peerCertificate() const
{ {
LockT l(_mutex); LockT l(_mutex);
X509* pCert = nullptr;
if (_pSSL) if (_pSSL)
return ::SSL_get_peer_certificate(_pSSL); return ::SSL_get_peer_certificate(_pSSL);
else else

View File

@ -162,7 +162,7 @@ public:
/// _fileName is used. If member variable is empty string, /// _fileName is used. If member variable is empty string,
/// document is saved to the memory stream. /// document is saved to the memory stream.
const DataPtr data(SizeType& sz); DataPtr data(SizeType& sz);
/// Returns the document content as raw data and data size in /// Returns the document content as raw data and data size in
/// the sz argument. /// the sz argument.

View File

@ -85,7 +85,7 @@ void Document::save(const std::string fileName)
} }
const Document::DataPtr Document::data(SizeType& sz) Document::DataPtr Document::data(SizeType& sz)
{ {
sz = size(); sz = size();
delete _pRawData; delete _pRawData;

View File

@ -47,6 +47,9 @@ public:
virtual ~Array(); virtual ~Array();
/// Destroys the Array. /// Destroys the Array.
Array& operator=(const Array&) = default;
Array& operator=(Array&&) = default;
template<typename T> template<typename T>
Array& operator<<(const T& arg) Array& operator<<(const T& arg)
/// Adds the argument to the array. /// Adds the argument to the array.
@ -126,7 +129,7 @@ public:
RedisType::Ptr element = _elements.value().at(pos); RedisType::Ptr element = _elements.value().at(pos);
if ( RedisTypeTraits<T>::TypeId == element->type() ) if ( RedisTypeTraits<T>::TypeId == element->type() )
{ {
Type<T>* concrete = dynamic_cast<Type<T>* >(element.get()); auto* concrete = dynamic_cast<Type<T>* >(element.get());
if ( concrete != NULL ) return concrete->value(); if ( concrete != NULL ) return concrete->value();
} }
throw BadCastException(); throw BadCastException();
@ -296,7 +299,7 @@ struct RedisTypeTraits<Array>
{ {
value.clear(); value.clear();
Int64 length = NumberParser::parse64(input.getline()); const Int64 length = NumberParser::parse64(input.getline());
if ( length != -1 ) if ( length != -1 )
{ {
@ -316,7 +319,8 @@ struct RedisTypeTraits<Array>
}; };
} } // namespace Poco::Redis } // namespace Redis
} // namespace Poco
#endif // Redis_Array_INCLUDED #endif // Redis_Array_INCLUDED

View File

@ -57,9 +57,12 @@ public:
Command(const Command& copy); Command(const Command& copy);
/// Creates a command by copying another one. /// Creates a command by copying another one.
virtual ~Command(); ~Command() override;
/// Destroys the command. /// Destroys the command.
Command& operator=(const Command&) = default;
Command& operator=(Command&&) = default;
static Command append(const std::string& key, const std::string& value); static Command append(const std::string& key, const std::string& value);
/// Creates and returns an APPEND command. /// Creates and returns an APPEND command.
@ -282,7 +285,8 @@ public:
}; };
} } // namespace Poco::Redis } // namespace Redis
} // namespace Poco
#endif // Redis_Command_INCLUDED #endif // Redis_Command_INCLUDED

View File

@ -223,7 +223,7 @@ Array Client::sendCommands(const std::vector<Array>& commands)
} }
_output->flush(); _output->flush();
for (int i = 0; i < commands.size(); ++i) for (std::size_t i = 0; i < commands.size(); ++i)
{ {
results.addRedisType(readReply()); results.addRedisType(readReply());
} }