Warning messages:
leveldb/util/logging.cc: In function ‘bool leveldb::ConsumeDecimalNumber(leveldb::Slice*, uint64_t*)’:
leveldb/util/logging.cc:58:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
(v == kMaxUint64/10 && delta > kMaxUint64%10)) {
~~~~~~^~~~~~~~~~~~~~~
leveldb/port/port_posix.cc: In function ‘bool leveldb::port::HasAcceleratedCRC32C()’:
leveldb/port/port_posix.cc:60:15: warning: ‘ecx’ may be used uninitialized in this function [-Wmaybe-uninitialized]
return (ecx & (1 << 20)) != 0;
~~~~~^~~~~~~~~~~~
Fixes:
leveldb/port/port_posix.cc:60:15: warning: ‘ecx’ may be used uninitialized in this function
Code part:
unsigned int eax, ebx, ecx, edx;
ecx = 0;
__get_cpuid(1, &eax, &ebx, &ecx, &edx);
return (ecx & (1 << 20)) != 0;
Explanation: Simply initiated ecx variable.
ecx = 0;
leveldb/util/logging.cc:58:40: warning: comparison between signed and unsigned integer expressions
Code part:
if (c >= '0' && c <= '9') {
++digits;
const int delta = (c - '0');
static const uint64_t kMaxUint64 = ~static_cast<uint64_t>(0);
if (v > kMaxUint64/10 ||
(v == kMaxUint64/10 && (uint64_t) delta > kMaxUint64%10)) {
// Overflow
return false;
}
Explanation: if statement comparing c >= '0' forces c to be definite positive or zero. 'delta' constant value assignment ( delta = (c - '0') ) and the comparison of it with a modular division also shows that 'delta' is definite positive or zero. So we can make an inline type change from int to uint64_t for 'delta' such that
(v == kMaxUint64/10 && (uint64_t) delta > kMaxUint64%10)) {