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