From c7ac314110711af2a0bae4fddf914e1eebd32bc7 Mon Sep 17 00:00:00 2001 From: XMRig <support@xmrig.com> Date: Wed, 25 Aug 2021 18:45:15 +0700 Subject: [PATCH] Code cleanup based on Clang-Tidy. --- src/backend/common/Threads.cpp | 4 +- src/backend/common/Workers.cpp | 7 ++- src/backend/common/Workers.h | 4 +- src/backend/cpu/CpuBackend.cpp | 6 +-- src/backend/cpu/CpuConfig.cpp | 3 +- src/backend/cpu/CpuThreads.cpp | 15 ++---- src/backend/cpu/CpuThreads.h | 12 ++--- src/backend/cpu/CpuWorker.cpp | 8 +-- src/backend/cpu/CpuWorker.h | 4 +- src/backend/cpu/platform/BasicCpuInfo.cpp | 2 +- src/backend/cpu/platform/HwlocCpuInfo.h | 2 +- src/backend/cuda/CudaBackend.cpp | 13 ++--- src/backend/cuda/CudaBackend.h | 10 +--- src/backend/cuda/CudaConfig.cpp | 15 ++---- src/backend/cuda/CudaConfig.h | 10 +--- src/backend/cuda/CudaThread.cpp | 13 ++--- src/backend/cuda/CudaThread.h | 10 +--- src/backend/cuda/CudaThreads.cpp | 13 ++--- src/backend/cuda/CudaThreads.h | 12 ++--- src/backend/cuda/runners/CudaKawPowRunner.cpp | 13 ++--- src/backend/cuda/runners/CudaKawPowRunner.h | 10 +--- src/backend/cuda/wrappers/NvmlLib.cpp | 13 ++--- src/backend/cuda/wrappers/NvmlLib.h | 10 +--- src/backend/opencl/OclBackend.cpp | 13 ++--- src/backend/opencl/OclBackend.h | 10 +--- src/backend/opencl/OclCache.cpp | 17 ++---- src/backend/opencl/OclCache.h | 10 +--- src/backend/opencl/OclConfig.cpp | 13 ++--- src/backend/opencl/OclConfig.h | 10 +--- src/backend/opencl/OclThread.cpp | 19 +++---- src/backend/opencl/OclThread.h | 10 +--- src/backend/opencl/OclWorker.cpp | 2 +- .../kawpow/KawPow_CalculateDAGKernel.cpp | 15 ++---- .../kawpow/KawPow_CalculateDAGKernel.h | 10 +--- .../opencl/runners/OclAstroBWTRunner.cpp | 14 ++--- .../opencl/runners/OclAstroBWTRunner.h | 10 +--- .../opencl/runners/OclKawPowRunner.cpp | 19 +++---- src/backend/opencl/runners/OclKawPowRunner.h | 10 +--- src/backend/opencl/runners/OclRxJitRunner.cpp | 20 +++---- src/backend/opencl/runners/OclRxJitRunner.h | 10 +--- src/backend/opencl/runners/OclRxVmRunner.cpp | 13 ++--- src/backend/opencl/runners/OclRxVmRunner.h | 10 +--- src/backend/opencl/runners/tools/OclCnR.cpp | 19 +++---- .../opencl/runners/tools/OclKawPow.cpp | 24 ++++----- src/backend/opencl/runners/tools/OclKawPow.h | 10 +--- .../opencl/runners/tools/OclSharedData.cpp | 17 ++---- .../opencl/runners/tools/OclSharedData.h | 10 +--- src/backend/opencl/wrappers/AdlLib.cpp | 13 ++--- src/backend/opencl/wrappers/AdlLib.h | 6 +-- src/backend/opencl/wrappers/OclDevice.cpp | 12 ++--- src/backend/opencl/wrappers/OclDevice.h | 10 +--- src/backend/opencl/wrappers/OclLib.cpp | 27 ++++------ src/backend/opencl/wrappers/OclLib.h | 10 +--- src/base/api/Api.cpp | 3 +- src/base/api/Httpd.cpp | 1 + src/base/api/requests/HttpApiRequest.cpp | 3 ++ src/base/io/Console.cpp | 7 ++- src/base/io/Console.h | 6 +-- src/base/io/Env.cpp | 5 +- src/base/io/json/Json.cpp | 7 ++- src/base/io/json/Json.h | 4 +- src/base/io/json/JsonChain.cpp | 11 ++-- src/base/io/log/Log.cpp | 11 ++-- src/base/io/log/Log.h | 4 +- src/base/io/log/backends/ConsoleLog.cpp | 9 ++-- src/base/io/log/backends/ConsoleLog.h | 6 +-- src/base/kernel/Base.cpp | 17 ++---- src/base/kernel/Base.h | 10 +--- src/base/kernel/Entry.cpp | 2 +- src/base/kernel/Platform_win.cpp | 6 +-- src/base/kernel/Process.cpp | 7 ++- src/base/kernel/Process.h | 4 +- src/base/kernel/config/BaseConfig.h | 4 +- src/base/kernel/config/BaseTransform.cpp | 5 +- src/base/net/dns/DnsConfig.cpp | 1 - src/base/net/dns/DnsConfig.h | 2 +- src/base/net/dns/DnsRecords.cpp | 5 +- src/base/net/http/Fetch.cpp | 3 +- src/base/net/http/Http.cpp | 13 ++--- src/base/net/http/Http.h | 11 +--- src/base/net/https/HttpsClient.cpp | 4 +- src/base/net/https/HttpsContext.cpp | 3 +- src/base/net/https/HttpsServer.cpp | 7 ++- src/base/net/https/HttpsServer.h | 5 +- src/base/net/stratum/AutoClient.cpp | 11 ++-- src/base/net/stratum/AutoClient.h | 4 +- src/base/net/stratum/Client.cpp | 54 +++++++++---------- src/base/net/stratum/Client.h | 2 +- src/base/net/stratum/DaemonClient.cpp | 6 +-- src/base/net/stratum/EthStratumClient.cpp | 2 +- src/base/net/stratum/EthStratumClient.h | 3 +- src/base/net/stratum/Pool.cpp | 2 +- src/base/net/stratum/Pools.cpp | 3 ++ src/base/net/stratum/Socks5.cpp | 4 +- src/base/net/stratum/Socks5.h | 5 +- src/base/net/stratum/Tls.cpp | 15 ++---- src/base/net/stratum/Tls.h | 11 ++-- src/base/net/stratum/Url.cpp | 14 ++--- src/base/net/stratum/Url.h | 11 +--- .../net/stratum/benchmark/BenchClient.cpp | 2 +- src/base/net/stratum/benchmark/BenchClient.h | 2 +- src/base/net/tls/TlsConfig.cpp | 13 ++--- src/base/net/tls/TlsConfig.h | 14 ++--- src/base/net/tls/TlsContext.cpp | 15 ++---- src/base/net/tls/TlsContext.h | 12 ++--- src/base/net/tls/TlsGen.cpp | 7 +-- src/base/net/tls/TlsGen.h | 4 +- src/base/tools/Cvt.cpp | 32 +++++------ src/base/tools/cryptonote/BlockTemplate.cpp | 6 ++- src/base/tools/cryptonote/WalletAddress.cpp | 2 +- src/core/Controller.cpp | 7 ++- src/core/Controller.h | 6 +-- src/core/Miner.cpp | 4 +- src/core/config/Config.cpp | 3 +- src/core/config/ConfigTransform.cpp | 4 +- src/crypto/astrobwt/AstroBWT.cpp | 41 +++++++------- src/crypto/astrobwt/AstroBWT.h | 19 +++---- src/crypto/cn/CnCtx.cpp | 16 ++---- src/crypto/cn/CnCtx.h | 12 ++--- src/crypto/common/Nonce.cpp | 17 +++--- src/crypto/common/Nonce.h | 10 +--- src/crypto/common/VirtualMemory_hwloc.cpp | 14 ++--- src/crypto/rx/Rx.cpp | 2 +- src/crypto/rx/RxConfig.cpp | 15 ++---- src/crypto/rx/RxConfig.h | 12 ++--- src/crypto/rx/RxDataset.cpp | 7 ++- src/crypto/rx/RxDataset.h | 4 +- src/crypto/rx/RxFix_win.cpp | 5 +- src/crypto/rx/RxNUMAStorage.cpp | 17 +++--- src/crypto/rx/RxNUMAStorage.h | 4 +- src/hw/dmi/DmiReader.cpp | 2 - src/hw/msr/Msr.cpp | 3 +- src/net/JobResults.cpp | 2 - 133 files changed, 437 insertions(+), 833 deletions(-) diff --git a/src/backend/common/Threads.cpp b/src/backend/common/Threads.cpp index 00af22451..3b71035b6 100644 --- a/src/backend/common/Threads.cpp +++ b/src/backend/common/Threads.cpp @@ -104,7 +104,7 @@ xmrig::String xmrig::Threads<T>::profileName(const Algorithm &algorithm, bool st return String(); } - const String name = algorithm.name(); + String name = algorithm.name(); if (has(name)) { return name; } @@ -122,7 +122,7 @@ xmrig::String xmrig::Threads<T>::profileName(const Algorithm &algorithm, bool st } if (name.contains("/")) { - const String base = name.split('/').at(0); + String base = name.split('/').at(0); if (has(base)) { return base; } diff --git a/src/backend/common/Workers.cpp b/src/backend/common/Workers.cpp index a70affe66..72d02e954 100644 --- a/src/backend/common/Workers.cpp +++ b/src/backend/common/Workers.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "backend/common/Workers.h" #include "backend/common/Hashrate.h" #include "backend/common/interfaces/IBackend.h" @@ -200,7 +199,7 @@ void *xmrig::Workers<T>::onReady(void *arg) template<class T> -void xmrig::Workers<T>::start(const std::vector<T> &data, bool sleep) +void xmrig::Workers<T>::start(const std::vector<T> &data, bool /*sleep*/) { for (const auto &item : data) { m_workers.push_back(new Thread<T>(d_ptr->backend, m_workers.size(), item)); diff --git a/src/backend/common/Workers.h b/src/backend/common/Workers.h index 664912431..76909dd59 100644 --- a/src/backend/common/Workers.h +++ b/src/backend/common/Workers.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/cpu/CpuBackend.cpp b/src/backend/cpu/CpuBackend.cpp index 23c86bfd8..d5ada9adc 100644 --- a/src/backend/cpu/CpuBackend.cpp +++ b/src/backend/cpu/CpuBackend.cpp @@ -136,7 +136,7 @@ private: class CpuBackendPrivate { public: - inline CpuBackendPrivate(Controller *controller) : controller(controller) {} + inline explicit CpuBackendPrivate(Controller *controller) : controller(controller) {} inline void start() @@ -159,7 +159,7 @@ public: } - size_t ways() + size_t ways() const { std::lock_guard<std::mutex> lock(mutex); @@ -167,7 +167,7 @@ public: } - rapidjson::Value hugePages(int version, rapidjson::Document &doc) + rapidjson::Value hugePages(int version, rapidjson::Document &doc) const { HugePagesInfo pages; diff --git a/src/backend/cpu/CpuConfig.cpp b/src/backend/cpu/CpuConfig.cpp index 9ab332722..dc3330abb 100644 --- a/src/backend/cpu/CpuConfig.cpp +++ b/src/backend/cpu/CpuConfig.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "backend/cpu/CpuConfig.h" #include "3rdparty/rapidjson/document.h" #include "backend/cpu/CpuConfig_gen.h" @@ -54,7 +53,7 @@ const char *CpuConfig::kAstroBWTAVX2 = "astrobwt-avx2"; extern template class Threads<CpuThreads>; -} +} // namespace xmrig bool xmrig::CpuConfig::isHwAES() const diff --git a/src/backend/cpu/CpuThreads.cpp b/src/backend/cpu/CpuThreads.cpp index d9ae61b15..5b56a0bfc 100644 --- a/src/backend/cpu/CpuThreads.cpp +++ b/src/backend/cpu/CpuThreads.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <algorithm> @@ -80,7 +73,7 @@ static inline int64_t getAffinity(uint64_t index, int64_t affinity) } -} +} // namespace xmrig xmrig::CpuThreads::CpuThreads(const rapidjson::Value &value) @@ -89,7 +82,7 @@ xmrig::CpuThreads::CpuThreads(const rapidjson::Value &value) for (auto &v : value.GetArray()) { CpuThread thread(v); if (thread.isValid()) { - add(std::move(thread)); + add(thread); } } } diff --git a/src/backend/cpu/CpuThreads.h b/src/backend/cpu/CpuThreads.h index e87f52306..21a1aa0d8 100644 --- a/src/backend/cpu/CpuThreads.h +++ b/src/backend/cpu/CpuThreads.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,7 +41,7 @@ public: inline bool isEmpty() const { return m_data.empty(); } inline const std::vector<CpuThread> &data() const { return m_data; } inline size_t count() const { return m_data.size(); } - inline void add(CpuThread &&thread) { m_data.push_back(thread); } + inline void add(const CpuThread &thread) { m_data.push_back(thread); } inline void add(int64_t affinity, uint32_t intensity) { add(CpuThread(affinity, intensity)); } inline void reserve(size_t capacity) { m_data.reserve(capacity); } diff --git a/src/backend/cpu/CpuWorker.cpp b/src/backend/cpu/CpuWorker.cpp index 085bccb6c..c5a15f9b7 100644 --- a/src/backend/cpu/CpuWorker.cpp +++ b/src/backend/cpu/CpuWorker.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <cassert> #include <thread> #include <mutex> @@ -302,8 +301,9 @@ void xmrig::CpuWorker<N>::start() { # ifdef XMRIG_ALGO_ASTROBWT if (job.algorithm().family() == Algorithm::ASTROBWT) { - if (!astrobwt::astrobwt_dero(m_job.blob(), job.size(), m_ctx[0]->memory, m_hash, m_astrobwtMaxSize, m_astrobwtAVX2)) + if (!astrobwt::astrobwt_dero(m_job.blob(), job.size(), m_ctx[0]->memory, m_hash, m_astrobwtMaxSize, m_astrobwtAVX2)) { valid = false; + } } else # endif diff --git a/src/backend/cpu/CpuWorker.h b/src/backend/cpu/CpuWorker.h index 785763af7..487b20cc0 100644 --- a/src/backend/cpu/CpuWorker.h +++ b/src/backend/cpu/CpuWorker.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/cpu/platform/BasicCpuInfo.cpp b/src/backend/cpu/platform/BasicCpuInfo.cpp index 9771ca452..93b128092 100644 --- a/src/backend/cpu/platform/BasicCpuInfo.cpp +++ b/src/backend/cpu/platform/BasicCpuInfo.cpp @@ -196,7 +196,7 @@ xmrig::BasicCpuInfo::BasicCpuInfo() : } # ifdef XMRIG_FEATURE_ASM - if (hasAES()) { + if (m_flags.test(FLAG_AES)) { char vendor[13] = { 0 }; int32_t data[4] = { 0 }; diff --git a/src/backend/cpu/platform/HwlocCpuInfo.h b/src/backend/cpu/platform/HwlocCpuInfo.h index 69b67a305..390c7d3f3 100644 --- a/src/backend/cpu/platform/HwlocCpuInfo.h +++ b/src/backend/cpu/platform/HwlocCpuInfo.h @@ -65,7 +65,7 @@ protected: private: CpuThreads allThreads(const Algorithm &algorithm, uint32_t limit) const; - void processTopLevelCache(hwloc_obj_t obj, const Algorithm &algorithm, CpuThreads &threads, size_t limit) const; + void processTopLevelCache(hwloc_obj_t cache, const Algorithm &algorithm, CpuThreads &threads, size_t limit) const; void setThreads(size_t threads); static uint32_t m_features; diff --git a/src/backend/cuda/CudaBackend.cpp b/src/backend/cuda/CudaBackend.cpp index 59eaab1ff..0ef59981e 100644 --- a/src/backend/cuda/CudaBackend.cpp +++ b/src/backend/cuda/CudaBackend.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <mutex> #include <string> @@ -138,7 +131,7 @@ private: class CudaBackendPrivate { public: - inline CudaBackendPrivate(Controller *controller) : + inline explicit CudaBackendPrivate(Controller *controller) : controller(controller) { init(controller->config()->cuda()); diff --git a/src/backend/cuda/CudaBackend.h b/src/backend/cuda/CudaBackend.h index 379e9bf18..00de003b8 100644 --- a/src/backend/cuda/CudaBackend.h +++ b/src/backend/cuda/CudaBackend.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/cuda/CudaConfig.cpp b/src/backend/cuda/CudaConfig.cpp index 77bc1749f..65084f241 100644 --- a/src/backend/cuda/CudaConfig.cpp +++ b/src/backend/cuda/CudaConfig.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "backend/cuda/CudaConfig.h" #include "3rdparty/rapidjson/document.h" #include "backend/common/Tags.h" @@ -50,7 +43,7 @@ static const char *kNvml = "nvml"; extern template class Threads<CudaThreads>; -} +} // namespace xmrig rapidjson::Value xmrig::CudaConfig::toJSON(rapidjson::Document &doc) const @@ -118,7 +111,7 @@ void xmrig::CudaConfig::read(const rapidjson::Value &value) if (value.IsObject()) { m_enabled = Json::getBool(value, kEnabled, m_enabled); m_loader = Json::getString(value, kLoader); - m_bfactor = std::min(Json::getUint(value, kBfactorHint, m_bfactor), 12u); + m_bfactor = std::min(Json::getUint(value, kBfactorHint, m_bfactor), 12U); m_bsleep = Json::getUint(value, kBsleepHint, m_bsleep); setDevicesHint(Json::getString(value, kDevicesHint)); diff --git a/src/backend/cuda/CudaConfig.h b/src/backend/cuda/CudaConfig.h index 1c2f2e03e..a80235169 100644 --- a/src/backend/cuda/CudaConfig.h +++ b/src/backend/cuda/CudaConfig.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/cuda/CudaThread.cpp b/src/backend/cuda/CudaThread.cpp index fff58eaa9..007f18021 100644 --- a/src/backend/cuda/CudaThread.cpp +++ b/src/backend/cuda/CudaThread.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "backend/cuda/CudaThread.h" #include "3rdparty/rapidjson/document.h" #include "backend/cuda/wrappers/CudaLib.h" @@ -54,7 +47,7 @@ xmrig::CudaThread::CudaThread(const rapidjson::Value &value) m_index = Json::getUint(value, kIndex); m_threads = Json::getInt(value, kThreads); m_blocks = Json::getInt(value, kBlocks); - m_bfactor = std::min(Json::getUint(value, kBFactor, m_bfactor), 12u); + m_bfactor = std::min(Json::getUint(value, kBFactor, m_bfactor), 12U); m_bsleep = Json::getUint(value, kBSleep, m_bsleep); m_affinity = Json::getUint64(value, kAffinity, m_affinity); diff --git a/src/backend/cuda/CudaThread.h b/src/backend/cuda/CudaThread.h index 75110bfdc..cd30aa7ac 100644 --- a/src/backend/cuda/CudaThread.h +++ b/src/backend/cuda/CudaThread.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/cuda/CudaThreads.cpp b/src/backend/cuda/CudaThreads.cpp index b5696350e..863e2927f 100644 --- a/src/backend/cuda/CudaThreads.cpp +++ b/src/backend/cuda/CudaThreads.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "backend/cuda/CudaThreads.h" #include "3rdparty/rapidjson/document.h" #include "base/io/json/Json.h" @@ -37,7 +30,7 @@ xmrig::CudaThreads::CudaThreads(const rapidjson::Value &value) for (auto &v : value.GetArray()) { CudaThread thread(v); if (thread.isValid()) { - add(std::move(thread)); + add(thread); } } } diff --git a/src/backend/cuda/CudaThreads.h b/src/backend/cuda/CudaThreads.h index eb6d54ee2..98a4abc29 100644 --- a/src/backend/cuda/CudaThreads.h +++ b/src/backend/cuda/CudaThreads.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,7 +40,7 @@ public: inline bool isEmpty() const { return m_data.empty(); } inline const std::vector<CudaThread> &data() const { return m_data; } inline size_t count() const { return m_data.size(); } - inline void add(CudaThread &&thread) { m_data.push_back(thread); } + inline void add(const CudaThread &thread) { m_data.push_back(thread); } inline void reserve(size_t capacity) { m_data.reserve(capacity); } inline bool operator!=(const CudaThreads &other) const { return !isEqual(other); } diff --git a/src/backend/cuda/runners/CudaKawPowRunner.cpp b/src/backend/cuda/runners/CudaKawPowRunner.cpp index a03dd8c8e..7b8a72362 100644 --- a/src/backend/cuda/runners/CudaKawPowRunner.cpp +++ b/src/backend/cuda/runners/CudaKawPowRunner.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "backend/cuda/runners/CudaKawPowRunner.h" #include "3rdparty/libethash/data_sizes.h" #include "backend/cuda/CudaLaunchData.h" @@ -66,7 +59,7 @@ bool xmrig::CudaKawPowRunner::set(const Job &job, uint8_t *blob) const uint64_t start_ms = Chrono::steadyMSecs(); - const bool result = CudaLib::kawPowPrepare(m_ctx, cache.data(), cache.size(), cache.l1_cache(), cache.dag_size(epoch), height, dag_sizes); + const bool result = CudaLib::kawPowPrepare(m_ctx, cache.data(), cache.size(), cache.l1_cache(), KPCache::dag_size(epoch), height, dag_sizes); if (!result) { LOG_ERR("%s " YELLOW("KawPow") RED(" failed to initialize DAG: ") RED_BOLD("%s"), Tags::nvidia(), CudaLib::lastError(m_ctx)); } diff --git a/src/backend/cuda/runners/CudaKawPowRunner.h b/src/backend/cuda/runners/CudaKawPowRunner.h index ecd7642df..f49876e11 100644 --- a/src/backend/cuda/runners/CudaKawPowRunner.h +++ b/src/backend/cuda/runners/CudaKawPowRunner.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/cuda/wrappers/NvmlLib.cpp b/src/backend/cuda/wrappers/NvmlLib.cpp index cb05bdc17..841d19026 100644 --- a/src/backend/cuda/wrappers/NvmlLib.cpp +++ b/src/backend/cuda/wrappers/NvmlLib.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2019 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <stdexcept> #include <uv.h> @@ -117,7 +110,7 @@ bool xmrig::NvmlLib::assign(std::vector<CudaDevice> &devices) } for (uint32_t i = 0; i < count; i++) { - nvmlDevice_t nvmlDevice; + nvmlDevice_t nvmlDevice = nullptr; if (pNvmlDeviceGetHandleByIndex(i, &nvmlDevice) != NVML_SUCCESS) { continue; } diff --git a/src/backend/cuda/wrappers/NvmlLib.h b/src/backend/cuda/wrappers/NvmlLib.h index 85b80d0ca..79fc3a7fd 100644 --- a/src/backend/cuda/wrappers/NvmlLib.h +++ b/src/backend/cuda/wrappers/NvmlLib.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2019 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/opencl/OclBackend.cpp b/src/backend/opencl/OclBackend.cpp index d0d04f37d..18b8892a1 100644 --- a/src/backend/opencl/OclBackend.cpp +++ b/src/backend/opencl/OclBackend.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <mutex> #include <string> @@ -134,7 +127,7 @@ private: class OclBackendPrivate { public: - inline OclBackendPrivate(Controller *controller) : + inline explicit OclBackendPrivate(Controller *controller) : controller(controller) { init(controller->config()->cl()); diff --git a/src/backend/opencl/OclBackend.h b/src/backend/opencl/OclBackend.h index 1c196bae6..64236ec99 100644 --- a/src/backend/opencl/OclBackend.h +++ b/src/backend/opencl/OclBackend.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/opencl/OclCache.cpp b/src/backend/opencl/OclCache.cpp index e93019c88..6f3d670a9 100644 --- a/src/backend/opencl/OclCache.cpp +++ b/src/backend/opencl/OclCache.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <fstream> #include <map> #include <mutex> @@ -50,7 +43,7 @@ static cl_program createFromSource(const IOclRunner *runner) { LOG_INFO("%s GPU " WHITE_BOLD("#%zu") " " YELLOW_BOLD("compiling..."), ocl_tag(), runner->data().device.index()); - cl_int ret; + cl_int ret = 0; cl_device_id device = runner->data().device.id(); const char *source = runner->source(); const uint64_t ts = Chrono::steadyMSecs(); @@ -89,8 +82,8 @@ static cl_program createFromBinary(const IOclRunner *runner, const std::string & auto data_ptr = s.data(); cl_device_id device = runner->data().device.id(); - cl_int clStatus; - cl_int ret; + cl_int clStatus = 0; + cl_int ret = 0; cl_program program = OclLib::createProgramWithBinary(runner->ctx(), 1, &device, &bin_size, reinterpret_cast<const unsigned char **>(&data_ptr), &clStatus, &ret); if (ret != CL_SUCCESS) { return nullptr; diff --git a/src/backend/opencl/OclCache.h b/src/backend/opencl/OclCache.h index 5f17bfca9..942ce39c2 100644 --- a/src/backend/opencl/OclCache.h +++ b/src/backend/opencl/OclCache.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/opencl/OclConfig.cpp b/src/backend/opencl/OclConfig.cpp index 4f7349adc..06a9b2831 100644 --- a/src/backend/opencl/OclConfig.cpp +++ b/src/backend/opencl/OclConfig.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "backend/opencl/OclConfig.h" #include "3rdparty/rapidjson/document.h" #include "backend/common/Tags.h" @@ -55,7 +48,7 @@ static const char *kAdl = "adl"; extern template class Threads<OclThreads>; -} +} // namespace xmrig #ifndef XMRIG_OS_APPLE diff --git a/src/backend/opencl/OclConfig.h b/src/backend/opencl/OclConfig.h index 0aeca97ad..7002a46d2 100644 --- a/src/backend/opencl/OclConfig.h +++ b/src/backend/opencl/OclConfig.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/opencl/OclThread.cpp b/src/backend/opencl/OclThread.cpp index 77f6ef11b..c04d5e12a 100644 --- a/src/backend/opencl/OclThread.cpp +++ b/src/backend/opencl/OclThread.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "backend/opencl/OclThread.h" #include "3rdparty/rapidjson/document.h" #include "base/io/json/Json.h" @@ -56,15 +49,15 @@ xmrig::OclThread::OclThread(const rapidjson::Value &value) } m_index = Json::getUint(value, kIndex); - m_worksize = std::max(std::min(Json::getUint(value, kWorksize), 512u), 1u); - m_unrollFactor = std::max(std::min(Json::getUint(value, kUnroll, m_unrollFactor), 128u), 1u); + m_worksize = std::max(std::min(Json::getUint(value, kWorksize), 512U), 1U); + m_unrollFactor = std::max(std::min(Json::getUint(value, kUnroll, m_unrollFactor), 128U), 1U); setIntensity(Json::getUint(value, kIntensity)); const auto &si = Json::getArray(value, kStridedIndex); if (si.IsArray() && si.Size() >= 2) { - m_stridedIndex = std::min(si[0].GetUint(), 2u); - m_memChunk = std::min(si[1].GetUint(), 18u); + m_stridedIndex = std::min(si[0].GetUint(), 2U); + m_memChunk = std::min(si[1].GetUint(), 18U); } else { m_stridedIndex = 0; diff --git a/src/backend/opencl/OclThread.h b/src/backend/opencl/OclThread.h index 0c3f03e23..5d2e6658d 100644 --- a/src/backend/opencl/OclThread.h +++ b/src/backend/opencl/OclThread.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/opencl/OclWorker.cpp b/src/backend/opencl/OclWorker.cpp index 727a64c9c..d2563d8ff 100644 --- a/src/backend/opencl/OclWorker.cpp +++ b/src/backend/opencl/OclWorker.cpp @@ -85,7 +85,7 @@ xmrig::OclWorker::OclWorker(size_t id, const OclLaunchData &data) : case Algorithm::ARGON2: # ifdef XMRIG_ALGO_ARGON2 - m_runner = nullptr; // TODO OclArgon2Runner + m_runner = nullptr; # endif break; diff --git a/src/backend/opencl/kernels/kawpow/KawPow_CalculateDAGKernel.cpp b/src/backend/opencl/kernels/kawpow/KawPow_CalculateDAGKernel.cpp index 0130a37d6..ec1ed6f46 100644 --- a/src/backend/opencl/kernels/kawpow/KawPow_CalculateDAGKernel.cpp +++ b/src/backend/opencl/kernels/kawpow/KawPow_CalculateDAGKernel.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "KawPow_CalculateDAGKernel.h" #include "backend/opencl/wrappers/OclLib.h" #include "crypto/kawpow/KPCache.h" @@ -37,8 +30,8 @@ void xmrig::KawPow_CalculateDAGKernel::enqueue(cl_command_queue queue, size_t th void xmrig::KawPow_CalculateDAGKernel::setArgs(uint32_t start, cl_mem g_light, cl_mem g_dag, uint32_t dag_words, uint32_t light_words) { setArg(0, sizeof(start), &start); - setArg(1, sizeof(g_light), &g_light); - setArg(2, sizeof(g_dag), &g_dag); + setArg(1, sizeof(cl_mem), &g_light); + setArg(2, sizeof(cl_mem), &g_dag); const uint32_t isolate = 1; setArg(3, sizeof(isolate), &isolate); diff --git a/src/backend/opencl/kernels/kawpow/KawPow_CalculateDAGKernel.h b/src/backend/opencl/kernels/kawpow/KawPow_CalculateDAGKernel.h index 042b768f0..b5ceee8bd 100644 --- a/src/backend/opencl/kernels/kawpow/KawPow_CalculateDAGKernel.h +++ b/src/backend/opencl/kernels/kawpow/KawPow_CalculateDAGKernel.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/opencl/runners/OclAstroBWTRunner.cpp b/src/backend/opencl/runners/OclAstroBWTRunner.cpp index fb9ecb22b..7470fd62d 100644 --- a/src/backend/opencl/runners/OclAstroBWTRunner.cpp +++ b/src/backend/opencl/runners/OclAstroBWTRunner.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "backend/opencl/runners/OclAstroBWTRunner.h" #include "backend/opencl/kernels/astrobwt/AstroBWT_FilterKernel.h" #include "backend/opencl/kernels/astrobwt/AstroBWT_FindSharesKernel.h" @@ -125,8 +118,9 @@ void xmrig::OclAstroBWTRunner::run(uint32_t nonce, uint32_t *hashOutput) m_sha3_initial_kernel->enqueue(m_queue, m_batch_size1); - for (uint32_t i = 0; i < m_batch_size1; ++i) + for (uint32_t i = 0; i < m_batch_size1; ++i) { m_bwt_data_sizes_host[i] = STAGE1_SIZE; + } enqueueWriteBuffer(m_bwt_data_sizes, CL_FALSE, 0, m_batch_size1 * sizeof(uint32_t), m_bwt_data_sizes_host); diff --git a/src/backend/opencl/runners/OclAstroBWTRunner.h b/src/backend/opencl/runners/OclAstroBWTRunner.h index 5b337e9c5..d1204f920 100644 --- a/src/backend/opencl/runners/OclAstroBWTRunner.h +++ b/src/backend/opencl/runners/OclAstroBWTRunner.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/opencl/runners/OclKawPowRunner.cpp b/src/backend/opencl/runners/OclKawPowRunner.cpp index fcc0058b8..275e3f9a7 100644 --- a/src/backend/opencl/runners/OclKawPowRunner.cpp +++ b/src/backend/opencl/runners/OclKawPowRunner.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "backend/opencl/runners/OclKawPowRunner.h" #include "backend/common/Tags.h" #include "3rdparty/libethash/ethash_internal.h" @@ -172,12 +165,12 @@ void OclKawPowRunner::set(const Job &job, uint8_t *blob) const uint64_t target = job.target(); const uint32_t hack_false = 0; - OclLib::setKernelArg(m_searchKernel, 0, sizeof(m_dag), &m_dag); - OclLib::setKernelArg(m_searchKernel, 1, sizeof(m_input), &m_input); + OclLib::setKernelArg(m_searchKernel, 0, sizeof(cl_mem), &m_dag); + OclLib::setKernelArg(m_searchKernel, 1, sizeof(cl_mem), &m_input); OclLib::setKernelArg(m_searchKernel, 2, sizeof(target), &target); OclLib::setKernelArg(m_searchKernel, 3, sizeof(hack_false), &hack_false); - OclLib::setKernelArg(m_searchKernel, 4, sizeof(m_output), &m_output); - OclLib::setKernelArg(m_searchKernel, 5, sizeof(m_stop), &m_stop); + OclLib::setKernelArg(m_searchKernel, 4, sizeof(cl_mem), &m_output); + OclLib::setKernelArg(m_searchKernel, 5, sizeof(cl_mem), &m_stop); m_blob = blob; enqueueWriteBuffer(m_input, CL_TRUE, 0, BLOB_SIZE, m_blob); diff --git a/src/backend/opencl/runners/OclKawPowRunner.h b/src/backend/opencl/runners/OclKawPowRunner.h index a88414e53..d236ce1ea 100644 --- a/src/backend/opencl/runners/OclKawPowRunner.h +++ b/src/backend/opencl/runners/OclKawPowRunner.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/opencl/runners/OclRxJitRunner.cpp b/src/backend/opencl/runners/OclRxJitRunner.cpp index 84d84c49a..c106c94d5 100644 --- a/src/backend/opencl/runners/OclRxJitRunner.cpp +++ b/src/backend/opencl/runners/OclRxJitRunner.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -105,7 +99,7 @@ bool xmrig::OclRxJitRunner::loadAsmProgram() uint32_t elf_header_flags = 0; const uint32_t elf_header_flags_offset = 0x30; - size_t bin_size; + size_t bin_size = 0; if (OclLib::getProgramInfo(m_program, CL_PROGRAM_BINARY_SIZES, sizeof(bin_size), &bin_size) != CL_SUCCESS) { return false; } @@ -120,8 +114,8 @@ bool xmrig::OclRxJitRunner::loadAsmProgram() elf_header_flags = *reinterpret_cast<uint32_t*>((binary_data.data() + elf_header_flags_offset)); } - size_t len; - unsigned char *binary; + size_t len = 0; + unsigned char *binary = nullptr; switch (m_gcn_version) { case 14: @@ -143,8 +137,8 @@ bool xmrig::OclRxJitRunner::loadAsmProgram() *reinterpret_cast<uint32_t*>(binary + elf_header_flags_offset) = elf_header_flags; } - cl_int status; - cl_int ret; + cl_int status = 0; + cl_int ret = 0; cl_device_id device = data().device.id(); m_asmProgram = OclLib::createProgramWithBinary(ctx(), 1, &device, &len, (const unsigned char**) &binary, &status, &ret); diff --git a/src/backend/opencl/runners/OclRxJitRunner.h b/src/backend/opencl/runners/OclRxJitRunner.h index 9e43363c3..2dca1c1b0 100644 --- a/src/backend/opencl/runners/OclRxJitRunner.h +++ b/src/backend/opencl/runners/OclRxJitRunner.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/opencl/runners/OclRxVmRunner.cpp b/src/backend/opencl/runners/OclRxVmRunner.cpp index 3a30d5610..f0737dd78 100644 --- a/src/backend/opencl/runners/OclRxVmRunner.cpp +++ b/src/backend/opencl/runners/OclRxVmRunner.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2019 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +17,6 @@ */ #include "backend/opencl/runners/OclRxVmRunner.h" - #include "backend/opencl/kernels/rx/Blake2bHashRegistersKernel.h" #include "backend/opencl/kernels/rx/ExecuteVmKernel.h" #include "backend/opencl/kernels/rx/HashAesKernel.h" @@ -76,7 +69,7 @@ void xmrig::OclRxVmRunner::build() void xmrig::OclRxVmRunner::execute(uint32_t iteration) { - const uint32_t bfactor = std::min(data().thread.bfactor(), 8u); + const uint32_t bfactor = std::min(data().thread.bfactor(), 8U); const uint32_t num_iterations = RxAlgo::programIterations(m_algorithm) >> bfactor; m_init_vm->enqueue(m_queue, m_intensity, iteration); diff --git a/src/backend/opencl/runners/OclRxVmRunner.h b/src/backend/opencl/runners/OclRxVmRunner.h index 8d044e744..fee59ee67 100644 --- a/src/backend/opencl/runners/OclRxVmRunner.h +++ b/src/backend/opencl/runners/OclRxVmRunner.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2019 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/opencl/runners/tools/OclCnR.cpp b/src/backend/opencl/runners/tools/OclCnR.cpp index c27a58f03..5b3e55004 100644 --- a/src/backend/opencl/runners/tools/OclCnR.cpp +++ b/src/backend/opencl/runners/tools/OclCnR.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2019 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +17,6 @@ */ #include "backend/opencl/runners/tools/OclCnR.h" - #include "backend/opencl/cl/cn/cryptonight_r_cl.h" #include "backend/opencl/interfaces/IOclRunner.h" #include "backend/opencl/OclCache.h" @@ -62,7 +55,7 @@ public: inline bool isExpired(uint64_t offset) const { return m_offset + OclCnR::kHeightChunkSize < offset; } inline bool match(const Algorithm &algo, uint64_t offset, uint32_t index) const { return m_algo == algo && m_offset == offset && m_index == index; } inline bool match(const IOclRunner &runner, uint64_t offset) const { return match(runner.algorithm(), offset, runner.deviceIndex()); } - inline void release() { OclLib::release(program); } + inline void release() const { OclLib::release(program); } cl_program program; @@ -165,7 +158,7 @@ public: return program; } - cl_int ret; + cl_int ret = 0; const std::string source = getSource(offset); cl_device_id device = runner.data().device.id(); const char *s = source.c_str(); @@ -190,7 +183,7 @@ public: } private: - std::string getCode(const V4_Instruction *code, int code_size) const + static std::string getCode(const V4_Instruction *code, int code_size) { std::stringstream s; @@ -231,7 +224,7 @@ private: } - std::string getSource(uint64_t offset) const + static std::string getSource(uint64_t offset) { std::string source(cryptonight_r_defines_cl); diff --git a/src/backend/opencl/runners/tools/OclKawPow.cpp b/src/backend/opencl/runners/tools/OclKawPow.cpp index 15feeb80c..40b2b9795 100644 --- a/src/backend/opencl/runners/tools/OclKawPow.cpp +++ b/src/backend/opencl/runners/tools/OclKawPow.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2019 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -66,7 +60,7 @@ public: inline bool isExpired(uint64_t period) const { return m_period + 1 < period; } inline bool match(const Algorithm &algo, uint64_t period, uint32_t worksize, uint32_t index) const { return m_algo == algo && m_period == period && m_worksize == worksize && m_index == index; } inline bool match(const IOclRunner &runner, uint64_t period, uint32_t worksize) const { return match(runner.algorithm(), period, worksize, runner.deviceIndex()); } - inline void release() { OclLib::release(kernel); OclLib::release(program); } + inline void release() const { OclLib::release(kernel); OclLib::release(program); } cl_program program; cl_kernel kernel; @@ -173,7 +167,7 @@ public: return kernel; } - cl_int ret; + cl_int ret = 0; const std::string source = getSource(period); cl_device_id device = runner.data().device.id(); const char *s = source.c_str(); @@ -224,7 +218,7 @@ private: } kiss99_t; - std::string getSource(uint64_t prog_seed) const + static std::string getSource(uint64_t prog_seed) { std::stringstream ret; @@ -252,7 +246,7 @@ private: } for (int i = KPHash::REGS - 1; i > 0; i--) { - int j; + int j = 0; j = rnd() % (i + 1); std::swap(mix_seq_dst[i], mix_seq_dst[j]); j = rnd() % (i + 1); @@ -277,7 +271,11 @@ private: int src_rnd = rnd() % ((KPHash::REGS - 1) * KPHash::REGS); int src1 = src_rnd % KPHash::REGS; // 0 <= src1 < KPHash::REGS int src2 = src_rnd / KPHash::REGS; // 0 <= src2 < KPHash::REGS - 1 - if (src2 >= src1) ++src2; // src2 is now any reg other than src1 + + if (src2 >= src1) { + ++src2; // src2 is now any reg other than src1 + } + std::string src1_str = "mix[" + std::to_string(src1) + "]"; std::string src2_str = "mix[" + std::to_string(src2) + "]"; uint32_t r1 = rnd(); diff --git a/src/backend/opencl/runners/tools/OclKawPow.h b/src/backend/opencl/runners/tools/OclKawPow.h index 8d072680e..cf2fc949e 100644 --- a/src/backend/opencl/runners/tools/OclKawPow.h +++ b/src/backend/opencl/runners/tools/OclKawPow.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2019 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/opencl/runners/tools/OclSharedData.cpp b/src/backend/opencl/runners/tools/OclSharedData.cpp index 38e6a6769..57b360556 100644 --- a/src/backend/opencl/runners/tools/OclSharedData.cpp +++ b/src/backend/opencl/runners/tools/OclSharedData.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2019 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "backend/opencl/runners/tools/OclSharedData.h" #include "backend/opencl/wrappers/OclLib.h" #include "base/io/log/Log.h" @@ -62,7 +55,7 @@ cl_mem xmrig::OclSharedData::createBuffer(cl_context context, size_t size, size_ } -uint64_t xmrig::OclSharedData::adjustDelay(size_t id) +uint64_t xmrig::OclSharedData::adjustDelay(size_t /*id*/) { if (m_threads < 2) { return 0; @@ -103,7 +96,7 @@ uint64_t xmrig::OclSharedData::adjustDelay(size_t id) } -uint64_t xmrig::OclSharedData::resumeDelay(size_t id) +uint64_t xmrig::OclSharedData::resumeDelay(size_t /*id*/) { if (m_threads < 2) { return 0; @@ -187,7 +180,7 @@ void xmrig::OclSharedData::createDataset(cl_context ctx, const Job &job, bool ho return; } - cl_int ret; + cl_int ret = 0; if (host) { auto dataset = Rx::dataset(job, 0); diff --git a/src/backend/opencl/runners/tools/OclSharedData.h b/src/backend/opencl/runners/tools/OclSharedData.h index 393ed3b8a..7d55f2428 100644 --- a/src/backend/opencl/runners/tools/OclSharedData.h +++ b/src/backend/opencl/runners/tools/OclSharedData.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2019 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/opencl/wrappers/AdlLib.cpp b/src/backend/opencl/wrappers/AdlLib.cpp index d3b3bef4c..9df91524b 100644 --- a/src/backend/opencl/wrappers/AdlLib.cpp +++ b/src/backend/opencl/wrappers/AdlLib.cpp @@ -1,7 +1,7 @@ /* XMRig - * Copyright 2008-2018 Advanced Micro Devices, Inc. - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2008-2018 Advanced Micro Devices, Inc. + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <stdexcept> #include <uv.h> @@ -81,7 +80,7 @@ bool AdlLib::m_ready = false; static void * __stdcall ADL_Main_Memory_Alloc(int iSize) { - return malloc(iSize); + return malloc(iSize); // NOLINT(cppcoreguidelines-no-malloc, hicpp-no-malloc) } @@ -191,7 +190,9 @@ AdlHealth xmrig::AdlLib::health(const OclDevice &device) return {}; } - int supported, enabled, version; + int supported = 0; + int enabled = 0; + int version = 0; AdlHealth health; for (const auto &adapter : adapters) { diff --git a/src/backend/opencl/wrappers/AdlLib.h b/src/backend/opencl/wrappers/AdlLib.h index 70cb6d4f5..efdf1a6a6 100644 --- a/src/backend/opencl/wrappers/AdlLib.h +++ b/src/backend/opencl/wrappers/AdlLib.h @@ -1,7 +1,7 @@ /* XMRig - * Copyright 2008-2018 Advanced Micro Devices, Inc. - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2008-2018 Advanced Micro Devices, Inc. + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/opencl/wrappers/OclDevice.cpp b/src/backend/opencl/wrappers/OclDevice.cpp index 87bf21b0f..a3fcdd03b 100644 --- a/src/backend/opencl/wrappers/OclDevice.cpp +++ b/src/backend/opencl/wrappers/OclDevice.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "backend/opencl/wrappers/OclDevice.h" #include "3rdparty/rapidjson/document.h" #include "backend/opencl/OclGenerator.h" @@ -39,6 +32,7 @@ #include <algorithm> +// NOLINTNEXTLINE(modernize-use-using) typedef union { struct { cl_uint type; cl_uint data[5]; } raw; diff --git a/src/backend/opencl/wrappers/OclDevice.h b/src/backend/opencl/wrappers/OclDevice.h index ebe96d5ae..b698ad3a5 100644 --- a/src/backend/opencl/wrappers/OclDevice.h +++ b/src/backend/opencl/wrappers/OclDevice.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/backend/opencl/wrappers/OclLib.cpp b/src/backend/opencl/wrappers/OclLib.cpp index 4794f36bf..c970e70c0 100644 --- a/src/backend/opencl/wrappers/OclLib.cpp +++ b/src/backend/opencl/wrappers/OclLib.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <thread> #include <stdexcept> #include <uv.h> @@ -273,7 +266,7 @@ xmrig::String xmrig::OclLib::defaultLoader() cl_command_queue xmrig::OclLib::createCommandQueue(cl_context context, cl_device_id device, cl_int *errcode_ret) noexcept { - cl_command_queue result; + cl_command_queue result = nullptr; # if defined(CL_VERSION_2_0) if (pCreateCommandQueueWithProperties) { @@ -300,7 +293,7 @@ cl_command_queue xmrig::OclLib::createCommandQueue(cl_context context, cl_device cl_command_queue xmrig::OclLib::createCommandQueue(cl_context context, cl_device_id device) { - cl_int ret; + cl_int ret = 0; cl_command_queue queue = createCommandQueue(context, device, &ret); if (ret != CL_SUCCESS) { throw std::runtime_error(OclError::toString(ret)); @@ -327,7 +320,7 @@ cl_context xmrig::OclLib::createContext(const cl_context_properties *properties, cl_context xmrig::OclLib::createContext(const std::vector<cl_device_id> &ids) { - cl_int ret; + cl_int ret = 0; return createContext(nullptr, static_cast<cl_uint>(ids.size()), ids.data(), nullptr, nullptr, &ret); } @@ -615,7 +608,7 @@ cl_kernel xmrig::OclLib::createKernel(cl_program program, const char *kernel_nam cl_kernel xmrig::OclLib::createKernel(cl_program program, const char *kernel_name) { - cl_int ret; + cl_int ret = 0; cl_kernel kernel = createKernel(program, kernel_name, &ret); if (ret != CL_SUCCESS) { throw std::runtime_error(OclError::toString(ret)); @@ -627,7 +620,7 @@ cl_kernel xmrig::OclLib::createKernel(cl_program program, const char *kernel_nam cl_mem xmrig::OclLib::createBuffer(cl_context context, cl_mem_flags flags, size_t size, void *host_ptr) { - cl_int ret; + cl_int ret = 0; cl_mem mem = createBuffer(context, flags, size, host_ptr, &ret); if (ret != CL_SUCCESS) { throw std::runtime_error(OclError::toString(ret)); @@ -671,7 +664,7 @@ cl_mem xmrig::OclLib::createSubBuffer(cl_mem buffer, cl_mem_flags flags, size_t cl_mem xmrig::OclLib::createSubBuffer(cl_mem buffer, cl_mem_flags flags, size_t offset, size_t size) { - cl_int ret; + cl_int ret = 0; cl_mem mem = createSubBuffer(buffer, flags, offset, size, &ret); if (ret != CL_SUCCESS) { throw std::runtime_error(OclError::toString(ret)); @@ -737,8 +730,8 @@ cl_program xmrig::OclLib::retain(cl_program program) noexcept cl_uint xmrig::OclLib::getNumPlatforms() noexcept { - cl_uint count = 0; - cl_int ret; + cl_uint count = 0; + cl_int ret = 0; if ((ret = OclLib::getPlatformIDs(0, nullptr, &count)) != CL_SUCCESS) { LOG_ERR("Error %s when calling clGetPlatformIDs for number of platforms.", OclError::toString(ret)); diff --git a/src/backend/opencl/wrappers/OclLib.h b/src/backend/opencl/wrappers/OclLib.h index b4db1d8d8..c2f4194e1 100644 --- a/src/backend/opencl/wrappers/OclLib.h +++ b/src/backend/opencl/wrappers/OclLib.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/base/api/Api.cpp b/src/base/api/Api.cpp index 53e0ebb11..54666efda 100644 --- a/src/base/api/Api.cpp +++ b/src/base/api/Api.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <uv.h> @@ -198,7 +197,7 @@ void xmrig::Api::genId(const String &id) return; } - uv_interface_address_t *interfaces; + uv_interface_address_t *interfaces = nullptr; int count = 0; if (uv_interface_addresses(&interfaces, &count) < 0) { diff --git a/src/base/api/Httpd.cpp b/src/base/api/Httpd.cpp index 817da9207..d2d3db4a7 100644 --- a/src/base/api/Httpd.cpp +++ b/src/base/api/Httpd.cpp @@ -95,6 +95,7 @@ bool xmrig::Httpd::start() m_port = static_cast<uint16_t>(rc); # ifdef _WIN32 + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast, performance-no-int-to-ptr) HRSRC src = FindResource(nullptr, MAKEINTRESOURCE(1), RT_ICON); if (src != nullptr) { HGLOBAL res = LoadResource(nullptr, src); diff --git a/src/base/api/requests/HttpApiRequest.cpp b/src/base/api/requests/HttpApiRequest.cpp index 60d42b649..de43f752e 100644 --- a/src/base/api/requests/HttpApiRequest.cpp +++ b/src/base/api/requests/HttpApiRequest.cpp @@ -45,6 +45,9 @@ static inline const char *rpcError(int code) { case IApiRequest::RPC_INVALID_PARAMS: return "Invalid params"; + + default: + break; } if (code >= 400 && code < 600) { diff --git a/src/base/io/Console.cpp b/src/base/io/Console.cpp index 5af7e4a43..30ff34a34 100644 --- a/src/base/io/Console.cpp +++ b/src/base/io/Console.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/io/Console.h" #include "base/kernel/interfaces/IConsoleListener.h" #include "base/tools/Handle.h" @@ -50,7 +49,7 @@ xmrig::Console::~Console() } -bool xmrig::Console::isSupported() const +bool xmrig::Console::isSupported() { const uv_handle_type type = uv_guess_handle(0); return type == UV_TTY || type == UV_NAMED_PIPE; diff --git a/src/base/io/Console.h b/src/base/io/Console.h index 65523b94c..129bf8173 100644 --- a/src/base/io/Console.h +++ b/src/base/io/Console.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,7 +50,7 @@ public: ~Console(); private: - bool isSupported() const; + static bool isSupported(); static void onAllocBuffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf); static void onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf); diff --git a/src/base/io/Env.cpp b/src/base/io/Env.cpp index 6abb88070..2a0d4ad7c 100644 --- a/src/base/io/Env.cpp +++ b/src/base/io/Env.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/io/Env.h" #include "base/kernel/Process.h" #include "version.h" @@ -61,7 +60,7 @@ static void createVariables() variables.insert({ "XMRIG_DATA_DIR", Process::location(Process::DataLocation) }); String hostname = "HOSTNAME"; - if (!getenv(hostname)) { + if (!getenv(hostname)) { // NOLINT(concurrency-mt-unsafe) variables.insert({ std::move(hostname), Env::hostname() }); } } @@ -137,7 +136,7 @@ xmrig::String xmrig::Env::get(const String &name, const std::map<String, String> } # endif - return static_cast<const char *>(getenv(name)); + return static_cast<const char *>(getenv(name)); // NOLINT(concurrency-mt-unsafe) } diff --git a/src/base/io/json/Json.cpp b/src/base/io/json/Json.cpp index 99a087e9c..720f75152 100644 --- a/src/base/io/json/Json.cpp +++ b/src/base/io/json/Json.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/io/json/Json.h" #include "3rdparty/rapidjson/document.h" @@ -30,7 +29,7 @@ namespace xmrig { static const rapidjson::Value kNullValue; -} +} // namespace xmrig bool xmrig::Json::getBool(const rapidjson::Value &obj, const char *key, bool defaultValue) diff --git a/src/base/io/json/Json.h b/src/base/io/json/Json.h index e5d0fcc6d..36ee4c802 100644 --- a/src/base/io/json/Json.h +++ b/src/base/io/json/Json.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/base/io/json/JsonChain.cpp b/src/base/io/json/JsonChain.cpp index 0a4a1857d..9f9204648 100644 --- a/src/base/io/json/JsonChain.cpp +++ b/src/base/io/json/JsonChain.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/io/json/JsonChain.h" #include "3rdparty/rapidjson/error/en.h" #include "base/io/json/Json.h" @@ -27,7 +26,7 @@ namespace xmrig { static const rapidjson::Value kNullValue; -} +} // namespace xmrig xmrig::JsonChain::JsonChain() = default; @@ -58,8 +57,8 @@ bool xmrig::JsonChain::addFile(const char *fileName) if (doc.HasParseError()) { const size_t offset = doc.GetErrorOffset(); - size_t line; - size_t pos; + size_t line = 0; + size_t pos = 0; std::vector<std::string> s; if (Json::convertOffset(fileName, offset, line, pos, s)) { diff --git a/src/base/io/log/Log.cpp b/src/base/io/log/Log.cpp index e144858a0..891b93b67 100644 --- a/src/base/io/log/Log.cpp +++ b/src/base/io/log/Log.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2019 Spudz76 <https://github.com/Spudz76> - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #ifdef WIN32 # include <winsock2.h> # include <windows.h> @@ -103,7 +102,7 @@ public: endl(size); std::string txt(m_buf); - size_t i; + size_t i = 0; while ((i = txt.find(CSI)) != std::string::npos) { txt.erase(i, txt.find('m', i) - i + 1); } @@ -232,7 +231,7 @@ void xmrig::Log::print(const char *fmt, ...) return; } - va_list args; + va_list args = nullptr; va_start(args, fmt); d->print(NONE, fmt, args); @@ -247,7 +246,7 @@ void xmrig::Log::print(Level level, const char *fmt, ...) return; } - va_list args; + va_list args = nullptr; va_start(args, fmt); d->print(level, fmt, args); diff --git a/src/base/io/log/Log.h b/src/base/io/log/Log.h index 6da2e8927..d4c0a3197 100644 --- a/src/base/io/log/Log.h +++ b/src/base/io/log/Log.h @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2019 Spudz76 <https://github.com/Spudz76> - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/base/io/log/backends/ConsoleLog.cpp b/src/base/io/log/backends/ConsoleLog.cpp index cc3081fdd..a18fe7d9f 100644 --- a/src/base/io/log/backends/ConsoleLog.cpp +++ b/src/base/io/log/backends/ConsoleLog.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2019 Spudz76 <https://github.com/Spudz76> - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/io/log/backends/ConsoleLog.h" #include "base/io/log/Log.h" #include "base/kernel/config/Title.h" @@ -47,7 +46,7 @@ xmrig::ConsoleLog::ConsoleLog(const Title &title) m_stream = reinterpret_cast<uv_stream_t*>(m_tty); HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); - if (handle != INVALID_HANDLE_VALUE) { + if (handle != INVALID_HANDLE_VALUE) { // NOLINT(cppcoreguidelines-pro-type-cstyle-cast, performance-no-int-to-ptr) DWORD mode = 0; if (GetConsoleMode(handle, &mode)) { mode &= ~ENABLE_QUICK_EDIT_MODE; @@ -91,7 +90,7 @@ void xmrig::ConsoleLog::print(uint64_t, int, const char *line, size_t, size_t si } -bool xmrig::ConsoleLog::isSupported() const +bool xmrig::ConsoleLog::isSupported() { const uv_handle_type type = uv_guess_handle(1); return type == UV_TTY || type == UV_NAMED_PIPE; diff --git a/src/base/io/log/backends/ConsoleLog.h b/src/base/io/log/backends/ConsoleLog.h index 019177630..2d248a921 100644 --- a/src/base/io/log/backends/ConsoleLog.h +++ b/src/base/io/log/backends/ConsoleLog.h @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2019 Spudz76 <https://github.com/Spudz76> - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,7 +47,7 @@ protected: void print(uint64_t timestamp, int level, const char *line, size_t offset, size_t size, bool colors) override; private: - bool isSupported() const; + static bool isSupported(); uv_tty_t *m_tty = nullptr; diff --git a/src/base/kernel/Base.cpp b/src/base/kernel/Base.cpp index 698dc10cf..0e0121862 100644 --- a/src/base/kernel/Base.cpp +++ b/src/base/kernel/Base.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <cassert> #include <memory> @@ -76,7 +69,7 @@ public: XMRIG_DISABLE_COPY_MOVE_DEFAULT(BasePrivate) - inline BasePrivate(Process *process) + inline explicit BasePrivate(Process *process) { Log::init(); @@ -97,7 +90,7 @@ public: } - inline bool read(const JsonChain &chain, std::unique_ptr<Config> &config) + inline static bool read(const JsonChain &chain, std::unique_ptr<Config> &config) { config = std::unique_ptr<Config>(new Config()); @@ -125,7 +118,7 @@ public: private: - inline Config *load(Process *process) + inline static Config *load(Process *process) { JsonChain chain; ConfigTransform transform; diff --git a/src/base/kernel/Base.h b/src/base/kernel/Base.h index f113c0f70..53eaaea3b 100644 --- a/src/base/kernel/Base.h +++ b/src/base/kernel/Base.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/base/kernel/Entry.cpp b/src/base/kernel/Entry.cpp index a50cb6342..c257ad243 100644 --- a/src/base/kernel/Entry.cpp +++ b/src/base/kernel/Entry.cpp @@ -109,7 +109,7 @@ static int exportTopology(const Process &) { const String path = Process::location(Process::ExeLocation, "topology.xml"); - hwloc_topology_t topology; + hwloc_topology_t topology = nullptr; hwloc_topology_init(&topology); hwloc_topology_load(topology); diff --git a/src/base/kernel/Platform_win.cpp b/src/base/kernel/Platform_win.cpp index 75f810419..76d81ae56 100644 --- a/src/base/kernel/Platform_win.cpp +++ b/src/base/kernel/Platform_win.cpp @@ -30,7 +30,7 @@ static inline OSVERSIONINFOEX winOsVersion() { - typedef NTSTATUS (NTAPI *RtlGetVersionFunction)(LPOSVERSIONINFO); + typedef NTSTATUS (NTAPI *RtlGetVersionFunction)(LPOSVERSIONINFO); // NOLINT(modernize-use-using) OSVERSIONINFOEX result = { sizeof(OSVERSIONINFOEX), 0, 0, 0, 0, {'\0'}, 0, 0, 0, 0, 0}; HMODULE ntdll = GetModuleHandleW(L"ntdll.dll"); @@ -61,9 +61,9 @@ char *xmrig::Platform::createUserAgent() # endif # ifdef __GNUC__ - length += snprintf(buf + length, max - length, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); + snprintf(buf + length, max - length, " gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); # elif _MSC_VER - length += snprintf(buf + length, max - length, " msvc/%d", MSVC_VERSION); + snprintf(buf + length, max - length, " msvc/%d", MSVC_VERSION); # endif return buf; diff --git a/src/base/kernel/Process.cpp b/src/base/kernel/Process.cpp index 6f63b6476..173fc2aa3 100644 --- a/src/base/kernel/Process.cpp +++ b/src/base/kernel/Process.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <ctime> #include <string> #include <uv.h> @@ -80,7 +79,7 @@ static std::string getPath(Process::Location location) return {}; } - const auto path = std::string(pathBuf, size); + auto path = std::string(pathBuf, size); const auto pos = path.rfind(*XMRIG_DIR_SEPARATOR); if (pos != std::string::npos) { diff --git a/src/base/kernel/Process.h b/src/base/kernel/Process.h index 754e7a567..9af498f59 100644 --- a/src/base/kernel/Process.h +++ b/src/base/kernel/Process.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/base/kernel/config/BaseConfig.h b/src/base/kernel/config/BaseConfig.h index 37d4641f0..fae6d981c 100644 --- a/src/base/kernel/config/BaseConfig.h +++ b/src/base/kernel/config/BaseConfig.h @@ -86,7 +86,7 @@ public: bool read(const IJsonReader &reader, const char *fileName) override; bool save() override; - void printVersions(); + static void printVersions(); protected: bool m_autoSave = true; @@ -110,7 +110,7 @@ protected: # endif private: - void setVerbose(const rapidjson::Value &value); + static void setVerbose(const rapidjson::Value &value); }; diff --git a/src/base/kernel/config/BaseTransform.cpp b/src/base/kernel/config/BaseTransform.cpp index 6d4f38d01..c924dd59a 100644 --- a/src/base/kernel/config/BaseTransform.cpp +++ b/src/base/kernel/config/BaseTransform.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <cstdio> @@ -48,14 +47,14 @@ void xmrig::BaseTransform::load(JsonChain &chain, Process *process, IConfigTrans { using namespace rapidjson; - int key; + int key = 0; int argc = process->arguments().argc(); char **argv = process->arguments().argv(); Document doc(kObjectType); while (true) { - key = getopt_long(argc, argv, short_options, options, nullptr); + key = getopt_long(argc, argv, short_options, options, nullptr); // NOLINT(concurrency-mt-unsafe) if (key < 0) { break; } diff --git a/src/base/net/dns/DnsConfig.cpp b/src/base/net/dns/DnsConfig.cpp index c2446c2a6..f9ec7e28b 100644 --- a/src/base/net/dns/DnsConfig.cpp +++ b/src/base/net/dns/DnsConfig.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/net/dns/DnsConfig.h" #include "3rdparty/rapidjson/document.h" #include "base/io/json/Json.h" diff --git a/src/base/net/dns/DnsConfig.h b/src/base/net/dns/DnsConfig.h index d42c8ad8b..605e837be 100644 --- a/src/base/net/dns/DnsConfig.h +++ b/src/base/net/dns/DnsConfig.h @@ -34,7 +34,7 @@ public: static const char *kTTL; DnsConfig() = default; - DnsConfig(const rapidjson::Value &object); + DnsConfig(const rapidjson::Value &value); inline bool isIPv6() const { return m_ipv6; } inline uint32_t ttl() const { return m_ttl * 1000U; } diff --git a/src/base/net/dns/DnsRecords.cpp b/src/base/net/dns/DnsRecords.cpp index fb232f276..072f96729 100644 --- a/src/base/net/dns/DnsRecords.cpp +++ b/src/base/net/dns/DnsRecords.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <uv.h> @@ -36,11 +35,11 @@ const xmrig::DnsRecord &xmrig::DnsRecords::get(DnsRecord::Type prefered) const const size_t ipv6 = m_ipv6.size(); if (ipv6 && (prefered == DnsRecord::AAAA || Dns::config().isIPv6() || !ipv4)) { - return m_ipv6[ipv6 == 1 ? 0 : static_cast<size_t>(rand()) % ipv6]; + return m_ipv6[ipv6 == 1 ? 0 : static_cast<size_t>(rand()) % ipv6]; // NOLINT(concurrency-mt-unsafe, cert-msc30-c, cert-msc50-cpp) } if (ipv4) { - return m_ipv4[ipv4 == 1 ? 0 : static_cast<size_t>(rand()) % ipv4]; + return m_ipv4[ipv4 == 1 ? 0 : static_cast<size_t>(rand()) % ipv4]; // NOLINT(concurrency-mt-unsafe, cert-msc30-c, cert-msc50-cpp) } return defaultRecord; diff --git a/src/base/net/http/Fetch.cpp b/src/base/net/http/Fetch.cpp index f0be4dfd4..d387a8cc5 100644 --- a/src/base/net/http/Fetch.cpp +++ b/src/base/net/http/Fetch.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/net/http/Fetch.h" #include "3rdparty/rapidjson/document.h" #include "3rdparty/rapidjson/stringbuffer.h" @@ -106,7 +105,7 @@ void xmrig::fetch(const char *tag, FetchRequest &&req, const std::weak_ptr<IHttp } # endif - HttpClient *client; + HttpClient *client = nullptr; # ifdef XMRIG_FEATURE_TLS if (req.tls) { client = new HttpsClient(tag, std::move(req), listener); diff --git a/src/base/net/http/Http.cpp b/src/base/net/http/Http.cpp index 0aef85dc8..b6b1e8580 100644 --- a/src/base/net/http/Http.cpp +++ b/src/base/net/http/Http.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/net/http/Http.h" #include "3rdparty/rapidjson/document.h" #include "base/io/json/Json.h" @@ -39,7 +32,7 @@ const char *Http::kRestricted = "restricted"; const char *Http::kToken = "access-token"; -} +} // namespace xmrig xmrig::Http::Http() : diff --git a/src/base/net/http/Http.h b/src/base/net/http/Http.h index 7ee179cd0..f7a59bec1 100644 --- a/src/base/net/http/Http.h +++ b/src/base/net/http/Http.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #ifndef XMRIG_HTTP_H #define XMRIG_HTTP_H diff --git a/src/base/net/https/HttpsClient.cpp b/src/base/net/https/HttpsClient.cpp index 8b4149170..e901b1e0c 100644 --- a/src/base/net/https/HttpsClient.cpp +++ b/src/base/net/https/HttpsClient.cpp @@ -170,7 +170,7 @@ bool xmrig::HttpsClient::verifyFingerprint(X509 *cert) } unsigned char md[EVP_MAX_MD_SIZE]; - unsigned int dlen; + unsigned int dlen = 0; if (X509_digest(cert, digest, md, &dlen) != 1) { return false; @@ -189,7 +189,7 @@ void xmrig::HttpsClient::flush(bool close) } char *data = nullptr; - const size_t size = BIO_get_mem_data(m_write, &data); + const size_t size = BIO_get_mem_data(m_write, &data); // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) std::string body(data, size); (void) BIO_reset(m_write); diff --git a/src/base/net/https/HttpsContext.cpp b/src/base/net/https/HttpsContext.cpp index 3b0ff79af..c45bf0f30 100644 --- a/src/base/net/https/HttpsContext.cpp +++ b/src/base/net/https/HttpsContext.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/net/https/HttpsContext.h" #include "3rdparty/llhttp/llhttp.h" #include "base/net/tls/TlsContext.h" @@ -61,7 +60,7 @@ bool xmrig::HttpsContext::write(BIO *bio) } char *data = nullptr; - const size_t size = BIO_get_mem_data(bio, &data); + const size_t size = BIO_get_mem_data(bio, &data); // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) std::string body(data, size); (void) BIO_reset(bio); diff --git a/src/base/net/https/HttpsServer.cpp b/src/base/net/https/HttpsServer.cpp index 3a6fb0801..782c47443 100644 --- a/src/base/net/https/HttpsServer.cpp +++ b/src/base/net/https/HttpsServer.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <uv.h> @@ -53,7 +52,7 @@ void xmrig::HttpsServer::onConnection(uv_stream_t *stream, uint16_t) auto ctx = new HttpsContext(m_tls, m_listener); uv_accept(stream, ctx->stream()); - uv_read_start(ctx->stream(), NetBuffer::onAlloc, onRead); + uv_read_start(ctx->stream(), NetBuffer::onAlloc, onRead); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) } diff --git a/src/base/net/https/HttpsServer.h b/src/base/net/https/HttpsServer.h index 2b5ecd002..ad21162f3 100644 --- a/src/base/net/https/HttpsServer.h +++ b/src/base/net/https/HttpsServer.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #ifndef XMRIG_HTTPSSERVER_H #define XMRIG_HTTPSSERVER_H diff --git a/src/base/net/stratum/AutoClient.cpp b/src/base/net/stratum/AutoClient.cpp index 4a82b2bf8..e3896b584 100644 --- a/src/base/net/stratum/AutoClient.cpp +++ b/src/base/net/stratum/AutoClient.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/net/stratum/AutoClient.h" #include "3rdparty/rapidjson/document.h" #include "base/io/json/Json.h" @@ -31,7 +30,7 @@ xmrig::AutoClient::AutoClient(int id, const char *agent, IClientListener *listen bool xmrig::AutoClient::handleResponse(int64_t id, const rapidjson::Value &result, const rapidjson::Value &error) { if (m_mode == DEFAULT_MODE) { - return Client::handleResponse(id, result, error); + return Client::handleResponse(id, result, error); // NOLINT(bugprone-parent-virtual-call) } return EthStratumClient::handleResponse(id, result, error); @@ -73,7 +72,7 @@ bool xmrig::AutoClient::parseLogin(const rapidjson::Value &result, int *code) int64_t xmrig::AutoClient::submit(const JobResult &result) { if (m_mode == DEFAULT_MODE) { - return Client::submit(result); + return Client::submit(result); // NOLINT(bugprone-parent-virtual-call) } return EthStratumClient::submit(result); @@ -83,7 +82,7 @@ int64_t xmrig::AutoClient::submit(const JobResult &result) void xmrig::AutoClient::parseNotification(const char *method, const rapidjson::Value ¶ms, const rapidjson::Value &error) { if (m_mode == DEFAULT_MODE) { - return Client::parseNotification(method, params, error); + return Client::parseNotification(method, params, error); // NOLINT(bugprone-parent-virtual-call) } return EthStratumClient::parseNotification(method, params, error); diff --git a/src/base/net/stratum/AutoClient.h b/src/base/net/stratum/AutoClient.h index a97700fbc..c74d51911 100644 --- a/src/base/net/stratum/AutoClient.h +++ b/src/base/net/stratum/AutoClient.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/base/net/stratum/Client.cpp b/src/base/net/stratum/Client.cpp index 46c9ac2ff..db6ceca38 100644 --- a/src/base/net/stratum/Client.cpp +++ b/src/base/net/stratum/Client.cpp @@ -349,32 +349,6 @@ bool xmrig::Client::close() } -bool xmrig::Client::isCriticalError(const char *message) -{ - if (!message) { - return false; - } - - if (strncasecmp(message, "Unauthenticated", 15) == 0) { - return true; - } - - if (strncasecmp(message, "your IP is banned", 17) == 0) { - return true; - } - - if (strncasecmp(message, "IP Address currently banned", 27) == 0) { - return true; - } - - if (strncasecmp(message, "Invalid job id", 14) == 0) { - return true; - } - - return false; -} - - bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code) { if (!params.IsObject()) { @@ -465,7 +439,7 @@ bool xmrig::Client::send(BIO *bio) { # ifdef XMRIG_FEATURE_TLS uv_buf_t buf; - buf.len = BIO_get_mem_data(bio, &buf.base); + buf.len = BIO_get_mem_data(bio, &buf.base); // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) if (buf.len == 0) { return true; @@ -959,6 +933,32 @@ void xmrig::Client::startTimeout() } +bool xmrig::Client::isCriticalError(const char *message) +{ + if (!message) { + return false; + } + + if (strncasecmp(message, "Unauthenticated", 15) == 0) { + return true; + } + + if (strncasecmp(message, "your IP is banned", 17) == 0) { + return true; + } + + if (strncasecmp(message, "IP Address currently banned", 27) == 0) { + return true; + } + + if (strncasecmp(message, "Invalid job id", 14) == 0) { + return true; + } + + return false; +} + + void xmrig::Client::onClose(uv_handle_t *handle) { auto client = getClient(handle->data); diff --git a/src/base/net/stratum/Client.h b/src/base/net/stratum/Client.h index a74be296d..e1f5d7562 100644 --- a/src/base/net/stratum/Client.h +++ b/src/base/net/stratum/Client.h @@ -96,7 +96,6 @@ private: class Socks5; class Tls; - bool isCriticalError(const char *message); bool parseJob(const rapidjson::Value ¶ms, int *code); bool send(BIO *bio); bool verifyAlgorithm(const Algorithm &algorithm, const char *algo) const; @@ -119,6 +118,7 @@ private: inline void setExtension(Extension ext, bool enable) noexcept { m_extensions.set(ext, enable); } template<Extension ext> inline bool has() const noexcept { return m_extensions.test(ext); } + static bool isCriticalError(const char *message); static void onClose(uv_handle_t *handle); static void onConnect(uv_connect_t *req, int status); static void onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf); diff --git a/src/base/net/stratum/DaemonClient.cpp b/src/base/net/stratum/DaemonClient.cpp index 50a3a2324..57a8d6f0f 100644 --- a/src/base/net/stratum/DaemonClient.cpp +++ b/src/base/net/stratum/DaemonClient.cpp @@ -73,7 +73,7 @@ static constexpr size_t kZMQGreetingSize1 = 11; static const char kZMQHandshake[] = "\4\x19\5READY\xbSocket-Type\0\0\0\3SUB"; static const char kZMQSubscribe[] = "\0\x18\1json-minimal-chain_main"; -} +} // namespace xmrig xmrig::DaemonClient::DaemonClient(int id, IClientListener *listener) : @@ -823,9 +823,9 @@ void xmrig::DaemonClient::ZMQParse() size_t msg_size = 0; - char* data = m_ZMQRecvBuf.data(); + char *data = m_ZMQRecvBuf.data(); size_t avail = m_ZMQRecvBuf.size(); - bool more; + bool more = false; do { if (avail < 1) { diff --git a/src/base/net/stratum/EthStratumClient.cpp b/src/base/net/stratum/EthStratumClient.cpp index 40c57f299..94d856351 100644 --- a/src/base/net/stratum/EthStratumClient.cpp +++ b/src/base/net/stratum/EthStratumClient.cpp @@ -272,7 +272,7 @@ void xmrig::EthStratumClient::setExtraNonce(const rapidjson::Value &nonce) } -const char *xmrig::EthStratumClient::errorMessage(const rapidjson::Value &error) const +const char *xmrig::EthStratumClient::errorMessage(const rapidjson::Value &error) { if (error.IsArray() && error.GetArray().Size() > 1) { auto &value = error.GetArray()[1]; diff --git a/src/base/net/stratum/EthStratumClient.h b/src/base/net/stratum/EthStratumClient.h index d6b34fb84..7f3c59e03 100644 --- a/src/base/net/stratum/EthStratumClient.h +++ b/src/base/net/stratum/EthStratumClient.h @@ -48,7 +48,8 @@ protected: void setExtraNonce(const rapidjson::Value &nonce); private: - const char *errorMessage(const rapidjson::Value &error) const; + static const char *errorMessage(const rapidjson::Value &error); + void authorize(); void onAuthorizeResponse(const rapidjson::Value &result, bool success, uint64_t elapsed); void onSubscribeResponse(const rapidjson::Value &result, bool success, uint64_t elapsed); diff --git a/src/base/net/stratum/Pool.cpp b/src/base/net/stratum/Pool.cpp index 367e66677..9a27d7c0a 100644 --- a/src/base/net/stratum/Pool.cpp +++ b/src/base/net/stratum/Pool.cpp @@ -82,7 +82,7 @@ const char *Pool::kSpendSecretKey = "spend-secret-key"; const char *Pool::kNicehashHost = "nicehash.com"; -} +} // namespace xmrig xmrig::Pool::Pool(const char *url) : diff --git a/src/base/net/stratum/Pools.cpp b/src/base/net/stratum/Pools.cpp index d2ab30126..d70075ac0 100644 --- a/src/base/net/stratum/Pools.cpp +++ b/src/base/net/stratum/Pools.cpp @@ -230,6 +230,9 @@ void xmrig::Pools::setProxyDonate(int value) case PROXY_DONATE_AUTO: case PROXY_DONATE_ALWAYS: m_proxyDonate = static_cast<ProxyDonate>(value); + + default: + break; } } diff --git a/src/base/net/stratum/Socks5.cpp b/src/base/net/stratum/Socks5.cpp index 9577906fe..d61aa3292 100644 --- a/src/base/net/stratum/Socks5.cpp +++ b/src/base/net/stratum/Socks5.cpp @@ -59,13 +59,13 @@ void xmrig::Client::Socks5::handshake() } -bool xmrig::Client::Socks5::isIPv4(const String &host, sockaddr_storage *addr) const +bool xmrig::Client::Socks5::isIPv4(const String &host, sockaddr_storage *addr) { return uv_ip4_addr(host.data(), 0, reinterpret_cast<sockaddr_in *>(addr)) == 0; } -bool xmrig::Client::Socks5::isIPv6(const String &host, sockaddr_storage *addr) const +bool xmrig::Client::Socks5::isIPv6(const String &host, sockaddr_storage *addr) { return uv_ip6_addr(host.data(), 0, reinterpret_cast<sockaddr_in6 *>(addr)) == 0; } diff --git a/src/base/net/stratum/Socks5.h b/src/base/net/stratum/Socks5.h index 74ff66437..286ae1832 100644 --- a/src/base/net/stratum/Socks5.h +++ b/src/base/net/stratum/Socks5.h @@ -44,8 +44,9 @@ private: Ready }; - bool isIPv4(const String &host, sockaddr_storage *addr) const; - bool isIPv6(const String &host, sockaddr_storage *addr) const; + static bool isIPv4(const String &host, sockaddr_storage *addr); + static bool isIPv6(const String &host, sockaddr_storage *addr); + void connect(); Client *m_client; diff --git a/src/base/net/stratum/Tls.cpp b/src/base/net/stratum/Tls.cpp index a4ccd8537..46ba45116 100644 --- a/src/base/net/stratum/Tls.cpp +++ b/src/base/net/stratum/Tls.cpp @@ -1,13 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018 Lee Clagett <https://github.com/vtnerd> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/net/stratum/Tls.h" #include "base/io/log/Log.h" #include "base/net/stratum/Client.h" @@ -177,7 +170,7 @@ bool xmrig::Client::Tls::verifyFingerprint(X509 *cert) } unsigned char md[EVP_MAX_MD_SIZE]; - unsigned int dlen; + unsigned int dlen = 0; if (X509_digest(cert, digest, md, &dlen) != 1) { return false; diff --git a/src/base/net/stratum/Tls.h b/src/base/net/stratum/Tls.h index 38cf2f9e6..cfdda9340 100644 --- a/src/base/net/stratum/Tls.h +++ b/src/base/net/stratum/Tls.h @@ -1,12 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/base/net/stratum/Url.cpp b/src/base/net/stratum/Url.cpp index 5e2bdb9ac..7904a445d 100644 --- a/src/base/net/stratum/Url.cpp +++ b/src/base/net/stratum/Url.cpp @@ -1,13 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2019 Howard Chu <https://github.com/hyc> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/net/stratum/Url.h" @@ -49,7 +41,7 @@ static const char kDaemonHttp[] = "daemon+http://"; static const char kDaemonHttps[] = "daemon+https://"; #endif -} +} // namespace xmrig xmrig::Url::Url(const char *url) diff --git a/src/base/net/stratum/Url.h b/src/base/net/stratum/Url.h index 647612c11..6882631e2 100644 --- a/src/base/net/stratum/Url.h +++ b/src/base/net/stratum/Url.h @@ -1,13 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2019 Howard Chu <https://github.com/hyc> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/base/net/stratum/benchmark/BenchClient.cpp b/src/base/net/stratum/benchmark/BenchClient.cpp index 05a2c8551..a2f6d44b0 100644 --- a/src/base/net/stratum/benchmark/BenchClient.cpp +++ b/src/base/net/stratum/benchmark/BenchClient.cpp @@ -249,7 +249,7 @@ uint64_t xmrig::BenchClient::referenceHash() const } -void xmrig::BenchClient::printExit() +void xmrig::BenchClient::printExit() const { LOG_INFO("%s " WHITE_BOLD("press ") MAGENTA_BOLD("Ctrl+C") WHITE_BOLD(" to exit"), tag()); } diff --git a/src/base/net/stratum/benchmark/BenchClient.h b/src/base/net/stratum/benchmark/BenchClient.h index a4cedf612..c29e42e00 100644 --- a/src/base/net/stratum/benchmark/BenchClient.h +++ b/src/base/net/stratum/benchmark/BenchClient.h @@ -90,7 +90,7 @@ private: bool setSeed(const char *seed); uint64_t referenceHash() const; - void printExit(); + void printExit() const; void start(); # ifdef XMRIG_FEATURE_HTTP diff --git a/src/base/net/tls/TlsConfig.cpp b/src/base/net/tls/TlsConfig.cpp index 2e3dc903b..32fe9670c 100644 --- a/src/base/net/tls/TlsConfig.cpp +++ b/src/base/net/tls/TlsConfig.cpp @@ -1,13 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018 Lee Clagett <https://github.com/vtnerd> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/net/tls/TlsConfig.h" #include "3rdparty/rapidjson/document.h" #include "base/io/json/Json.h" diff --git a/src/base/net/tls/TlsConfig.h b/src/base/net/tls/TlsConfig.h index c5407f321..945eb0e8f 100644 --- a/src/base/net/tls/TlsConfig.h +++ b/src/base/net/tls/TlsConfig.h @@ -1,13 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018 Lee Clagett <https://github.com/vtnerd> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,7 +48,7 @@ public: }; TlsConfig() = default; - TlsConfig(const rapidjson::Value &object); + TlsConfig(const rapidjson::Value &value); inline bool isEnabled() const { return m_enabled && isValid(); } inline bool isValid() const { return !m_cert.isEmpty() && !m_key.isEmpty(); } diff --git a/src/base/net/tls/TlsContext.cpp b/src/base/net/tls/TlsContext.cpp index 03c79e654..e36217975 100644 --- a/src/base/net/tls/TlsContext.cpp +++ b/src/base/net/tls/TlsContext.cpp @@ -1,13 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018 Lee Clagett <https://github.com/vtnerd> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/net/tls/TlsContext.h" #include "base/io/Env.h" #include "base/io/log/Log.h" @@ -223,7 +216,7 @@ bool xmrig::TlsContext::setDH(const char *dhparam) dh = get_dh2048(); } - const int rc = SSL_CTX_set_tmp_dh(m_ctx, dh); + const int rc = SSL_CTX_set_tmp_dh(m_ctx, dh); // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) DH_free(dh); diff --git a/src/base/net/tls/TlsContext.h b/src/base/net/tls/TlsContext.h index b87798c5b..9a9b3cb1c 100644 --- a/src/base/net/tls/TlsContext.h +++ b/src/base/net/tls/TlsContext.h @@ -1,13 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018 Lee Clagett <https://github.com/vtnerd> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/base/net/tls/TlsGen.cpp b/src/base/net/tls/TlsGen.cpp index c56ef2a21..428920537 100644 --- a/src/base/net/tls/TlsGen.cpp +++ b/src/base/net/tls/TlsGen.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/net/tls/TlsGen.h" @@ -41,6 +40,8 @@ static EVP_PKEY *generate_pkey() auto exponent = BN_new(); auto rsa = RSA_new(); + + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) if (!exponent || !rsa || !BN_set_word(exponent, RSA_F4) || !RSA_generate_key_ex(rsa, 2048, exponent, nullptr) || !EVP_PKEY_assign_RSA(pkey, rsa)) { EVP_PKEY_free(pkey); BN_free(exponent); diff --git a/src/base/net/tls/TlsGen.h b/src/base/net/tls/TlsGen.h index 9386e88ca..c471c8ca6 100644 --- a/src/base/net/tls/TlsGen.h +++ b/src/base/net/tls/TlsGen.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/base/tools/Cvt.cpp b/src/base/tools/Cvt.cpp index 0d1c89fb0..3f083a266 100644 --- a/src/base/tools/Cvt.cpp +++ b/src/base/tools/Cvt.cpp @@ -36,9 +36,9 @@ namespace xmrig { static char *cvt_bin2hex(char *const hex, const size_t hex_maxlen, const unsigned char *const bin, const size_t bin_len) { size_t i = 0U; - unsigned int x; - int b; - int c; + unsigned int x = 0U; + int b = 0; + int c = 0; if (bin_len >= SIZE_MAX / 2 || hex_maxlen < bin_len * 2U) { return nullptr; /* LCOV_EXCL_LINE */ @@ -70,17 +70,17 @@ static std::mt19937 randomEngine(randomDevice()); static int cvt_hex2bin(unsigned char *const bin, const size_t bin_maxlen, const char *const hex, const size_t hex_len, const char *const ignore, size_t *const bin_len, const char **const hex_end) { - size_t bin_pos = 0U; - size_t hex_pos = 0U; - int ret = 0; - unsigned char c; - unsigned char c_acc = 0U; - unsigned char c_alpha0; - unsigned char c_alpha; - unsigned char c_num0; - unsigned char c_num; - unsigned char c_val; - unsigned char state = 0U; + size_t bin_pos = 0U; + size_t hex_pos = 0U; + int ret = 0; + unsigned char c = 0U; + unsigned char c_acc = 0U; + unsigned char c_alpha0 = 0U; + unsigned char c_alpha = 0U; + unsigned char c_num0 = 0U; + unsigned char c_num = 0U; + unsigned char c_val = 0U; + unsigned char state = 0U; while (hex_pos < hex_len) { c = (unsigned char) hex[hex_pos]; @@ -193,13 +193,13 @@ bool xmrig::Cvt::fromHex(uint8_t *bin, size_t bin_maxlen, const char *hex, size_ } -bool xmrig::Cvt::fromHex(uint8_t *bin, size_t max, const rapidjson::Value &value) +bool xmrig::Cvt::fromHex(uint8_t *bin, size_t bin_maxlen, const rapidjson::Value &value) { if (!value.IsString()) { return false; } - return fromHex(bin, max, value.GetString(), value.GetStringLength()); + return fromHex(bin, bin_maxlen, value.GetString(), value.GetStringLength()); } diff --git a/src/base/tools/cryptonote/BlockTemplate.cpp b/src/base/tools/cryptonote/BlockTemplate.cpp index db3d0496b..4f6d27333 100644 --- a/src/base/tools/cryptonote/BlockTemplate.cpp +++ b/src/base/tools/cryptonote/BlockTemplate.cpp @@ -78,7 +78,9 @@ void xmrig::BlockTemplate::calculateMerkleTreeHash() keccak(h, kHashSize * 2, m_rootHash, kHashSize); } else { - size_t i, j, cnt; + size_t i = 0; + size_t j = 0; + size_t cnt = 0; for (i = 0, cnt = 1; cnt <= count; ++i, cnt <<= 1) {} @@ -261,7 +263,7 @@ bool xmrig::BlockTemplate::parse(bool hashes) break; default: - return false; // TODO: handle other tags + return false; // TODO(SChernykh): handle other tags } } diff --git a/src/base/tools/cryptonote/WalletAddress.cpp b/src/base/tools/cryptonote/WalletAddress.cpp index 8ea2bbd64..9f5a562dc 100644 --- a/src/base/tools/cryptonote/WalletAddress.cpp +++ b/src/base/tools/cryptonote/WalletAddress.cpp @@ -183,7 +183,7 @@ rapidjson::Value xmrig::WalletAddress::toAPI(rapidjson::Document &doc) const const xmrig::WalletAddress::TagInfo &xmrig::WalletAddress::tagInfo(uint64_t tag) { - static TagInfo dummy = { Coin::INVALID, MAINNET, PUBLIC, 0 }; + static TagInfo dummy = { Coin::INVALID, MAINNET, PUBLIC, 0, 0 }; static const std::map<uint64_t, TagInfo> tags = { { 18, { Coin::MONERO, MAINNET, PUBLIC, 18081, 18082 } }, { 19, { Coin::MONERO, MAINNET, INTEGRATED, 18081, 18082 } }, diff --git a/src/core/Controller.cpp b/src/core/Controller.cpp index 9242b6ee3..626175aeb 100644 --- a/src/core/Controller.cpp +++ b/src/core/Controller.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2021 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "core/Controller.h" #include "backend/cpu/Cpu.h" #include "core/config/Config.h" @@ -100,7 +99,7 @@ xmrig::Network *xmrig::Controller::network() const } -void xmrig::Controller::execCommand(char command) +void xmrig::Controller::execCommand(char command) const { miner()->execCommand(command); network()->execCommand(command); diff --git a/src/core/Controller.h b/src/core/Controller.h index 13704f151..42ae04ff5 100644 --- a/src/core/Controller.h +++ b/src/core/Controller.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright 2018-2021 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,7 +49,7 @@ public: Miner *miner() const; Network *network() const; - void execCommand(char command); + void execCommand(char command) const; private: std::shared_ptr<Miner> m_miner; diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index 81b426eb4..2b6c1dbee 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -78,7 +78,7 @@ public: XMRIG_DISABLE_COPY_MOVE_DEFAULT(MinerPrivate) - inline MinerPrivate(Controller *controller) : controller(controller) {} + inline explicit MinerPrivate(Controller *controller) : controller(controller) {} inline ~MinerPrivate() @@ -329,7 +329,7 @@ public: # ifdef XMRIG_ALGO_RANDOMX - inline bool initRX() { return Rx::init(job, controller->config()->rx(), controller->config()->cpu()); } + inline bool initRX() const { return Rx::init(job, controller->config()->rx(), controller->config()->cpu()); } # endif diff --git a/src/core/config/Config.cpp b/src/core/config/Config.cpp index fa5760185..6150607d0 100644 --- a/src/core/config/Config.cpp +++ b/src/core/config/Config.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include <algorithm> #include <cinttypes> #include <cstring> @@ -112,7 +111,7 @@ public: } }; -} +} // namespace xmrig xmrig::Config::Config() : diff --git a/src/core/config/ConfigTransform.cpp b/src/core/config/ConfigTransform.cpp index 1c4f4244a..20a89eda6 100644 --- a/src/core/config/ConfigTransform.cpp +++ b/src/core/config/ConfigTransform.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "core/config/ConfigTransform.h" #include "base/kernel/interfaces/IConfig.h" #include "base/net/stratum/Pool.h" @@ -354,6 +353,9 @@ void xmrig::ConfigTransform::transformBenchmark(rapidjson::Document &doc, int ke case IConfig::UserKey: /* --user */ return set(doc, BenchConfig::kBenchmark, BenchConfig::kUser, arg); + + default: + break; } } #endif diff --git a/src/crypto/astrobwt/AstroBWT.cpp b/src/crypto/astrobwt/AstroBWT.cpp index 3e3622530..26b802251 100644 --- a/src/crypto/astrobwt/AstroBWT.cpp +++ b/src/crypto/astrobwt/AstroBWT.cpp @@ -1,16 +1,10 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018 Lee Clagett <https://github.com/vtnerd> - * Copyright 2018-2019 tevador <tevador@gmail.com> - * Copyright 2000 Transmeta Corporation <https://github.com/intel/msr-tools> - * Copyright 2004-2008 H. Peter Anvin <https://github.com/intel/msr-tools> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd> + * Copyright (c) 2018-2019 tevador <tevador@gmail.com> + * Copyright (c) 2000 Transmeta Corporation <https://github.com/intel/msr-tools> + * Copyright (c) 2004-2008 H. Peter Anvin <https://github.com/intel/msr-tools> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +20,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "crypto/astrobwt/AstroBWT.h" #include "backend/cpu/Cpu.h" #include "base/crypto/sha3.h" @@ -123,11 +116,13 @@ void sort_indices(int N, const uint8_t* v, uint64_t* indices, uint64_t* tmp_indi const uint64_t value_a = a >> 21; const uint64_t value_b = b >> 21; - if (value_a < value_b) + if (value_a < value_b) { return true; + } - if (value_a > value_b) + if (value_a > value_b) { return false; + } const uint64_t data_a = bswap_64(*reinterpret_cast<const uint64_t*>(v + (a % (1 << 21)) + 5)); const uint64_t data_b = bswap_64(*reinterpret_cast<const uint64_t*>(v + (b % (1 << 21)) + 5)); @@ -146,8 +141,11 @@ void sort_indices(int N, const uint8_t* v, uint64_t* indices, uint64_t* tmp_indi { indices[j + 1] = prev_t; --j; - if (j < 0) + + if (j < 0) { break; + } + prev_t = indices[j]; } while (smaller(t, prev_t)); indices[j + 1] = t; @@ -181,8 +179,9 @@ bool xmrig::astrobwt::astrobwt_dero(const void* input_data, uint32_t input_size, { const uint8_t* tmp = stage1_output - 1; - for (int i = 0; i <= STAGE1_SIZE; ++i) + for (int i = 0; i <= STAGE1_SIZE; ++i) { stage1_result[i] = tmp[indices[i] & ((1 << 21) - 1)]; + } } #ifdef ASTROBWT_AVX2 @@ -193,8 +192,9 @@ bool xmrig::astrobwt::astrobwt_dero(const void* input_data, uint32_t input_size, sha3_HashBuffer(256, SHA3_FLAGS_NONE, stage1_result, STAGE1_SIZE + 1, key, sizeof(key)); const int stage2_size = STAGE1_SIZE + (*(uint32_t*)(key) & 0xfffff); - if (stage2_size > stage2_max_size) + if (stage2_size > stage2_max_size) { return false; + } Salsa20_XORKeyStream(key, stage2_output, stage2_size); @@ -204,6 +204,7 @@ bool xmrig::astrobwt::astrobwt_dero(const void* input_data, uint32_t input_size, const uint8_t* tmp = stage2_output - 1; int i = 0; const int n = ((stage2_size + 1) / 4) * 4; + for (; i < n; i += 4) { stage2_result[i + 0] = tmp[indices[i + 0] & ((1 << 21) - 1)]; @@ -211,8 +212,10 @@ bool xmrig::astrobwt::astrobwt_dero(const void* input_data, uint32_t input_size, stage2_result[i + 2] = tmp[indices[i + 2] & ((1 << 21) - 1)]; stage2_result[i + 3] = tmp[indices[i + 3] & ((1 << 21) - 1)]; } - for (; i <= stage2_size; ++i) + + for (; i <= stage2_size; ++i) { stage2_result[i] = tmp[indices[i] & ((1 << 21) - 1)]; + } } #ifdef ASTROBWT_AVX2 diff --git a/src/crypto/astrobwt/AstroBWT.h b/src/crypto/astrobwt/AstroBWT.h index 4e526060d..236b3ce47 100644 --- a/src/crypto/astrobwt/AstroBWT.h +++ b/src/crypto/astrobwt/AstroBWT.h @@ -1,16 +1,10 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018 Lee Clagett <https://github.com/vtnerd> - * Copyright 2018-2019 tevador <tevador@gmail.com> - * Copyright 2000 Transmeta Corporation <https://github.com/intel/msr-tools> - * Copyright 2004-2008 H. Peter Anvin <https://github.com/intel/msr-tools> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd> + * Copyright (c) 2018-2019 tevador <tevador@gmail.com> + * Copyright (c) 2000 Transmeta Corporation <https://github.com/intel/msr-tools> + * Copyright (c) 2004-2008 H. Peter Anvin <https://github.com/intel/msr-tools> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +20,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "base/crypto/Algorithm.h" diff --git a/src/crypto/cn/CnCtx.cpp b/src/crypto/cn/CnCtx.cpp index e92fe22ec..c0dc8b344 100644 --- a/src/crypto/cn/CnCtx.cpp +++ b/src/crypto/cn/CnCtx.cpp @@ -1,13 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018 Lee Clagett <https://github.com/vtnerd> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd> + * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,8 +30,8 @@ void xmrig::CnCtx::create(cryptonight_ctx **ctx, uint8_t *memory, size_t size, size_t count) { for (size_t i = 0; i < count; ++i) { - cryptonight_ctx *c = static_cast<cryptonight_ctx *>(_mm_malloc(sizeof(cryptonight_ctx), 4096)); - c->memory = memory + (i * size); + auto *c = static_cast<cryptonight_ctx *>(_mm_malloc(sizeof(cryptonight_ctx), 4096)); + c->memory = memory + (i * size); c->generated_code = reinterpret_cast<cn_mainloop_fun_ms_abi>(VirtualMemory::allocateExecutableMemory(0x4000, false)); c->generated_code_data.algo = Algorithm::INVALID; diff --git a/src/crypto/cn/CnCtx.h b/src/crypto/cn/CnCtx.h index 7939bf4e9..c90430d19 100644 --- a/src/crypto/cn/CnCtx.h +++ b/src/crypto/cn/CnCtx.h @@ -1,13 +1,7 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018 Lee Clagett <https://github.com/vtnerd> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd> + * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/crypto/common/Nonce.cpp b/src/crypto/common/Nonce.cpp index bd23e54c1..e2e51c2c2 100644 --- a/src/crypto/common/Nonce.cpp +++ b/src/crypto/common/Nonce.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "crypto/common/Nonce.h" @@ -48,7 +41,8 @@ bool xmrig::Nonce::next(uint8_t index, uint32_t *nonce, uint32_t reserveCount, u if (mask < counter) { return false; } - else if (mask - counter <= reserveCount - 1) { + + if (mask - counter <= reserveCount - 1) { pause(true); if (mask - counter < reserveCount - 1) { return false; @@ -58,10 +52,13 @@ bool xmrig::Nonce::next(uint8_t index, uint32_t *nonce, uint32_t reserveCount, u counter = m_nonces[index].fetch_add(reserveCount, std::memory_order_relaxed); continue; } + *nonce = (nonce[0] & ~mask) | counter; + if (mask > 0xFFFFFFFFULL) { nonce[1] = (nonce[1] & (~mask >> 32)) | (counter >> 32); } + return true; } } diff --git a/src/crypto/common/Nonce.h b/src/crypto/common/Nonce.h index 7c0e6d49a..5742e67a1 100644 --- a/src/crypto/common/Nonce.h +++ b/src/crypto/common/Nonce.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/crypto/common/VirtualMemory_hwloc.cpp b/src/crypto/common/VirtualMemory_hwloc.cpp index e9e23aa9d..d11290081 100644 --- a/src/crypto/common/VirtualMemory_hwloc.cpp +++ b/src/crypto/common/VirtualMemory_hwloc.cpp @@ -1,14 +1,8 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018 Lee Clagett <https://github.com/vtnerd> - * Copyright 2018-2019 SChernykh <https://github.com/SChernykh> - * Copyright 2018-2019 tevador <tevador@gmail.com> - * Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018 Lee Clagett <https://github.com/vtnerd> + * Copyright (c) 2018-2019 tevador <tevador@gmail.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/crypto/rx/Rx.cpp b/src/crypto/rx/Rx.cpp index c68b8bf1c..e1455dba7 100644 --- a/src/crypto/rx/Rx.cpp +++ b/src/crypto/rx/Rx.cpp @@ -45,7 +45,7 @@ static RxPrivate *d_ptr = nullptr; class RxPrivate { public: - inline RxPrivate(IRxListener *listener) : queue(listener) {} + inline explicit RxPrivate(IRxListener *listener) : queue(listener) {} RxQueue queue; }; diff --git a/src/crypto/rx/RxConfig.cpp b/src/crypto/rx/RxConfig.cpp index ae6215dfe..1cd6f6eb1 100644 --- a/src/crypto/rx/RxConfig.cpp +++ b/src/crypto/rx/RxConfig.cpp @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "crypto/rx/RxConfig.h" #include "3rdparty/rapidjson/document.h" #include "backend/cpu/Cpu.h" @@ -81,7 +74,7 @@ static_assert (kMsrArraySize == ICpuInfo::MSR_MOD_MAX, "kMsrArraySize and MSR_MO #endif -} +} // namespace xmrig bool xmrig::RxConfig::read(const rapidjson::Value &value) @@ -286,7 +279,7 @@ void xmrig::RxConfig::readMSR(const rapidjson::Value &value) #endif -xmrig::RxConfig::Mode xmrig::RxConfig::readMode(const rapidjson::Value &value) const +xmrig::RxConfig::Mode xmrig::RxConfig::readMode(const rapidjson::Value &value) { if (value.IsUint()) { return static_cast<Mode>(std::min(value.GetUint(), ModeMax - 1)); diff --git a/src/crypto/rx/RxConfig.h b/src/crypto/rx/RxConfig.h index ea1bf6859..e4fb4f89c 100644 --- a/src/crypto/rx/RxConfig.h +++ b/src/crypto/rx/RxConfig.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik <jgarzik@pobox.com> - * Copyright 2012-2014 pooler <pooler@litecoinpool.org> - * Copyright 2014 Lucas Jones <https://github.com/lucasjones> - * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> - * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> - * Copyright 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -111,7 +105,7 @@ private: bool m_cacheQoS = false; - Mode readMode(const rapidjson::Value &value) const; + static Mode readMode(const rapidjson::Value &value); bool m_oneGbPages = false; bool m_rdmsr = true; diff --git a/src/crypto/rx/RxDataset.cpp b/src/crypto/rx/RxDataset.cpp index b47285a3d..86b3a3f6d 100644 --- a/src/crypto/rx/RxDataset.cpp +++ b/src/crypto/rx/RxDataset.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2018-2019 tevador <tevador@gmail.com> - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "crypto/rx/RxDataset.h" #include "backend/cpu/Cpu.h" #include "base/io/log/Log.h" @@ -36,7 +35,7 @@ namespace xmrig { -static void init_dataset_wrapper(randomx_dataset *dataset, randomx_cache *cache, unsigned long startItem, unsigned long itemCount, int priority) +static void init_dataset_wrapper(randomx_dataset *dataset, randomx_cache *cache, uint32_t startItem, uint32_t itemCount, int priority) { Platform::setThreadPriority(priority); diff --git a/src/crypto/rx/RxDataset.h b/src/crypto/rx/RxDataset.h index 1621cae14..4f9caadf4 100644 --- a/src/crypto/rx/RxDataset.h +++ b/src/crypto/rx/RxDataset.h @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2018-2019 tevador <tevador@gmail.com> - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/crypto/rx/RxFix_win.cpp b/src/crypto/rx/RxFix_win.cpp index 75538be4d..3d722cd39 100644 --- a/src/crypto/rx/RxFix_win.cpp +++ b/src/crypto/rx/RxFix_win.cpp @@ -17,7 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "crypto/rx/RxFix.h" #include "base/io/log/Log.h" @@ -34,7 +33,7 @@ static thread_local std::pair<const void*, const void*> mainLoopBounds = { nullp static LONG WINAPI MainLoopHandler(_EXCEPTION_POINTERS *ExceptionInfo) { if (ExceptionInfo->ExceptionRecord->ExceptionCode == 0xC0000005) { - const char* accessType; + const char* accessType = nullptr; switch (ExceptionInfo->ExceptionRecord->ExceptionInformation[0]) { case 0: accessType = "read"; break; case 1: accessType = "write"; break; @@ -47,7 +46,7 @@ static LONG WINAPI MainLoopHandler(_EXCEPTION_POINTERS *ExceptionInfo) LOG_VERBOSE(YELLOW_BOLD("[THREAD %u] Exception 0x%08X at 0x%p"), GetCurrentThreadId(), ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo->ExceptionRecord->ExceptionAddress); } - void* p = reinterpret_cast<void*>(ExceptionInfo->ContextRecord->Rip); + void* p = reinterpret_cast<void*>(ExceptionInfo->ContextRecord->Rip); // NOLINT(performance-no-int-to-ptr) const std::pair<const void*, const void*>& loopBounds = mainLoopBounds; if ((loopBounds.first <= p) && (p < loopBounds.second)) { diff --git a/src/crypto/rx/RxNUMAStorage.cpp b/src/crypto/rx/RxNUMAStorage.cpp index 6bd5627f2..b6345a061 100644 --- a/src/crypto/rx/RxNUMAStorage.cpp +++ b/src/crypto/rx/RxNUMAStorage.cpp @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2018-2019 tevador <tevador@gmail.com> - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "crypto/rx/RxNUMAStorage.h" #include "backend/cpu/Cpu.h" #include "backend/cpu/platform/HwlocCpuInfo.h" @@ -79,7 +78,7 @@ class RxNUMAStoragePrivate public: XMRIG_DISABLE_COPY_MOVE_DEFAULT(RxNUMAStoragePrivate) - inline RxNUMAStoragePrivate(const std::vector<uint32_t> &nodeset) : + inline explicit RxNUMAStoragePrivate(const std::vector<uint32_t> &nodeset) : m_nodeset(nodeset) { m_threads.reserve(nodeset.size()); @@ -230,7 +229,7 @@ private: std::lock_guard<std::mutex> lock(mutex); d_ptr->m_datasets.insert({ nodeId, dataset }); - d_ptr->printAllocStatus(dataset, nodeId, ts); + RxNUMAStoragePrivate::printAllocStatus(dataset, nodeId, ts); } @@ -251,7 +250,7 @@ private: std::lock_guard<std::mutex> lock(mutex); d_ptr->m_cache = cache; - d_ptr->printAllocStatus(cache, nodeId, ts); + RxNUMAStoragePrivate::printAllocStatus(cache, nodeId, ts); } @@ -265,7 +264,7 @@ private: } - void printAllocStatus(RxDataset *dataset, uint32_t nodeId, uint64_t ts) + static void printAllocStatus(RxDataset *dataset, uint32_t nodeId, uint64_t ts) { const auto pages = dataset->hugePages(); @@ -280,7 +279,7 @@ private: } - void printAllocStatus(RxCache *cache, uint32_t nodeId, uint64_t ts) + static void printAllocStatus(RxCache *cache, uint32_t nodeId, uint64_t ts) { const auto pages = cache->hugePages(); @@ -296,7 +295,7 @@ private: } - void printAllocStatus(uint64_t ts) + void printAllocStatus(uint64_t ts) const { auto pages = hugePages(); diff --git a/src/crypto/rx/RxNUMAStorage.h b/src/crypto/rx/RxNUMAStorage.h index 29ec5fb0f..33d5b92ab 100644 --- a/src/crypto/rx/RxNUMAStorage.h +++ b/src/crypto/rx/RxNUMAStorage.h @@ -1,7 +1,7 @@ /* XMRig * Copyright (c) 2018-2019 tevador <tevador@gmail.com> - * Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh> - * Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com> + * Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> + * Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/hw/dmi/DmiReader.cpp b/src/hw/dmi/DmiReader.cpp index 18211759a..1e12603c2 100644 --- a/src/hw/dmi/DmiReader.cpp +++ b/src/hw/dmi/DmiReader.cpp @@ -18,7 +18,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "hw/dmi/DmiReader.h" #include "3rdparty/fmt/core.h" #include "3rdparty/rapidjson/document.h" @@ -111,7 +110,6 @@ bool xmrig::DmiReader::decode(uint8_t *buf) next += 2; if (static_cast<uint32_t>(next - buf) > m_size) { - data = next; break; } diff --git a/src/hw/msr/Msr.cpp b/src/hw/msr/Msr.cpp index 1fed87760..47ed424bd 100644 --- a/src/hw/msr/Msr.cpp +++ b/src/hw/msr/Msr.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #include "hw/msr/Msr.h" #include "base/io/log/Log.h" @@ -58,7 +57,7 @@ std::shared_ptr<xmrig::Msr> xmrig::Msr::get() bool xmrig::Msr::write(uint32_t reg, uint64_t value, int32_t cpu, uint64_t mask, bool verbose) { if (mask != MsrItem::kNoMask) { - uint64_t old_value; + uint64_t old_value = 0; if (rdmsr(reg, cpu, old_value)) { value = MsrItem::maskedValue(old_value, value, mask); } diff --git a/src/net/JobResults.cpp b/src/net/JobResults.cpp index bcf1abd13..19a1dc43c 100644 --- a/src/net/JobResults.cpp +++ b/src/net/JobResults.cpp @@ -291,8 +291,6 @@ private: } # endif - -private: const bool m_hwAES; IJobResultListener *m_listener; std::list<JobResult> m_results;