소스 검색

Switched variable type from int to uint64_t in ConsumeDecimalNumber.

An Android test was occasionally crashing with a SEGV in ConsumeDecimalNumber
Switching a local variable from an int to uint64_t eliminated these crashes.
Speculating this is either a compiler, runtime library, or emulator issue.

Switching this type to uint64_t also eliminates a compiler warning
about comparing an int with a uint64_t.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166399695
pull/1/head
cmumford 7 년 전
committed by Victor Costan
부모
커밋
09a3c8e741
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. +2
    -1
      util/logging.cc

+ 2
- 1
util/logging.cc 파일 보기

@ -52,7 +52,8 @@ bool ConsumeDecimalNumber(Slice* in, uint64_t* val) {
char c = (*in)[0];
if (c >= '0' && c <= '9') {
++digits;
const int delta = (c - '0');
// |delta| intentionally unit64_t to avoid Android crash (see log).
const uint64_t delta = (c - '0');
static const uint64_t kMaxUint64 = ~static_cast<uint64_t>(0);
if (v > kMaxUint64/10 ||
(v == kMaxUint64/10 && delta > kMaxUint64%10)) {

불러오는 중...
취소
저장