mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 11:06:50 +01:00
fix: g++ C++20 warnings #3734
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
@@ -37,7 +38,7 @@ protected:
|
|||||||
bool waitImpl(long milliseconds);
|
bool waitImpl(long milliseconds);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
volatile int _n;
|
std::atomic<int> _n;
|
||||||
int _max;
|
int _max;
|
||||||
pthread_mutex_t _mutex;
|
pthread_mutex_t _mutex;
|
||||||
pthread_cond_t _cond;
|
pthread_cond_t _cond;
|
||||||
|
|||||||
@@ -129,10 +129,16 @@ const DigestEngine::Digest& MD4Engine::digest()
|
|||||||
|
|
||||||
/* Store state in digest */
|
/* Store state in digest */
|
||||||
unsigned char digest[16];
|
unsigned char digest[16];
|
||||||
encode(digest, _context.state, 16);
|
encode(digest, _context.state, sizeof(digest));
|
||||||
_digest.clear();
|
_digest.clear();
|
||||||
|
#if defined(POCO_COMPILER_GCC)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wstringop-overflow"
|
||||||
|
#endif
|
||||||
_digest.insert(_digest.begin(), digest, digest + sizeof(digest));
|
_digest.insert(_digest.begin(), digest, digest + sizeof(digest));
|
||||||
|
#if defined(POCO_COMPILER_GCC)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
/* Zeroize sensitive information. */
|
/* Zeroize sensitive information. */
|
||||||
std::memset(&_context, 0, sizeof (_context));
|
std::memset(&_context, 0, sizeof (_context));
|
||||||
reset();
|
reset();
|
||||||
|
|||||||
@@ -129,10 +129,16 @@ const DigestEngine::Digest& MD5Engine::digest()
|
|||||||
|
|
||||||
/* Store state in digest */
|
/* Store state in digest */
|
||||||
unsigned char digest[16];
|
unsigned char digest[16];
|
||||||
encode(digest, _context.state, 16);
|
encode(digest, _context.state, sizeof(digest));
|
||||||
_digest.clear();
|
_digest.clear();
|
||||||
|
#if defined(POCO_COMPILER_GCC)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wstringop-overflow"
|
||||||
|
#endif
|
||||||
_digest.insert(_digest.begin(), digest, digest + sizeof(digest));
|
_digest.insert(_digest.begin(), digest, digest + sizeof(digest));
|
||||||
|
#if defined(POCO_COMPILER_GCC)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
/* Zeroize sensitive information. */
|
/* Zeroize sensitive information. */
|
||||||
std::memset(&_context, 0, sizeof (_context));
|
std::memset(&_context, 0, sizeof (_context));
|
||||||
reset();
|
reset();
|
||||||
|
|||||||
@@ -143,7 +143,14 @@ const DigestEngine::Digest& SHA1Engine::digest()
|
|||||||
for (count = 0; count < DIGEST_SIZE; count++)
|
for (count = 0; count < DIGEST_SIZE; count++)
|
||||||
hash[count] = (BYTE) ((_context.digest[count>>2]) >> (8*(3-(count & 0x3)))) & 0xff;
|
hash[count] = (BYTE) ((_context.digest[count>>2]) >> (8*(3-(count & 0x3)))) & 0xff;
|
||||||
_digest.clear();
|
_digest.clear();
|
||||||
|
#if defined(POCO_COMPILER_GCC)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wstringop-overflow"
|
||||||
|
#endif
|
||||||
_digest.insert(_digest.begin(), hash, hash + DIGEST_SIZE);
|
_digest.insert(_digest.begin(), hash, hash + DIGEST_SIZE);
|
||||||
|
#if defined(POCO_COMPILER_GCC)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
reset();
|
reset();
|
||||||
return _digest;
|
return _digest;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "Poco/RWLock.h"
|
#include "Poco/RWLock.h"
|
||||||
#include "Poco/Thread.h"
|
#include "Poco/Thread.h"
|
||||||
#include "Poco/Runnable.h"
|
#include "Poco/Runnable.h"
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
|
||||||
using Poco::RWLock;
|
using Poco::RWLock;
|
||||||
@@ -24,7 +25,12 @@ using Poco::Runnable;
|
|||||||
class RWLockRunnable: public Runnable
|
class RWLockRunnable: public Runnable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RWLockRunnable(RWLock& lock, volatile int& counter): _lock(lock), _counter(counter), _ok(true)
|
#ifdef __cpp_lib_atomic_ref
|
||||||
|
RWLockRunnable(RWLock& lock, int& counter):
|
||||||
|
#else
|
||||||
|
RWLockRunnable(RWLock& lock, volatile int& counter):
|
||||||
|
#endif
|
||||||
|
_lock(lock), _counter(counter), _ok(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +71,11 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
RWLock& _lock;
|
RWLock& _lock;
|
||||||
|
#ifdef __cpp_lib_atomic_ref
|
||||||
|
std::atomic_ref<int> _counter;
|
||||||
|
#else
|
||||||
volatile int& _counter;
|
volatile int& _counter;
|
||||||
|
#endif
|
||||||
bool _ok;
|
bool _ok;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -73,7 +83,12 @@ private:
|
|||||||
class RWTryLockRunnable: public Runnable
|
class RWTryLockRunnable: public Runnable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RWTryLockRunnable(RWLock& lock, volatile int& counter): _lock(lock), _counter(counter), _ok(true)
|
#ifdef __cpp_lib_atomic_ref
|
||||||
|
RWTryLockRunnable(RWLock& lock, int& counter):
|
||||||
|
#else
|
||||||
|
RWTryLockRunnable(RWLock& lock, volatile int& counter):
|
||||||
|
#endif
|
||||||
|
_lock(lock), _counter(counter), _ok(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +129,11 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
RWLock& _lock;
|
RWLock& _lock;
|
||||||
|
#ifdef __cpp_lib_atomic_ref
|
||||||
|
std::atomic_ref<int> _counter;
|
||||||
|
#else
|
||||||
volatile int& _counter;
|
volatile int& _counter;
|
||||||
|
#endif
|
||||||
bool _ok;
|
bool _ok;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,9 @@ private:
|
|||||||
{
|
{
|
||||||
T result = 0;
|
T result = 0;
|
||||||
if (123 <= std::numeric_limits<T>::max())
|
if (123 <= std::numeric_limits<T>::max())
|
||||||
|
{
|
||||||
assertTrue (Poco::strToInt("123", result, 10)); assertTrue (result == 123);
|
assertTrue (Poco::strToInt("123", result, 10)); assertTrue (result == 123);
|
||||||
|
}
|
||||||
|
|
||||||
assertTrue (Poco::strToInt("0", result, 10)); assertTrue (result == 0);
|
assertTrue (Poco::strToInt("0", result, 10)); assertTrue (result == 0);
|
||||||
assertTrue (Poco::strToInt("000", result, 10)); assertTrue (result == 0);
|
assertTrue (Poco::strToInt("000", result, 10)); assertTrue (result == 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user