More static analysis fixes

This commit is contained in:
SChernykh 2020-12-08 16:05:58 +01:00
parent cafd868773
commit 0da3390d09
14 changed files with 40 additions and 33 deletions

View file

@ -28,6 +28,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <thread>
#include <vector>
#include <array>
#include "crypto/randomx/aes_hash.hpp"
#include "base/tools/Chrono.h"
@ -371,7 +372,7 @@ hashAndFillAes1Rx4_impl* softAESImpl = &hashAndFillAes1Rx4<1,1>;
void SelectSoftAESImpl(size_t threadsCount)
{
constexpr int test_length_ms = 100;
const std::vector<hashAndFillAes1Rx4_impl *> impl = {
const std::array<hashAndFillAes1Rx4_impl *, 4> impl = {
&hashAndFillAes1Rx4<1,1>,
&hashAndFillAes1Rx4<2,1>,
&hashAndFillAes1Rx4<2,2>,

View file

@ -48,7 +48,7 @@ struct randomx_cache {
randomx::DatasetInitFunc* datasetInit;
randomx::SuperscalarProgram programs[RANDOMX_CACHE_MAX_ACCESSES];
bool isInitialized() {
bool isInitialized() const {
return programs[0].getSize() != 0;
}
};

View file

@ -1076,7 +1076,7 @@ namespace randomx {
pos += 2;
}
else {
*(uint64_t*)(p + pos) = 0x840f + ((static_cast<int64_t>(jmp_offset) - 4) << 16);
*(uint64_t*)(p + pos) = 0x840f + (static_cast<uint64_t>(jmp_offset - 4) << 16);
pos += 6;
}

View file

@ -68,11 +68,11 @@ namespace randomx {
alignas(64) static InstructionGeneratorX86 engine[256];
int registerUsage[RegistersCount];
uint8_t* code;
uint32_t codePos;
uint32_t codePosFirst;
uint32_t vm_flags;
int registerUsage[RegistersCount] = {};
uint8_t* code = nullptr;
uint32_t codePos = 0;
uint32_t codePosFirst = 0;
uint32_t vm_flags = 0;
# ifdef XMRIG_FIX_RYZEN
std::pair<const void*, const void*> mainLoopBounds;

View file

@ -282,11 +282,11 @@ namespace randomx {
return fetchNextDefault(gen);
}
private:
const char* name_;
int index_;
const int* counts_;
int opsCount_;
DecoderBuffer() : index_(-1) {}
const char* name_ = nullptr;
int index_ = -1;
const int* counts_ = nullptr;
int opsCount_ = 0;
DecoderBuffer() = default;
static const DecoderBuffer decodeBuffer484;
static const DecoderBuffer decodeBuffer7333;
static const DecoderBuffer decodeBuffer3733;
@ -555,10 +555,10 @@ namespace randomx {
const SuperscalarInstructionInfo* info_;
int src_ = -1;
int dst_ = -1;
int mod_;
uint32_t imm32_;
SuperscalarInstructionType opGroup_;
int opGroupPar_;
int mod_ = 0;
uint32_t imm32_ = 0;
SuperscalarInstructionType opGroup_ = SuperscalarInstructionType::INVALID;
int opGroupPar_ = 0;
bool canReuse_ = false;
bool groupParIsSource_ = false;

View file

@ -39,13 +39,13 @@ namespace randomx {
Instruction& operator()(int pc) {
return programBuffer[pc];
}
uint32_t getSize() {
uint32_t getSize() const {
return size;
}
void setSize(uint32_t val) {
size = val;
}
int getAddressRegister() {
int getAddressRegister() const {
return addrReg;
}
void setAddressRegister(int val) {