Browse Source

Fixed errors found by static analysis

pull/1969/head
SChernykh 4 years ago
parent
commit
cafd868773
  1. 2
      src/backend/common/WorkerJob.h
  2. 2
      src/backend/cpu/platform/HwlocCpuInfo.h
  3. 2
      src/backend/opencl/runners/OclAstroBWTRunner.cpp
  4. 7
      src/backend/opencl/runners/OclKawPowRunner.cpp
  5. 2
      src/base/crypto/keccak.cpp
  6. 2
      src/crypto/astrobwt/AstroBWT.cpp
  7. 2
      src/crypto/cn/r/CryptonightR_gen.cpp
  8. 22
      src/crypto/randomx/jit_compiler_x86.cpp
  9. 2
      src/crypto/randomx/superscalar.cpp
  10. 1
      src/net/JobResults.cpp

2
src/backend/common/WorkerJob.h

@ -110,7 +110,7 @@ private:
alignas(16) uint8_t m_blobs[2][Job::kMaxBlobSize * N]{};
Job m_jobs[2];
uint32_t m_rounds[2] = { 0, 0 };
uint64_t m_nonce_mask[2];
uint64_t m_nonce_mask[2] = { 0, 0 };
uint64_t m_sequence = 0;
uint8_t m_index = 0;
};

2
src/backend/cpu/platform/HwlocCpuInfo.h

@ -46,7 +46,7 @@ public:
HwlocCpuInfo();
~HwlocCpuInfo() override;
static inline bool has(Feature feature) { return m_features & feature; }
static inline bool hasFeature(Feature feature) { return m_features & feature; }
inline const std::vector<uint32_t> &nodeset() const { return m_nodeset; }
inline hwloc_topology_t topology() const { return m_topology; }

2
src/backend/opencl/runners/OclAstroBWTRunner.cpp

@ -93,7 +93,7 @@ xmrig::OclAstroBWTRunner::~OclAstroBWTRunner()
OclLib::release(m_tmp_indices);
OclLib::release(m_filtered_hashes);
delete m_bwt_data_sizes_host;
delete [] m_bwt_data_sizes_host;
}

7
src/backend/opencl/runners/OclKawPowRunner.cpp

