Skip to content

Commit c038b52

Browse files
committed
chore(Poco): Resolve a lot of warnings, reported by g++ 13.
1 parent 88c4958 commit c038b52

File tree

13 files changed

+58
-56
lines changed

13 files changed

+58
-56
lines changed

Diff for: Data/ODBC/include/Poco/Data/ODBC/Binder.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -575,11 +575,11 @@ class ODBC_API Binder: public Poco::Data::AbstractBinder
575575
getColumnOrParameterSize(pos, size);
576576
poco_assert (size > 0);
577577

578-
if (size == _maxFieldSize)
578+
if (static_cast<std::size_t>(size) == _maxFieldSize)
579579
{
580580
getMinValueSize(*pVal, size);
581581
// accommodate for terminating zero
582-
if (size != _maxFieldSize) ++size;
582+
if (static_cast<std::size_t>(size) != _maxFieldSize) ++size;
583583
}
584584

585585
if (_vecLengthIndicator.size() <= pos)
@@ -601,7 +601,7 @@ class ODBC_API Binder: public Poco::Data::AbstractBinder
601601
for (; it != end; ++it)
602602
{
603603
strSize = it->size();
604-
if (strSize > size)
604+
if (strSize > static_cast<std::size_t>(size))
605605
{
606606
if (transcodeRequired()) delete pVal;
607607
throw LengthExceededException(Poco::format("SQLBindParameter(%s)", typeID));
@@ -646,11 +646,11 @@ class ODBC_API Binder: public Poco::Data::AbstractBinder
646646
getColumnOrParameterSize(pos, size);
647647
poco_assert(size > 0);
648648

649-
if (size == _maxFieldSize)
649+
if (static_cast<std::size_t>(size) == _maxFieldSize)
650650
{
651651
getMinValueSize(val, size);
652652
// accomodate for terminating zero
653-
if (size != _maxFieldSize) size += sizeof(UTF16Char);
653+
if (static_cast<std::size_t>(size) != _maxFieldSize) size += sizeof(UTF16Char);
654654
}
655655

656656
if (_vecLengthIndicator.size() <= pos)
@@ -672,7 +672,7 @@ class ODBC_API Binder: public Poco::Data::AbstractBinder
672672
for (; it != end; ++it)
673673
{
674674
strSize = it->size() * sizeof(UTF16Char);
675-
if (strSize > size)
675+
if (strSize > static_cast<std::size_t>(size))
676676
throw LengthExceededException("ODBC::Binder::bindImplContainerUTF16String:SQLBindParameter(std::vector<UTF16String>)");
677677
std::memcpy(pBuf + offset, it->data(), strSize);
678678
offset += size;
@@ -742,7 +742,7 @@ class ODBC_API Binder: public Poco::Data::AbstractBinder
742742
for (; cIt != cEnd; ++cIt)
743743
{
744744
blobSize = cIt->size();
745-
if (blobSize > size)
745+
if (blobSize > static_cast<std::size_t>(size))
746746
throw LengthExceededException("ODBC::Binder::bindImplContainerLOB():SQLBindParameter(std::vector<BLOB>)");
747747
std::memcpy(_charPtrs[pos] + offset, cIt->rawContent(), blobSize * sizeof(CharType));
748748
offset += size;

Diff for: Data/ODBC/src/Binder.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ void Binder::getColSizeAndPrecision(std::size_t pos,
526526
else foundSize = _pTypeInfo->tryGetInfo(sqlDataType, "COLUMN_SIZE", tmp);
527527
if (foundSize) colSize = tmp;
528528

529-
if (actualSize > colSize)
529+
if (actualSize > static_cast<std::size_t>(colSize))
530530
{
531531
throw LengthExceededException(Poco::format("ODBC::Binder::getColSizeAndPrecision();%d: Error binding column %z size=%z, max size=%ld)",
532532
__LINE__, pos, actualSize, static_cast<long>(colSize)));

Diff for: Data/ODBC/testsuite/src/SQLExecutor.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class SQLExecutor: public CppUnit::TestCase
171171
C5 dateTimes(size);
172172
C6 bools;
173173

174-
for (int i = 0; i < size; ++i)
174+
for (Poco::UInt32 i = 0; i < size; ++i)
175175
{
176176
ints.push_back(i);
177177
strings.push_back(std::string("xyz" + Poco::NumberFormatter::format(i)));
@@ -313,7 +313,7 @@ class SQLExecutor: public CppUnit::TestCase
313313
C4 floats;
314314
C5 dateTimes(size);
315315

316-
for (int i = 0; i < size; ++i)
316+
for (Poco::UInt32 i = 0; i < size; ++i)
317317
{
318318
ints.push_back(i);
319319
strings.push_back(std::string("xyz" + Poco::NumberFormatter::format(i)));

Diff for: Data/include/Poco/Data/Column.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -403,19 +403,19 @@ class Column<std::list<T>>
403403
/// to start iteration from beginning or end,
404404
/// depending on the position requested.
405405
{
406-
if (row <= (std::size_t) (_pData->size() / 2))
406+
if (row <= (_pData->size() / 2))
407407
{
408408
Iterator it = _pData->begin();
409409
Iterator end = _pData->end();
410-
for (int i = 0; it != end; ++it, ++i)
410+
for (std::size_t i = 0; it != end; ++it, ++i)
411411
if (i == row) return *it;
412412
}
413413
else
414414
{
415415
row = _pData->size() - row;
416416
RIterator it = _pData->rbegin();
417-
RIterator end = _pData->rend();
418-
for (int i = 1; it != end; ++it, ++i)
417+
const RIterator end = _pData->rend();
418+
for (std::size_t i = 1; it != end; ++it, ++i)
419419
if (i == row) return *it;
420420
}
421421

Diff for: Foundation/include/Poco/StreamCopier.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static std::streamsize copyStreamRangeUnbuffered(std::istream& istr, std::ostrea
137137
{
138138
poco_assert (bufferSize > 0);
139139

140-
if (bufferSize > rangeLength)
140+
if (bufferSize > static_cast<std::size_t>(rangeLength))
141141
bufferSize = rangeLength;
142142

143143
Buffer<char> buffer(bufferSize);
@@ -153,8 +153,9 @@ static std::streamsize copyStreamRangeUnbuffered(std::istream& istr, std::ostrea
153153
ostr.write(buffer.begin(), n);
154154
if ((len < rangeLength) && istr && ostr)
155155
{
156-
if (bufferSize > (rangeLength - len))
157-
bufferSize = rangeLength - len;
156+
const std::size_t inputLen = rangeLength - len;
157+
if (bufferSize > inputLen)
158+
bufferSize = inputLen;
158159
istr.read(buffer.begin(), bufferSize);
159160
n = istr.gcount();
160161
}
@@ -211,7 +212,7 @@ static std::streamsize copyStreamRangeUnbuffered(std::istream& istr, std::ostrea
211212
{
212213
istr.seekg(rangeStart, std::ios_base::beg);
213214
istr.get(c);
214-
while (istr && ostr && (len < rangeLength))
215+
while (istr && ostr && (static_cast<std::streamsize>(len) < rangeLength))
215216
{
216217
ostr.put(c);
217218
++len;

Diff for: Foundation/include/Poco/Timer.h

+9-11
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class Foundation_API Timer: protected Runnable
7171
/// startInterval expires.
7272
/// To start the timer, call the Start() method.
7373

74-
virtual ~Timer();
74+
~Timer() override;
7575
/// Stops and destroys the timer.
7676

7777
void start(const AbstractTimerCallback& method);
@@ -138,7 +138,7 @@ class Foundation_API Timer: protected Runnable
138138
/// longer to execute than the timer interval.
139139

140140
protected:
141-
void run();
141+
void run() override;
142142

143143
private:
144144
long _startInterval;
@@ -181,19 +181,19 @@ class TimerCallback: public AbstractTimerCallback
181181
/// to use this template class.
182182
{
183183
public:
184-
typedef void (C::*Callback)(Timer&);
184+
using Callback = void (C::*)(Timer &);
185+
186+
TimerCallback() = delete;
185187

186188
TimerCallback(C& object, Callback method): _pObject(&object), _method(method)
187189
{
188190
}
189191

190-
TimerCallback(const TimerCallback& callback): _pObject(callback._pObject), _method(callback._method)
192+
TimerCallback(const TimerCallback& callback): AbstractTimerCallback(callback), _pObject(callback._pObject), _method(callback._method)
191193
{
192194
}
193195

194-
~TimerCallback()
195-
{
196-
}
196+
~TimerCallback() override = default;
197197

198198
TimerCallback& operator = (const TimerCallback& callback)
199199
{
@@ -205,19 +205,17 @@ class TimerCallback: public AbstractTimerCallback
205205
return *this;
206206
}
207207

208-
void invoke(Timer& timer) const
208+
void invoke(Timer& timer) const override
209209
{
210210
(_pObject->*_method)(timer);
211211
}
212212

213-
AbstractTimerCallback* clone() const
213+
AbstractTimerCallback* clone() const override
214214
{
215215
return new TimerCallback(*this);
216216
}
217217

218218
private:
219-
TimerCallback();
220-
221219
C* _pObject;
222220
Callback _method;
223221
};

Diff for: Foundation/src/DirectoryWatcher.cpp

+14-17
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ class DirectoryWatcherStrategy
5454
{
5555
}
5656

57-
virtual ~DirectoryWatcherStrategy()
58-
{
59-
}
57+
virtual ~DirectoryWatcherStrategy() = default;
58+
59+
DirectoryWatcherStrategy() = delete;
60+
DirectoryWatcherStrategy(const DirectoryWatcherStrategy&) = delete;
61+
DirectoryWatcherStrategy& operator = (const DirectoryWatcherStrategy&) = delete;
6062

6163
DirectoryWatcher& owner()
6264
{
@@ -75,12 +77,11 @@ class DirectoryWatcherStrategy
7577
{
7678
}
7779

78-
ItemInfo(const ItemInfo& other):
79-
path(other.path),
80-
size(other.size),
81-
lastModified(other.lastModified)
82-
{
83-
}
80+
ItemInfo(const ItemInfo& other) = default;
81+
ItemInfo& operator=(const ItemInfo& ) = default;
82+
83+
ItemInfo(ItemInfo&& other) = default;
84+
ItemInfo& operator=(ItemInfo&& ) = default;
8485

8586
explicit ItemInfo(const File& f):
8687
path(f.path()),
@@ -93,12 +94,12 @@ class DirectoryWatcherStrategy
9394
File::FileSize size;
9495
Timestamp lastModified;
9596
};
96-
typedef std::map<std::string, ItemInfo> ItemInfoMap;
97+
using ItemInfoMap = std::map<std::string, ItemInfo>;
9798

9899
void scan(ItemInfoMap& entries)
99100
{
100101
DirectoryIterator it(owner().directory());
101-
DirectoryIterator end;
102+
const DirectoryIterator end;
102103
while (it != end)
103104
{
104105
entries[it.path().getFileName()] = ItemInfo(*it);
@@ -110,14 +111,14 @@ class DirectoryWatcherStrategy
110111
{
111112
for (auto& np: newEntries)
112113
{
113-
ItemInfoMap::iterator ito = oldEntries.find(np.first);
114+
const auto ito = oldEntries.find(np.first);
114115
if (ito != oldEntries.end())
115116
{
116117
if ((owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED) && !owner().eventsSuspended())
117118
{
118119
if (np.second.size != ito->second.size || np.second.lastModified != ito->second.lastModified)
119120
{
120-
Poco::File f(np.second.path);
121+
const Poco::File f(np.second.path);
121122
DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_MODIFIED);
122123
owner().itemModified(&owner(), ev);
123124
}
@@ -143,10 +144,6 @@ class DirectoryWatcherStrategy
143144
}
144145

145146
private:
146-
DirectoryWatcherStrategy();
147-
DirectoryWatcherStrategy(const DirectoryWatcherStrategy&);
148-
DirectoryWatcherStrategy& operator = (const DirectoryWatcherStrategy&);
149-
150147
DirectoryWatcher& _owner;
151148
};
152149

Diff for: NetSSL_OpenSSL/src/SecureSocketImpl.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,6 @@ X509* SecureSocketImpl::peerCertificate() const
518518
{
519519
LockT l(_mutex);
520520

521-
X509* pCert = nullptr;
522-
523521
if (_pSSL)
524522
return ::SSL_get_peer_certificate(_pSSL);
525523
else

Diff for: PDF/include/Poco/PDF/Document.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class PDF_API Document
162162
/// _fileName is used. If member variable is empty string,
163163
/// document is saved to the memory stream.
164164

165-
const DataPtr data(SizeType& sz);
165+
DataPtr data(SizeType& sz);
166166
/// Returns the document content as raw data and data size in
167167
/// the sz argument.
168168

Diff for: PDF/src/Document.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void Document::save(const std::string fileName)
8585
}
8686

8787

88-
const Document::DataPtr Document::data(SizeType& sz)
88+
Document::DataPtr Document::data(SizeType& sz)
8989
{
9090
sz = size();
9191
delete _pRawData;

Diff for: Redis/include/Poco/Redis/Array.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class Redis_API Array
4747
virtual ~Array();
4848
/// Destroys the Array.
4949

50+
Array& operator=(const Array&) = default;
51+
Array& operator=(Array&&) = default;
52+
5053
template<typename T>
5154
Array& operator<<(const T& arg)
5255
/// Adds the argument to the array.
@@ -126,7 +129,7 @@ class Redis_API Array
126129
RedisType::Ptr element = _elements.value().at(pos);
127130
if ( RedisTypeTraits<T>::TypeId == element->type() )
128131
{
129-
Type<T>* concrete = dynamic_cast<Type<T>* >(element.get());
132+
auto* concrete = dynamic_cast<Type<T>* >(element.get());
130133
if ( concrete != NULL ) return concrete->value();
131134
}
132135
throw BadCastException();
@@ -296,7 +299,7 @@ struct RedisTypeTraits<Array>
296299
{
297300
value.clear();
298301

299-
Int64 length = NumberParser::parse64(input.getline());
302+
const Int64 length = NumberParser::parse64(input.getline());
300303

301304
if ( length != -1 )
302305
{
@@ -316,7 +319,8 @@ struct RedisTypeTraits<Array>
316319
};
317320

318321

319-
} } // namespace Poco::Redis
322+
} // namespace Redis
323+
} // namespace Poco
320324

321325

322326
#endif // Redis_Array_INCLUDED

Diff for: Redis/include/Poco/Redis/Command.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ class Redis_API Command: public Array
5757
Command(const Command& copy);
5858
/// Creates a command by copying another one.
5959

60-
virtual ~Command();
60+
~Command() override;
6161
/// Destroys the command.
6262

63+
Command& operator=(const Command&) = default;
64+
Command& operator=(Command&&) = default;
65+
6366
static Command append(const std::string& key, const std::string& value);
6467
/// Creates and returns an APPEND command.
6568

@@ -282,7 +285,8 @@ class Redis_API Command: public Array
282285
};
283286

284287

285-
} } // namespace Poco::Redis
288+
} // namespace Redis
289+
} // namespace Poco
286290

287291

288292
#endif // Redis_Command_INCLUDED

Diff for: Redis/src/Client.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ Array Client::sendCommands(const std::vector<Array>& commands)
223223
}
224224
_output->flush();
225225

226-
for (int i = 0; i < commands.size(); ++i)
226+
for (std::size_t i = 0; i < commands.size(); ++i)
227227
{
228228
results.addRedisType(readReply());
229229
}

0 commit comments

Comments
 (0)