Utils and libraries: Leveldb warning fixes #12551

pull bedri wants to merge 5 commits into bitcoin:master from bedri:leveldbWarningFixes changing 6 files +1809 −1
  1. bedri commented at 4:43 AM on February 27, 2018: none

    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)) {
    
  2. Merge #12083: Improve getchaintxstats test coverage
    57e6786 qa: Improve getchaintxstats functional test (João Barbosa)
    501b439 rpc: Refactor blockhash parse in getchaintxstats (João Barbosa)
    
    Pull request description:
    
    Tree-SHA512: 61dec5cb68122998df7ec7b5239830f3caf0fe7185c107a66f27653ab2531a800db19a09050671b6fa8dbb5b53181da861eb31199c79d8635f246ccfa0d10efd
    d8b13d453c
  3. fixes 'leveldb/util/logging.cc:58:40: warning: comparison between signed and unsigned integer expressions' compile warning message 6e7240c40e
  4. fixes 'leveldb/port/port_posix.cc:60:15: warning: ‘ecx’ may be used uninitialized in this function' compile warning message 1d9cb4ebac
  5. bedri renamed this:
    Leveldb warning fixes
    Utils and libraries: Leveldb warning fixes
    on Feb 27, 2018
  6. fixes 'leveldb/port/port_posix.cc:60:15: warning: ‘ecx’ may be used uninitialized in this function' compile warning message 4c135b29ab
  7. fixes 'leveldb/util/logging.cc:58:40: warning: comparison between signed and unsigned integer expressions' compile warning message efdd642e52
  8. fanquake commented at 6:27 AM on February 27, 2018: member

    Please submit leveldb changes to our upstream repository.

  9. fanquake closed this on Feb 27, 2018

  10. MarcoFalke locked this on Sep 8, 2021
Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-14 18:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me