Code cleanup based on Clang-Tidy.

This commit is contained in:
XMRig 2021-08-25 18:45:15 +07:00
parent 3215403815
commit c7ac314110
No known key found for this signature in database
GPG key ID: 446A53638BE94409
133 changed files with 437 additions and 833 deletions

View file

@ -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());
}

View file

@ -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
}
}

View file

@ -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 } },