@ -43,6 +43,9 @@
namespace xmrig {
constexpr size_t BLOB_SIZE = 40;
OclKawPowRunner::OclKawPowRunner(size_t index, const OclLaunchData &data) : OclBaseRunner(index, data)
{
switch (data.thread.worksize())
@ -82,7 +85,7 @@ void OclKawPowRunner::run(uint32_t nonce, uint32_t *hashOutput)
const size_t global_work_offset = nonce;
const size_t global_work_size = m_intensity - (m_intensity % m_workGroupSize);
enqueueWriteBuffer(m_input, CL_FALSE, 0, 40, m_blob);
enqueueWriteBuffer(m_input, CL_FALSE, 0, BLOB_SIZE, m_blob);
const uint32_t zero[2] = {};
enqueueWriteBuffer(m_output, CL_FALSE, 0, sizeof(uint32_t), zero);
@ -177,7 +180,7 @@ void OclKawPowRunner::set(const Job &job, uint8_t *blob)
OclLib::setKernelArg(m_searchKernel, 5, sizeof(m_stop), &m_stop);
m_blob = blob;
enqueueWriteBuffer(m_input, CL_TRUE, 0, sizeof(m_blob), m_blob);
enqueueWriteBuffer(m_input, CL_TRUE, 0, BLOB_SIZE, m_blob);
}

2
src/base/crypto/keccak.cpp

@ -168,7 +168,7 @@ typedef uint64_t state_t[25];
void xmrig::keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen)
{
state_t st;
uint8_t temp[144];
alignas(8) uint8_t temp[144];
int i, rsiz, rsizw;
rsiz = sizeof(state_t) == mdlen ? HASH_DATA_AREA : 200 - 2 * mdlen;

2
src/crypto/astrobwt/AstroBWT.cpp

@ -173,7 +173,7 @@ void sort_indices(int N, const uint8_t* v, uint64_t* indices, uint64_t* tmp_indi
bool xmrig::astrobwt::astrobwt_dero(const void* input_data, uint32_t input_size, void* scratchpad, uint8_t* output_hash, int stage2_max_size, bool avx2)
{
uint8_t key[32];
alignas(8) uint8_t key[32];
uint8_t* scratchpad_ptr = (uint8_t*)(scratchpad) + 64;
uint8_t* stage1_output = scratchpad_ptr;
uint8_t* stage2_output = scratchpad_ptr;

2
src/crypto/cn/r/CryptonightR_gen.cpp

@ -76,7 +76,7 @@ static inline void add_random_math(uint8_t* &p, const V4_Instruction* code, int
void_func begin = instructions[c];
if ((ASM = xmrig::Assembly::BULLDOZER) && (inst.opcode == MUL) && !is_64_bit) {
if ((ASM == xmrig::Assembly::BULLDOZER) && (inst.opcode == MUL) && !is_64_bit) {
// AMD Bulldozer has latency 4 for 32-bit IMUL and 6 for 64-bit IMUL
// Always use 32-bit IMUL for AMD Bulldozer in 32-bit mode - skip prefix 0x48 and change 0x49 to 0x41
uint8_t* prefix = reinterpret_cast<uint8_t*>(begin);

22
src/crypto/randomx/jit_compiler_x86.cpp

@ -411,30 +411,14 @@ namespace randomx {
emitByte(instr.getImm32() & 63, code, codePos);
break;
case randomx::SuperscalarInstructionType::IADD_C7:
emit(REX_81, code, codePos);
emitByte(0xc0 + instr.dst, code, codePos);
emit32(instr.getImm32(), code, codePos);
break;
case randomx::SuperscalarInstructionType::IXOR_C7:
emit(REX_XOR_RI, code, codePos);
emitByte(0xf0 + instr.dst, code, codePos);
emit32(instr.getImm32(), code, codePos);
break;
case randomx::SuperscalarInstructionType::IADD_C8:
emit(REX_81, code, codePos);
emitByte(0xc0 + instr.dst, code, codePos);
emit32(instr.getImm32(), code, codePos);
break;
case randomx::SuperscalarInstructionType::IXOR_C8:
emit(REX_XOR_RI, code, codePos);
emitByte(0xf0 + instr.dst, code, codePos);
emit32(instr.getImm32(), code, codePos);
break;
case randomx::SuperscalarInstructionType::IADD_C9:
emit(REX_81, code, codePos);
emitByte(0xc0 + instr.dst, code, codePos);
emit32(instr.getImm32(), code, codePos);
break;
case randomx::SuperscalarInstructionType::IXOR_C7:
case randomx::SuperscalarInstructionType::IXOR_C8:
case randomx::SuperscalarInstructionType::IXOR_C9:
emit(REX_XOR_RI, code, codePos);
emitByte(0xf0 + instr.dst, code, codePos);
@ -1088,7 +1072,7 @@ namespace randomx {
pos += 14;
if (jmp_offset >= -128) {
*(uint32_t*)(p + pos) = 0x74 + (jmp_offset << 8);
*(uint32_t*)(p + pos) = 0x74 + (static_cast<uint32_t>(jmp_offset) << 8);
pos += 2;
}
else {

2
src/crypto/randomx/superscalar.cpp

@ -196,7 +196,7 @@ namespace randomx {
int latency_;
int resultOp_ = 0;
int dstOp_ = 0;
int srcOp_;
int srcOp_ = 0;
SuperscalarInstructionInfo(const char* name)
: name_(name), type_(SuperscalarInstructionType::INVALID), latency_(0) {}

1
src/net/JobResults.cpp

@ -123,6 +123,7 @@ static void getResults(JobBundle &bundle, std::vector<JobResult> &results, uint3
RxDataset *dataset = Rx::dataset(bundle.job, 0);
if (dataset == nullptr) {
errors += bundle.nonces.size();
delete memory;
return;
}

Loading…
Cancel
Save