Fix warnings in emucore

This commit is contained in:
Nekotekina Aux1
2020-03-04 17:08:40 +03:00
committed by Nekotekina
parent f2f3321952
commit 250736ece5
48 changed files with 189 additions and 193 deletions
+1 -1
View File
@@ -923,7 +923,7 @@ public:
name.append(".gz");
z_stream zs{};
uLong zsz = compressBound(obj.getBufferSize()) + 256;
uLong zsz = compressBound(::narrow<u32>(obj.getBufferSize(), HERE)) + 256;
auto zbuf = std::make_unique<uchar[]>(zsz);
#ifndef _MSC_VER
#pragma GCC diagnostic push
+6 -15
View File
@@ -7,22 +7,13 @@
#include <functional>
#include <string_view>
// Copy null-terminated string from std::string to char array with truncation
template <std::size_t N>
inline void strcpy_trunc(char (&dst)[N], const std::string& src)
// Copy null-terminated string from a std::string or a char array to a char array with truncation
template <typename D, typename T>
inline void strcpy_trunc(D& dst, const T& src)
{
const std::size_t count = src.size() >= N ? N - 1 : src.size();
std::memcpy(dst, src.c_str(), count);
std::memset(dst + count, 0, N - count);
}
// Copy null-terminated string from char array to another char array with truncation
template <std::size_t N, std::size_t N2>
inline void strcpy_trunc(char (&dst)[N], const char (&src)[N2])
{
const std::size_t count = N2 >= N ? N - 1 : N2;
std::memcpy(dst, src, count);
std::memset(dst + count, 0, N - count);
const std::size_t count = std::size(src) >= std::size(dst) ? std::size(dst) - 1 : std::size(src);
std::memcpy(std::data(dst), std::data(src), count);
std::memset(std::data(dst) + count, 0, std::size(dst) - count);
}
namespace fmt
+3 -3
View File
@@ -1,4 +1,4 @@
#include "cond.h"
#include "cond.h"
#include "sync.h"
#include "lockless.h"
@@ -38,7 +38,7 @@ void cond_variable::imp_wake(u32 _count) noexcept
}
// Add signal
value += c_signal_mask & -c_signal_mask;
value += c_signal_mask & (0 - c_signal_mask);
return true;
});
@@ -47,7 +47,7 @@ void cond_variable::imp_wake(u32 _count) noexcept
return;
}
if (_count > 1 || ((_old + (c_signal_mask & -c_signal_mask)) & c_signal_mask) == c_signal_mask)
if (_count > 1 || ((_old + (c_signal_mask & (0 - c_signal_mask))) & c_signal_mask) == c_signal_mask)
{
// Resort to notify_all if signal count reached max
m_value.notify_all();