diff --git a/src/crypto/rx/Rx_linux.cpp b/src/crypto/rx/Rx_linux.cpp index 46f13c04b..991151253 100644 --- a/src/crypto/rx/Rx_linux.cpp +++ b/src/crypto/rx/Rx_linux.cpp @@ -92,7 +92,7 @@ static MsrItem rdmsr(uint32_t reg) static bool wrmsr_on_cpu(uint32_t reg, uint32_t cpu, uint64_t value, uint64_t mask) { // If a bit in mask is set to 1, use new value, otherwise use old value - if (mask != uint64_t(-1)) { + if (mask != MsrItem::kNoMask) { uint64_t old_value; if (rdmsr_on_cpu(reg, cpu, old_value)) { value = (value & mask) | (old_value & ~mask); diff --git a/src/crypto/rx/Rx_win.cpp b/src/crypto/rx/Rx_win.cpp index b4e7588d2..8e9c198f4 100644 --- a/src/crypto/rx/Rx_win.cpp +++ b/src/crypto/rx/Rx_win.cpp @@ -227,7 +227,7 @@ static bool wrmsr(HANDLE driver, uint32_t reg, uint64_t value, uint64_t mask) static_assert(sizeof(input) == 12, "Invalid struct size for WinRing0 driver"); // If a bit in mask is set to 1, use new value, otherwise use old value - if (mask != uint64_t(-1)) { + if (mask != MsrItem::kNoMask) { uint64_t old_value; if (rdmsr(driver, reg, old_value)) { value = (value & mask) | (old_value & ~mask); diff --git a/src/crypto/rx/msr/MsrItem.cpp b/src/crypto/rx/msr/MsrItem.cpp index 97eb843f6..3f70b8b61 100644 --- a/src/crypto/rx/msr/MsrItem.cpp +++ b/src/crypto/rx/msr/MsrItem.cpp @@ -45,7 +45,7 @@ xmrig::MsrItem::MsrItem(const rapidjson::Value &value) m_reg = strtoul(kv[0], nullptr, 0); m_value = strtoul(kv[1], nullptr, 0); - m_mask = (kv.size() > 2) ? strtoul(kv[2], nullptr, 0) : uint64_t(-1); + m_mask = (kv.size() > 2) ? strtoul(kv[2], nullptr, 0) : kNoMask; } diff --git a/src/crypto/rx/msr/MsrItem.h b/src/crypto/rx/msr/MsrItem.h index 005274892..5b84f432d 100644 --- a/src/crypto/rx/msr/MsrItem.h +++ b/src/crypto/rx/msr/MsrItem.h @@ -31,6 +31,7 @@ #include "base/tools/String.h" +#include #include @@ -44,8 +45,10 @@ class RxDataset; class MsrItem { public: + constexpr static uint64_t kNoMask = std::numeric_limits::max(); + inline MsrItem() = default; - inline MsrItem(uint32_t reg, uint64_t value, uint64_t mask = uint64_t(-1)) : m_reg(reg), m_value(value), m_mask(mask) {} + inline MsrItem(uint32_t reg, uint64_t value, uint64_t mask = kNoMask) : m_reg(reg), m_value(value), m_mask(mask) {} MsrItem(const rapidjson::Value &value); @@ -60,7 +63,7 @@ public: private: uint32_t m_reg = 0; uint64_t m_value = 0; - uint64_t m_mask = uint64_t(-1); + uint64_t m_mask = kNoMask; };