Add GCC 8 to Travis (#3433)

Summary:
- Avoid `strdup` to use jemalloc on Windows
- Use `size_t` for consistency
- Add GCC 8 to Travis
- Add CMAKE_BUILD_TYPE=Release to Travis
Pull Request resolved: https://github.com/facebook/rocksdb/pull/3433

Differential Revision: D6837948

Pulled By: sagar0

fbshipit-source-id: b8543c3a4da9cd07ee9a33f9f4623188e233261f
This commit is contained in:
Tamir Duberstein 2018-07-13 10:47:49 -07:00 committed by Facebook Github Bot
parent de98fd88e3
commit 7bee48bdbd
14 changed files with 263 additions and 201 deletions

View File

@ -16,7 +16,16 @@ cache:
addons: addons:
apt: apt:
packages: ['zlib1g-dev', 'libbz2-dev', 'libsnappy-dev', 'curl', 'libgflags-dev', 'mingw-w64'] sources:
- ubuntu-toolchain-r-test
packages:
- curl
- g++-8
- libbz2-dev
- libgflags-dev
- libsnappy-dev
- mingw-w64
- zlib1g-dev
env: env:
- TEST_GROUP=platform_dependent # 16-18 minutes - TEST_GROUP=platform_dependent # 16-18 minutes
- TEST_GROUP=1 # 33-35 minutes - TEST_GROUP=1 # 33-35 minutes
@ -30,6 +39,7 @@ env:
# Build examples # Build examples
- JOB_NAME=examples # 5-7 minutes - JOB_NAME=examples # 5-7 minutes
- JOB_NAME=cmake # 3-5 minutes - JOB_NAME=cmake # 3-5 minutes
- JOB_NAME=cmake-gcc8 # 3-5 minutes
- JOB_NAME=cmake-mingw # 3 minutes - JOB_NAME=cmake-mingw # 3 minutes
matrix: matrix:
@ -42,6 +52,8 @@ matrix:
env: TEST_GROUP=3 env: TEST_GROUP=3
- os: osx - os: osx
env: TEST_GROUP=4 env: TEST_GROUP=4
- os: osx
env: JOB_NAME=cmake-gcc8
- os : osx - os : osx
env: JOB_NAME=cmake-mingw env: JOB_NAME=cmake-mingw
- os : linux - os : linux
@ -55,6 +67,9 @@ install:
brew install ccache zstd lz4 snappy xz; brew install ccache zstd lz4 snappy xz;
PATH=$PATH:/usr/local/opt/ccache/libexec; PATH=$PATH:/usr/local/opt/ccache/libexec;
fi fi
- if [ "${JOB_NAME}" == cmake-gcc8 ]; then
CC=gcc-8 && CXX=g++-8;
fi
- if [[ "${JOB_NAME}" == cmake* ]] && [ "${TRAVIS_OS_NAME}" == linux ]; then - if [[ "${JOB_NAME}" == cmake* ]] && [ "${TRAVIS_OS_NAME}" == linux ]; then
mkdir cmake-dist && curl -sfSL https://cmake.org/files/v3.8/cmake-3.8.1-Linux-x86_64.tar.gz | tar --strip-components=1 -C cmake-dist -xz && export PATH=$PWD/cmake-dist/bin:$PATH; mkdir cmake-dist && curl -sfSL https://cmake.org/files/v3.8/cmake-3.8.1-Linux-x86_64.tar.gz | tar --strip-components=1 -C cmake-dist -xz && export PATH=$PWD/cmake-dist/bin:$PATH;
fi fi
@ -67,16 +82,40 @@ before_script:
script: script:
- ${CXX} --version - ${CXX} --version
- if [ `command -v ccache` ]; then ccache -C; fi - if [ `command -v ccache` ]; then ccache -C; fi
- if [ "${TEST_GROUP}" == 'platform_dependent' ]; then OPT=-DTRAVIS V=1 ROCKSDBTESTS_END=db_block_cache_test make -j4 all_but_some_tests check_some; fi - case $TEST_GROUP in
- if [ "${TEST_GROUP}" == '1' ]; then OPT=-DTRAVIS V=1 ROCKSDBTESTS_START=db_block_cache_test ROCKSDBTESTS_END=full_filter_block_test make -j4 check_some; fi platform_dependent)
- if [ "${TEST_GROUP}" == '2' ]; then OPT=-DTRAVIS V=1 ROCKSDBTESTS_START=full_filter_block_test ROCKSDBTESTS_END=write_batch_with_index_test make -j4 check_some; fi OPT=-DTRAVIS V=1 ROCKSDBTESTS_END=db_block_cache_test make -j4 all_but_some_tests check_some
- if [ "${TEST_GROUP}" == '3' ]; then OPT=-DTRAVIS V=1 ROCKSDBTESTS_START=write_batch_with_index_test ROCKSDBTESTS_END=write_prepared_transaction_test make -j4 check_some; fi ;;
- if [ "${TEST_GROUP}" == '4' ]; then OPT=-DTRAVIS V=1 ROCKSDBTESTS_START=write_prepared_transaction_test make -j4 check_some; fi 1)
- if [ "${JOB_NAME}" == 'java_test' ]; then OPT=-DTRAVIS V=1 make clean jclean && make rocksdbjava jtest; fi OPT=-DTRAVIS V=1 ROCKSDBTESTS_START=db_block_cache_test ROCKSDBTESTS_END=full_filter_block_test make -j4 check_some
- if [ "${JOB_NAME}" == 'lite_build' ]; then OPT="-DTRAVIS -DROCKSDB_LITE" V=1 make -j4 static_lib tools; fi ;;
- if [ "${JOB_NAME}" == 'examples' ]; then OPT=-DTRAVIS V=1 make -j4 static_lib; cd examples; make -j4; fi 2)
- if [ "${JOB_NAME}" == 'cmake' ]; then mkdir build && cd build && cmake -DJNI=1 .. && make -j4 rocksdb rocksdbjni; fi OPT=-DTRAVIS V=1 ROCKSDBTESTS_START=full_filter_block_test ROCKSDBTESTS_END=write_batch_with_index_test make -j4 check_some
- if [ "${JOB_NAME}" == 'cmake-mingw' ]; then mkdir build && cd build && cmake -DJNI=1 .. -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_SYSTEM_NAME=Windows && make -j4 rocksdb rocksdbjni; fi ;;
3)
OPT=-DTRAVIS V=1 ROCKSDBTESTS_START=write_batch_with_index_test ROCKSDBTESTS_END=write_prepared_transaction_test make -j4 check_some
;;
4)
OPT=-DTRAVIS V=1 ROCKSDBTESTS_START=write_prepared_transaction_test make -j4 check_some
;;
esac
- case $JOB_NAME in
java_test)
OPT=-DTRAVIS V=1 make clean jclean && make rocksdbjava jtest
;;
lite_build)
OPT='-DTRAVIS -DROCKSDB_LITE' V=1 make -j4 static_lib tools
;;
examples)
OPT=-DTRAVIS V=1 make -j4 static_lib && cd examples && make -j4
;;
cmake-mingw)
mkdir build && cd build && cmake -DJNI=1 .. -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_SYSTEM_NAME=Windows && make -j4 rocksdb rocksdbjni
;;
cmake*)
mkdir build && cd build && cmake -DJNI=1 .. -DCMAKE_BUILD_TYPE=Release && make -j4 rocksdb rocksdbjni
;;
esac
notifications: notifications:
email: email:
- leveldb@fb.com - leveldb@fb.com

View File

@ -170,7 +170,7 @@ else()
endif() endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-momit-leaf-frame-pointer" HAVE_OMIT_LEAF_FRAME_POINTER) CHECK_CXX_COMPILER_FLAG("-momit-leaf-frame-pointer" HAVE_OMIT_LEAF_FRAME_POINTER)
if(HAVE_OMIT_LEAF_FRAME_POINTER) if(HAVE_OMIT_LEAF_FRAME_POINTER)

View File

@ -45,7 +45,7 @@ We plan to use this port for our business purposes here at Bing and this provide
* All posix specific headers were replaced to port/port.h which worked well * All posix specific headers were replaced to port/port.h which worked well
* Replaced `dirent.h` for `port/dirent.h` (very few places) with the implementation of the relevant interfaces within `rocksdb::port` namespace * Replaced `dirent.h` for `port/dirent.h` (very few places) with the implementation of the relevant interfaces within `rocksdb::port` namespace
* Replaced `sys/time.h` to `port/sys_time.h` (few places) implemented equivalents within `rocksdb::port` * Replaced `sys/time.h` to `port/sys_time.h` (few places) implemented equivalents within `rocksdb::port`
* `printf %z` specification is not supported on Windows. To imitate existing standards we came up with a string macro `ROCKSDB_PRIszt` which expands to `%z` on posix systems and to Iu on windows. * `printf %z` specification is not supported on Windows. To imitate existing standards we came up with a string macro `ROCKSDB_PRIszt` which expands to `zu` on posix systems and to `Iu` on windows.
* in class member initialization were moved to a __ctors in some cases * in class member initialization were moved to a __ctors in some cases
* `constexpr` is not supported. We had to replace `std::numeric_limits<>::max/min()` to its C macros for constants. Sometimes we had to make class members `static const` and place a definition within a .cc file. * `constexpr` is not supported. We had to replace `std::numeric_limits<>::max/min()` to its C macros for constants. Sometimes we had to make class members `static const` and place a definition within a .cc file.
* `constexpr` for functions was replaced to a template specialization (1 place) * `constexpr` for functions was replaced to a template specialization (1 place)

View File

@ -14,6 +14,7 @@
#include "util/coding.h" #include "util/coding.h"
#include "util/crc32c.h" #include "util/crc32c.h"
#include "util/file_reader_writer.h" #include "util/file_reader_writer.h"
#include "util/util.h"
namespace rocksdb { namespace rocksdb {
namespace log { namespace log {
@ -151,7 +152,7 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch,
// in clean shutdown we don't expect any error in the log files // in clean shutdown we don't expect any error in the log files
ReportCorruption(drop_size, "truncated header"); ReportCorruption(drop_size, "truncated header");
} }
// fall-thru FALLTHROUGH_INTENDED;
case kEof: case kEof:
if (in_fragmented_record) { if (in_fragmented_record) {
@ -181,7 +182,7 @@ bool Reader::ReadRecord(Slice* record, std::string* scratch,
} }
return false; return false;
} }
// fall-thru FALLTHROUGH_INTENDED;
case kBadRecord: case kBadRecord:
if (in_fragmented_record) { if (in_fragmented_record) {

View File

@ -36,6 +36,7 @@
#include "util/memory_usage.h" #include "util/memory_usage.h"
#include "util/murmurhash.h" #include "util/murmurhash.h"
#include "util/mutexlock.h" #include "util/mutexlock.h"
#include "util/util.h"
namespace rocksdb { namespace rocksdb {
@ -639,7 +640,7 @@ static bool SaveValue(void* arg, const char* entry) {
*(s->found_final_value) = true; *(s->found_final_value) = true;
return false; return false;
} }
// intentional fallthrough FALLTHROUGH_INTENDED;
case kTypeValue: { case kTypeValue: {
if (s->inplace_update_support) { if (s->inplace_update_support) {
s->mem->GetLock(s->key->user_key())->ReadLock(); s->mem->GetLock(s->key->user_key())->ReadLock();

View File

@ -55,6 +55,7 @@
#include "util/coding.h" #include "util/coding.h"
#include "util/duplicate_detector.h" #include "util/duplicate_detector.h"
#include "util/string_util.h" #include "util/string_util.h"
#include "util/util.h"
namespace rocksdb { namespace rocksdb {
@ -307,7 +308,7 @@ Status ReadRecordFromWriteBatch(Slice* input, char* tag,
if (!GetVarint32(input, column_family)) { if (!GetVarint32(input, column_family)) {
return Status::Corruption("bad WriteBatch Put"); return Status::Corruption("bad WriteBatch Put");
} }
// intentional fallthrough FALLTHROUGH_INTENDED;
case kTypeValue: case kTypeValue:
if (!GetLengthPrefixedSlice(input, key) || if (!GetLengthPrefixedSlice(input, key) ||
!GetLengthPrefixedSlice(input, value)) { !GetLengthPrefixedSlice(input, value)) {
@ -319,7 +320,7 @@ Status ReadRecordFromWriteBatch(Slice* input, char* tag,
if (!GetVarint32(input, column_family)) { if (!GetVarint32(input, column_family)) {
return Status::Corruption("bad WriteBatch Delete"); return Status::Corruption("bad WriteBatch Delete");
} }
// intentional fallthrough FALLTHROUGH_INTENDED;
case kTypeDeletion: case kTypeDeletion:
case kTypeSingleDeletion: case kTypeSingleDeletion:
if (!GetLengthPrefixedSlice(input, key)) { if (!GetLengthPrefixedSlice(input, key)) {
@ -330,7 +331,7 @@ Status ReadRecordFromWriteBatch(Slice* input, char* tag,
if (!GetVarint32(input, column_family)) { if (!GetVarint32(input, column_family)) {
return Status::Corruption("bad WriteBatch DeleteRange"); return Status::Corruption("bad WriteBatch DeleteRange");
} }
// intentional fallthrough FALLTHROUGH_INTENDED;
case kTypeRangeDeletion: case kTypeRangeDeletion:
// for range delete, "key" is begin_key, "value" is end_key // for range delete, "key" is begin_key, "value" is end_key
if (!GetLengthPrefixedSlice(input, key) || if (!GetLengthPrefixedSlice(input, key) ||
@ -342,7 +343,7 @@ Status ReadRecordFromWriteBatch(Slice* input, char* tag,
if (!GetVarint32(input, column_family)) { if (!GetVarint32(input, column_family)) {
return Status::Corruption("bad WriteBatch Merge"); return Status::Corruption("bad WriteBatch Merge");
} }
// intentional fallthrough FALLTHROUGH_INTENDED;
case kTypeMerge: case kTypeMerge:
if (!GetLengthPrefixedSlice(input, key) || if (!GetLengthPrefixedSlice(input, key) ||
!GetLengthPrefixedSlice(input, value)) { !GetLengthPrefixedSlice(input, value)) {
@ -353,7 +354,7 @@ Status ReadRecordFromWriteBatch(Slice* input, char* tag,
if (!GetVarint32(input, column_family)) { if (!GetVarint32(input, column_family)) {
return Status::Corruption("bad WriteBatch BlobIndex"); return Status::Corruption("bad WriteBatch BlobIndex");
} }
// intentional fallthrough FALLTHROUGH_INTENDED;
case kTypeBlobIndex: case kTypeBlobIndex:
if (!GetLengthPrefixedSlice(input, key) || if (!GetLengthPrefixedSlice(input, key) ||
!GetLengthPrefixedSlice(input, value)) { !GetLengthPrefixedSlice(input, value)) {

View File

@ -26,7 +26,7 @@ class Status {
public: public:
// Create a success status. // Create a success status.
Status() : code_(kOk), subcode_(kNone), sev_(kNoError), state_(nullptr) {} Status() : code_(kOk), subcode_(kNone), sev_(kNoError), state_(nullptr) {}
~Status() { free((void *) state_); } ~Status() { delete[] state_; }
// Copy the specified status. // Copy the specified status.
Status(const Status& s); Status(const Status& s);
@ -308,7 +308,7 @@ inline Status& Status::operator=(const Status& s) {
code_ = s.code_; code_ = s.code_;
subcode_ = s.subcode_; subcode_ = s.subcode_;
sev_ = s.sev_; sev_ = s.sev_;
free((void *) state_); delete[] state_;
state_ = (s.state_ == nullptr) ? nullptr : CopyState(s.state_); state_ = (s.state_ == nullptr) ? nullptr : CopyState(s.state_);
} }
return *this; return *this;
@ -334,7 +334,7 @@ inline Status& Status::operator=(Status&& s)
s.subcode_ = kNone; s.subcode_ = kNone;
sev_ = std::move(s.sev_); sev_ = std::move(s.sev_);
s.sev_ = kNoError; s.sev_ = kNoError;
free((void *)state_); delete[] state_;
state_ = nullptr; state_ = nullptr;
std::swap(state_, s.state_); std::swap(state_, s.state_);
} }

View File

@ -996,7 +996,7 @@ class HarnessTest : public testing::Test {
std::vector<TestArgs> args = GenerateArgList(); std::vector<TestArgs> args = GenerateArgList();
assert(part); assert(part);
assert(part <= total); assert(part <= total);
for (unsigned int i = 0; i < args.size(); i++) { for (size_t i = 0; i < args.size(); i++) {
if ((i % total) + 1 != part) { if ((i % total) + 1 != part) {
continue; continue;
} }

View File

@ -456,7 +456,11 @@ class FbsonJsonParserT {
} }
case '+': case '+':
in.ignore(); in.ignore();
// fall through #if defined(__clang__)
[[clang::fallthrough]];
#elif defined(__GNUC__) && __GNUC__ >= 7
[[gnu::fallthrough]];
#endif
default: default:
ret = parseDecimal(in, 1); ret = parseDecimal(in, 1);
break; break;

View File

@ -16,6 +16,7 @@
#include <wmmintrin.h> #include <wmmintrin.h>
#endif #endif
#include "util/coding.h" #include "util/coding.h"
#include "util/util.h"
#ifdef __powerpc64__ #ifdef __powerpc64__
#include "util/crc32c_ppc.h" #include "util/crc32c_ppc.h"
@ -704,386 +705,386 @@ uint32_t crc32c_3way(uint32_t crc, const char* buf, size_t len) {
do { do {
// jumps here for a full block of len 128 // jumps here for a full block of len 128
CRCtriplet(crc, next, -128); CRCtriplet(crc, next, -128);
// FALLTHRU FALLTHROUGH_INTENDED;
case 127: case 127:
// jumps here or below for the first block smaller // jumps here or below for the first block smaller
CRCtriplet(crc, next, -127); CRCtriplet(crc, next, -127);
// FALLTHRU FALLTHROUGH_INTENDED;
case 126: case 126:
CRCtriplet(crc, next, -126); // than 128 CRCtriplet(crc, next, -126); // than 128
// FALLTHRU FALLTHROUGH_INTENDED;
case 125: case 125:
CRCtriplet(crc, next, -125); CRCtriplet(crc, next, -125);
// FALLTHRU FALLTHROUGH_INTENDED;
case 124: case 124:
CRCtriplet(crc, next, -124); CRCtriplet(crc, next, -124);
// FALLTHRU FALLTHROUGH_INTENDED;
case 123: case 123:
CRCtriplet(crc, next, -123); CRCtriplet(crc, next, -123);
// FALLTHRU FALLTHROUGH_INTENDED;
case 122: case 122:
CRCtriplet(crc, next, -122); CRCtriplet(crc, next, -122);
// FALLTHRU FALLTHROUGH_INTENDED;
case 121: case 121:
CRCtriplet(crc, next, -121); CRCtriplet(crc, next, -121);
// FALLTHRU FALLTHROUGH_INTENDED;
case 120: case 120:
CRCtriplet(crc, next, -120); CRCtriplet(crc, next, -120);
// FALLTHRU FALLTHROUGH_INTENDED;
case 119: case 119:
CRCtriplet(crc, next, -119); CRCtriplet(crc, next, -119);
// FALLTHRU FALLTHROUGH_INTENDED;
case 118: case 118:
CRCtriplet(crc, next, -118); CRCtriplet(crc, next, -118);
// FALLTHRU FALLTHROUGH_INTENDED;
case 117: case 117:
CRCtriplet(crc, next, -117); CRCtriplet(crc, next, -117);
// FALLTHRU FALLTHROUGH_INTENDED;
case 116: case 116:
CRCtriplet(crc, next, -116); CRCtriplet(crc, next, -116);
// FALLTHRU FALLTHROUGH_INTENDED;
case 115: case 115:
CRCtriplet(crc, next, -115); CRCtriplet(crc, next, -115);
// FALLTHRU FALLTHROUGH_INTENDED;
case 114: case 114:
CRCtriplet(crc, next, -114); CRCtriplet(crc, next, -114);
// FALLTHRU FALLTHROUGH_INTENDED;
case 113: case 113:
CRCtriplet(crc, next, -113); CRCtriplet(crc, next, -113);
// FALLTHRU FALLTHROUGH_INTENDED;
case 112: case 112:
CRCtriplet(crc, next, -112); CRCtriplet(crc, next, -112);
// FALLTHRU FALLTHROUGH_INTENDED;
case 111: case 111:
CRCtriplet(crc, next, -111); CRCtriplet(crc, next, -111);
// FALLTHRU FALLTHROUGH_INTENDED;
case 110: case 110:
CRCtriplet(crc, next, -110); CRCtriplet(crc, next, -110);
// FALLTHRU FALLTHROUGH_INTENDED;
case 109: case 109:
CRCtriplet(crc, next, -109); CRCtriplet(crc, next, -109);
// FALLTHRU FALLTHROUGH_INTENDED;
case 108: case 108:
CRCtriplet(crc, next, -108); CRCtriplet(crc, next, -108);
// FALLTHRU FALLTHROUGH_INTENDED;
case 107: case 107:
CRCtriplet(crc, next, -107); CRCtriplet(crc, next, -107);
// FALLTHRU FALLTHROUGH_INTENDED;
case 106: case 106:
CRCtriplet(crc, next, -106); CRCtriplet(crc, next, -106);
// FALLTHRU FALLTHROUGH_INTENDED;
case 105: case 105:
CRCtriplet(crc, next, -105); CRCtriplet(crc, next, -105);
// FALLTHRU FALLTHROUGH_INTENDED;
case 104: case 104:
CRCtriplet(crc, next, -104); CRCtriplet(crc, next, -104);
// FALLTHRU FALLTHROUGH_INTENDED;
case 103: case 103:
CRCtriplet(crc, next, -103); CRCtriplet(crc, next, -103);
// FALLTHRU FALLTHROUGH_INTENDED;
case 102: case 102:
CRCtriplet(crc, next, -102); CRCtriplet(crc, next, -102);
// FALLTHRU FALLTHROUGH_INTENDED;
case 101: case 101:
CRCtriplet(crc, next, -101); CRCtriplet(crc, next, -101);
// FALLTHRU FALLTHROUGH_INTENDED;
case 100: case 100:
CRCtriplet(crc, next, -100); CRCtriplet(crc, next, -100);
// FALLTHRU FALLTHROUGH_INTENDED;
case 99: case 99:
CRCtriplet(crc, next, -99); CRCtriplet(crc, next, -99);
// FALLTHRU FALLTHROUGH_INTENDED;
case 98: case 98:
CRCtriplet(crc, next, -98); CRCtriplet(crc, next, -98);
// FALLTHRU FALLTHROUGH_INTENDED;
case 97: case 97:
CRCtriplet(crc, next, -97); CRCtriplet(crc, next, -97);
// FALLTHRU FALLTHROUGH_INTENDED;
case 96: case 96:
CRCtriplet(crc, next, -96); CRCtriplet(crc, next, -96);
// FALLTHRU FALLTHROUGH_INTENDED;
case 95: case 95:
CRCtriplet(crc, next, -95); CRCtriplet(crc, next, -95);
// FALLTHRU FALLTHROUGH_INTENDED;
case 94: case 94:
CRCtriplet(crc, next, -94); CRCtriplet(crc, next, -94);
// FALLTHRU FALLTHROUGH_INTENDED;
case 93: case 93:
CRCtriplet(crc, next, -93); CRCtriplet(crc, next, -93);
// FALLTHRU FALLTHROUGH_INTENDED;
case 92: case 92:
CRCtriplet(crc, next, -92); CRCtriplet(crc, next, -92);
// FALLTHRU FALLTHROUGH_INTENDED;
case 91: case 91:
CRCtriplet(crc, next, -91); CRCtriplet(crc, next, -91);
// FALLTHRU FALLTHROUGH_INTENDED;
case 90: case 90:
CRCtriplet(crc, next, -90); CRCtriplet(crc, next, -90);
// FALLTHRU FALLTHROUGH_INTENDED;
case 89: case 89:
CRCtriplet(crc, next, -89); CRCtriplet(crc, next, -89);
// FALLTHRU FALLTHROUGH_INTENDED;
case 88: case 88:
CRCtriplet(crc, next, -88); CRCtriplet(crc, next, -88);
// FALLTHRU FALLTHROUGH_INTENDED;
case 87: case 87:
CRCtriplet(crc, next, -87); CRCtriplet(crc, next, -87);
// FALLTHRU FALLTHROUGH_INTENDED;
case 86: case 86:
CRCtriplet(crc, next, -86); CRCtriplet(crc, next, -86);
// FALLTHRU FALLTHROUGH_INTENDED;
case 85: case 85:
CRCtriplet(crc, next, -85); CRCtriplet(crc, next, -85);
// FALLTHRU FALLTHROUGH_INTENDED;
case 84: case 84:
CRCtriplet(crc, next, -84); CRCtriplet(crc, next, -84);
// FALLTHRU FALLTHROUGH_INTENDED;
case 83: case 83:
CRCtriplet(crc, next, -83); CRCtriplet(crc, next, -83);
// FALLTHRU FALLTHROUGH_INTENDED;
case 82: case 82:
CRCtriplet(crc, next, -82); CRCtriplet(crc, next, -82);
// FALLTHRU FALLTHROUGH_INTENDED;
case 81: case 81:
CRCtriplet(crc, next, -81); CRCtriplet(crc, next, -81);
// FALLTHRU FALLTHROUGH_INTENDED;
case 80: case 80:
CRCtriplet(crc, next, -80); CRCtriplet(crc, next, -80);
// FALLTHRU FALLTHROUGH_INTENDED;
case 79: case 79:
CRCtriplet(crc, next, -79); CRCtriplet(crc, next, -79);
// FALLTHRU FALLTHROUGH_INTENDED;
case 78: case 78:
CRCtriplet(crc, next, -78); CRCtriplet(crc, next, -78);
// FALLTHRU FALLTHROUGH_INTENDED;
case 77: case 77:
CRCtriplet(crc, next, -77); CRCtriplet(crc, next, -77);
// FALLTHRU FALLTHROUGH_INTENDED;
case 76: case 76:
CRCtriplet(crc, next, -76); CRCtriplet(crc, next, -76);
// FALLTHRU FALLTHROUGH_INTENDED;
case 75: case 75:
CRCtriplet(crc, next, -75); CRCtriplet(crc, next, -75);
// FALLTHRU FALLTHROUGH_INTENDED;
case 74: case 74:
CRCtriplet(crc, next, -74); CRCtriplet(crc, next, -74);
// FALLTHRU FALLTHROUGH_INTENDED;
case 73: case 73:
CRCtriplet(crc, next, -73); CRCtriplet(crc, next, -73);
// FALLTHRU FALLTHROUGH_INTENDED;
case 72: case 72:
CRCtriplet(crc, next, -72); CRCtriplet(crc, next, -72);
// FALLTHRU FALLTHROUGH_INTENDED;
case 71: case 71:
CRCtriplet(crc, next, -71); CRCtriplet(crc, next, -71);
// FALLTHRU FALLTHROUGH_INTENDED;
case 70: case 70:
CRCtriplet(crc, next, -70); CRCtriplet(crc, next, -70);
// FALLTHRU FALLTHROUGH_INTENDED;
case 69: case 69:
CRCtriplet(crc, next, -69); CRCtriplet(crc, next, -69);
// FALLTHRU FALLTHROUGH_INTENDED;
case 68: case 68:
CRCtriplet(crc, next, -68); CRCtriplet(crc, next, -68);
// FALLTHRU FALLTHROUGH_INTENDED;
case 67: case 67:
CRCtriplet(crc, next, -67); CRCtriplet(crc, next, -67);
// FALLTHRU FALLTHROUGH_INTENDED;
case 66: case 66:
CRCtriplet(crc, next, -66); CRCtriplet(crc, next, -66);
// FALLTHRU FALLTHROUGH_INTENDED;
case 65: case 65:
CRCtriplet(crc, next, -65); CRCtriplet(crc, next, -65);
// FALLTHRU FALLTHROUGH_INTENDED;
case 64: case 64:
CRCtriplet(crc, next, -64); CRCtriplet(crc, next, -64);
// FALLTHRU FALLTHROUGH_INTENDED;
case 63: case 63:
CRCtriplet(crc, next, -63); CRCtriplet(crc, next, -63);
// FALLTHRU FALLTHROUGH_INTENDED;
case 62: case 62:
CRCtriplet(crc, next, -62); CRCtriplet(crc, next, -62);
// FALLTHRU FALLTHROUGH_INTENDED;
case 61: case 61:
CRCtriplet(crc, next, -61); CRCtriplet(crc, next, -61);
// FALLTHRU FALLTHROUGH_INTENDED;
case 60: case 60:
CRCtriplet(crc, next, -60); CRCtriplet(crc, next, -60);
// FALLTHRU FALLTHROUGH_INTENDED;
case 59: case 59:
CRCtriplet(crc, next, -59); CRCtriplet(crc, next, -59);
// FALLTHRU FALLTHROUGH_INTENDED;
case 58: case 58:
CRCtriplet(crc, next, -58); CRCtriplet(crc, next, -58);
// FALLTHRU FALLTHROUGH_INTENDED;
case 57: case 57:
CRCtriplet(crc, next, -57); CRCtriplet(crc, next, -57);
// FALLTHRU FALLTHROUGH_INTENDED;
case 56: case 56:
CRCtriplet(crc, next, -56); CRCtriplet(crc, next, -56);
// FALLTHRU FALLTHROUGH_INTENDED;
case 55: case 55:
CRCtriplet(crc, next, -55); CRCtriplet(crc, next, -55);
// FALLTHRU FALLTHROUGH_INTENDED;
case 54: case 54:
CRCtriplet(crc, next, -54); CRCtriplet(crc, next, -54);
// FALLTHRU FALLTHROUGH_INTENDED;
case 53: case 53:
CRCtriplet(crc, next, -53); CRCtriplet(crc, next, -53);
// FALLTHRU FALLTHROUGH_INTENDED;
case 52: case 52:
CRCtriplet(crc, next, -52); CRCtriplet(crc, next, -52);
// FALLTHRU FALLTHROUGH_INTENDED;
case 51: case 51:
CRCtriplet(crc, next, -51); CRCtriplet(crc, next, -51);
// FALLTHRU FALLTHROUGH_INTENDED;
case 50: case 50:
CRCtriplet(crc, next, -50); CRCtriplet(crc, next, -50);
// FALLTHRU FALLTHROUGH_INTENDED;
case 49: case 49:
CRCtriplet(crc, next, -49); CRCtriplet(crc, next, -49);
// FALLTHRU FALLTHROUGH_INTENDED;
case 48: case 48:
CRCtriplet(crc, next, -48); CRCtriplet(crc, next, -48);
// FALLTHRU FALLTHROUGH_INTENDED;
case 47: case 47:
CRCtriplet(crc, next, -47); CRCtriplet(crc, next, -47);
// FALLTHRU FALLTHROUGH_INTENDED;
case 46: case 46:
CRCtriplet(crc, next, -46); CRCtriplet(crc, next, -46);
// FALLTHRU FALLTHROUGH_INTENDED;
case 45: case 45:
CRCtriplet(crc, next, -45); CRCtriplet(crc, next, -45);
// FALLTHRU FALLTHROUGH_INTENDED;
case 44: case 44:
CRCtriplet(crc, next, -44); CRCtriplet(crc, next, -44);
// FALLTHRU FALLTHROUGH_INTENDED;
case 43: case 43:
CRCtriplet(crc, next, -43); CRCtriplet(crc, next, -43);
// FALLTHRU FALLTHROUGH_INTENDED;
case 42: case 42:
CRCtriplet(crc, next, -42); CRCtriplet(crc, next, -42);
// FALLTHRU FALLTHROUGH_INTENDED;
case 41: case 41:
CRCtriplet(crc, next, -41); CRCtriplet(crc, next, -41);
// FALLTHRU FALLTHROUGH_INTENDED;
case 40: case 40:
CRCtriplet(crc, next, -40); CRCtriplet(crc, next, -40);
// FALLTHRU FALLTHROUGH_INTENDED;
case 39: case 39:
CRCtriplet(crc, next, -39); CRCtriplet(crc, next, -39);
// FALLTHRU FALLTHROUGH_INTENDED;
case 38: case 38:
CRCtriplet(crc, next, -38); CRCtriplet(crc, next, -38);
// FALLTHRU FALLTHROUGH_INTENDED;
case 37: case 37:
CRCtriplet(crc, next, -37); CRCtriplet(crc, next, -37);
// FALLTHRU FALLTHROUGH_INTENDED;
case 36: case 36:
CRCtriplet(crc, next, -36); CRCtriplet(crc, next, -36);
// FALLTHRU FALLTHROUGH_INTENDED;
case 35: case 35:
CRCtriplet(crc, next, -35); CRCtriplet(crc, next, -35);
// FALLTHRU FALLTHROUGH_INTENDED;
case 34: case 34:
CRCtriplet(crc, next, -34); CRCtriplet(crc, next, -34);
// FALLTHRU FALLTHROUGH_INTENDED;
case 33: case 33:
CRCtriplet(crc, next, -33); CRCtriplet(crc, next, -33);
// FALLTHRU FALLTHROUGH_INTENDED;
case 32: case 32:
CRCtriplet(crc, next, -32); CRCtriplet(crc, next, -32);
// FALLTHRU FALLTHROUGH_INTENDED;
case 31: case 31:
CRCtriplet(crc, next, -31); CRCtriplet(crc, next, -31);
// FALLTHRU FALLTHROUGH_INTENDED;
case 30: case 30:
CRCtriplet(crc, next, -30); CRCtriplet(crc, next, -30);
// FALLTHRU FALLTHROUGH_INTENDED;
case 29: case 29:
CRCtriplet(crc, next, -29); CRCtriplet(crc, next, -29);
// FALLTHRU FALLTHROUGH_INTENDED;
case 28: case 28:
CRCtriplet(crc, next, -28); CRCtriplet(crc, next, -28);
// FALLTHRU FALLTHROUGH_INTENDED;
case 27: case 27:
CRCtriplet(crc, next, -27); CRCtriplet(crc, next, -27);
// FALLTHRU FALLTHROUGH_INTENDED;
case 26: case 26:
CRCtriplet(crc, next, -26); CRCtriplet(crc, next, -26);
// FALLTHRU FALLTHROUGH_INTENDED;
case 25: case 25:
CRCtriplet(crc, next, -25); CRCtriplet(crc, next, -25);
// FALLTHRU FALLTHROUGH_INTENDED;
case 24: case 24:
CRCtriplet(crc, next, -24); CRCtriplet(crc, next, -24);
// FALLTHRU FALLTHROUGH_INTENDED;
case 23: case 23:
CRCtriplet(crc, next, -23); CRCtriplet(crc, next, -23);
// FALLTHRU FALLTHROUGH_INTENDED;
case 22: case 22:
CRCtriplet(crc, next, -22); CRCtriplet(crc, next, -22);
// FALLTHRU FALLTHROUGH_INTENDED;
case 21: case 21:
CRCtriplet(crc, next, -21); CRCtriplet(crc, next, -21);
// FALLTHRU FALLTHROUGH_INTENDED;
case 20: case 20:
CRCtriplet(crc, next, -20); CRCtriplet(crc, next, -20);
// FALLTHRU FALLTHROUGH_INTENDED;
case 19: case 19:
CRCtriplet(crc, next, -19); CRCtriplet(crc, next, -19);
// FALLTHRU FALLTHROUGH_INTENDED;
case 18: case 18:
CRCtriplet(crc, next, -18); CRCtriplet(crc, next, -18);
// FALLTHRU FALLTHROUGH_INTENDED;
case 17: case 17:
CRCtriplet(crc, next, -17); CRCtriplet(crc, next, -17);
// FALLTHRU FALLTHROUGH_INTENDED;
case 16: case 16:
CRCtriplet(crc, next, -16); CRCtriplet(crc, next, -16);
// FALLTHRU FALLTHROUGH_INTENDED;
case 15: case 15:
CRCtriplet(crc, next, -15); CRCtriplet(crc, next, -15);
// FALLTHRU FALLTHROUGH_INTENDED;
case 14: case 14:
CRCtriplet(crc, next, -14); CRCtriplet(crc, next, -14);
// FALLTHRU FALLTHROUGH_INTENDED;
case 13: case 13:
CRCtriplet(crc, next, -13); CRCtriplet(crc, next, -13);
// FALLTHRU FALLTHROUGH_INTENDED;
case 12: case 12:
CRCtriplet(crc, next, -12); CRCtriplet(crc, next, -12);
// FALLTHRU FALLTHROUGH_INTENDED;
case 11: case 11:
CRCtriplet(crc, next, -11); CRCtriplet(crc, next, -11);
// FALLTHRU FALLTHROUGH_INTENDED;
case 10: case 10:
CRCtriplet(crc, next, -10); CRCtriplet(crc, next, -10);
// FALLTHRU FALLTHROUGH_INTENDED;
case 9: case 9:
CRCtriplet(crc, next, -9); CRCtriplet(crc, next, -9);
// FALLTHRU FALLTHROUGH_INTENDED;
case 8: case 8:
CRCtriplet(crc, next, -8); CRCtriplet(crc, next, -8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 7: case 7:
CRCtriplet(crc, next, -7); CRCtriplet(crc, next, -7);
// FALLTHRU FALLTHROUGH_INTENDED;
case 6: case 6:
CRCtriplet(crc, next, -6); CRCtriplet(crc, next, -6);
// FALLTHRU FALLTHROUGH_INTENDED;
case 5: case 5:
CRCtriplet(crc, next, -5); CRCtriplet(crc, next, -5);
// FALLTHRU FALLTHROUGH_INTENDED;
case 4: case 4:
CRCtriplet(crc, next, -4); CRCtriplet(crc, next, -4);
// FALLTHRU FALLTHROUGH_INTENDED;
case 3: case 3:
CRCtriplet(crc, next, -3); CRCtriplet(crc, next, -3);
// FALLTHRU FALLTHROUGH_INTENDED;
case 2: case 2:
CRCtriplet(crc, next, -2); CRCtriplet(crc, next, -2);
// FALLTHRU FALLTHROUGH_INTENDED;
case 1: case 1:
CRCduplet(crc, next, -1); // the final triplet is actually only 2 CRCduplet(crc, next, -1); // the final triplet is actually only 2
//{ CombineCRC(); } //{ CombineCRC(); }
@ -1096,7 +1097,7 @@ uint32_t crc32c_3way(uint32_t crc, const char* buf, size_t len) {
next1 = next0 + 128; // from here on all blocks are 128 long next1 = next0 + 128; // from here on all blocks are 128 long
next2 = next1 + 128; next2 = next1 + 128;
} }
// FALLTHRU FALLTHROUGH_INTENDED;
case 0:; case 0:;
} while (n > 0); } while (n > 0);
} }
@ -1108,85 +1109,85 @@ uint32_t crc32c_3way(uint32_t crc, const char* buf, size_t len) {
switch (count2) { switch (count2) {
case 27: case 27:
CRCsinglet(crc0, next, -27 * 8); CRCsinglet(crc0, next, -27 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 26: case 26:
CRCsinglet(crc0, next, -26 * 8); CRCsinglet(crc0, next, -26 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 25: case 25:
CRCsinglet(crc0, next, -25 * 8); CRCsinglet(crc0, next, -25 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 24: case 24:
CRCsinglet(crc0, next, -24 * 8); CRCsinglet(crc0, next, -24 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 23: case 23:
CRCsinglet(crc0, next, -23 * 8); CRCsinglet(crc0, next, -23 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 22: case 22:
CRCsinglet(crc0, next, -22 * 8); CRCsinglet(crc0, next, -22 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 21: case 21:
CRCsinglet(crc0, next, -21 * 8); CRCsinglet(crc0, next, -21 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 20: case 20:
CRCsinglet(crc0, next, -20 * 8); CRCsinglet(crc0, next, -20 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 19: case 19:
CRCsinglet(crc0, next, -19 * 8); CRCsinglet(crc0, next, -19 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 18: case 18:
CRCsinglet(crc0, next, -18 * 8); CRCsinglet(crc0, next, -18 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 17: case 17:
CRCsinglet(crc0, next, -17 * 8); CRCsinglet(crc0, next, -17 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 16: case 16:
CRCsinglet(crc0, next, -16 * 8); CRCsinglet(crc0, next, -16 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 15: case 15:
CRCsinglet(crc0, next, -15 * 8); CRCsinglet(crc0, next, -15 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 14: case 14:
CRCsinglet(crc0, next, -14 * 8); CRCsinglet(crc0, next, -14 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 13: case 13:
CRCsinglet(crc0, next, -13 * 8); CRCsinglet(crc0, next, -13 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 12: case 12:
CRCsinglet(crc0, next, -12 * 8); CRCsinglet(crc0, next, -12 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 11: case 11:
CRCsinglet(crc0, next, -11 * 8); CRCsinglet(crc0, next, -11 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 10: case 10:
CRCsinglet(crc0, next, -10 * 8); CRCsinglet(crc0, next, -10 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 9: case 9:
CRCsinglet(crc0, next, -9 * 8); CRCsinglet(crc0, next, -9 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 8: case 8:
CRCsinglet(crc0, next, -8 * 8); CRCsinglet(crc0, next, -8 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 7: case 7:
CRCsinglet(crc0, next, -7 * 8); CRCsinglet(crc0, next, -7 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 6: case 6:
CRCsinglet(crc0, next, -6 * 8); CRCsinglet(crc0, next, -6 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 5: case 5:
CRCsinglet(crc0, next, -5 * 8); CRCsinglet(crc0, next, -5 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 4: case 4:
CRCsinglet(crc0, next, -4 * 8); CRCsinglet(crc0, next, -4 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 3: case 3:
CRCsinglet(crc0, next, -3 * 8); CRCsinglet(crc0, next, -3 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 2: case 2:
CRCsinglet(crc0, next, -2 * 8); CRCsinglet(crc0, next, -2 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 1: case 1:
CRCsinglet(crc0, next, -1 * 8); CRCsinglet(crc0, next, -1 * 8);
// FALLTHRU FALLTHROUGH_INTENDED;
case 0:; case 0:;
} }
} }

View File

@ -10,6 +10,7 @@
#include <string.h> #include <string.h>
#include "util/coding.h" #include "util/coding.h"
#include "util/hash.h" #include "util/hash.h"
#include "util/util.h"
namespace rocksdb { namespace rocksdb {
@ -40,10 +41,10 @@ uint32_t Hash(const char* data, size_t n, uint32_t seed) {
// are unsigned we first cast the char to int8_t. // are unsigned we first cast the char to int8_t.
case 3: case 3:
h += static_cast<uint32_t>(static_cast<int8_t>(data[2])) << 16; h += static_cast<uint32_t>(static_cast<int8_t>(data[2])) << 16;
// fall through FALLTHROUGH_INTENDED;
case 2: case 2:
h += static_cast<uint32_t>(static_cast<int8_t>(data[1])) << 8; h += static_cast<uint32_t>(static_cast<int8_t>(data[1])) << 8;
// fall through FALLTHROUGH_INTENDED;
case 1: case 1:
h += static_cast<uint32_t>(static_cast<int8_t>(data[0])); h += static_cast<uint32_t>(static_cast<int8_t>(data[0]));
h *= m; h *= m;

View File

@ -10,6 +10,7 @@
is under the MIT license. is under the MIT license.
*/ */
#include "murmurhash.h" #include "murmurhash.h"
#include "util/util.h"
#if defined(__x86_64__) #if defined(__x86_64__)
@ -53,12 +54,12 @@ uint64_t MurmurHash64A ( const void * key, int len, unsigned int seed )
switch(len & 7) switch(len & 7)
{ {
case 7: h ^= ((uint64_t)data2[6]) << 48; // fallthrough case 7: h ^= ((uint64_t)data2[6]) << 48; FALLTHROUGH_INTENDED;
case 6: h ^= ((uint64_t)data2[5]) << 40; // fallthrough case 6: h ^= ((uint64_t)data2[5]) << 40; FALLTHROUGH_INTENDED;
case 5: h ^= ((uint64_t)data2[4]) << 32; // fallthrough case 5: h ^= ((uint64_t)data2[4]) << 32; FALLTHROUGH_INTENDED;
case 4: h ^= ((uint64_t)data2[3]) << 24; // fallthrough case 4: h ^= ((uint64_t)data2[3]) << 24; FALLTHROUGH_INTENDED;
case 3: h ^= ((uint64_t)data2[2]) << 16; // fallthrough case 3: h ^= ((uint64_t)data2[2]) << 16; FALLTHROUGH_INTENDED;
case 2: h ^= ((uint64_t)data2[1]) << 8; // fallthrough case 2: h ^= ((uint64_t)data2[1]) << 8; FALLTHROUGH_INTENDED;
case 1: h ^= ((uint64_t)data2[0]); case 1: h ^= ((uint64_t)data2[0]);
h *= m; h *= m;
}; };
@ -120,8 +121,8 @@ unsigned int MurmurHash2 ( const void * key, int len, unsigned int seed )
switch(len) switch(len)
{ {
case 3: h ^= data[2] << 16; // fallthrough case 3: h ^= data[2] << 16; FALLTHROUGH_INTENDED;
case 2: h ^= data[1] << 8; // fallthrough case 2: h ^= data[1] << 8; FALLTHROUGH_INTENDED;
case 1: h ^= data[0]; case 1: h ^= data[0];
h *= m; h *= m;
}; };
@ -174,8 +175,8 @@ unsigned int MurmurHashNeutral2 ( const void * key, int len, unsigned int seed )
switch(len) switch(len)
{ {
case 3: h ^= data[2] << 16; // fallthrough case 3: h ^= data[2] << 16; FALLTHROUGH_INTENDED;
case 2: h ^= data[1] << 8; // fallthrough case 2: h ^= data[1] << 8; FALLTHROUGH_INTENDED;
case 1: h ^= data[0]; case 1: h ^= data[0];
h *= m; h *= m;
}; };

View File

@ -10,17 +10,14 @@
#include "rocksdb/status.h" #include "rocksdb/status.h"
#include <stdio.h> #include <stdio.h>
#include <cstring> #include <cstring>
#include <string.h>
#include "port/port.h" #include "port/port.h"
namespace rocksdb { namespace rocksdb {
const char* Status::CopyState(const char* state) { const char* Status::CopyState(const char* state) {
#ifdef OS_WIN const size_t cch =
return _strdup(state); std::strlen(state) + 1; // +1 for the null terminator
#else return std::strncpy(new char[cch], state, cch);
return strdup(state);
#endif
} }
Status::Status(Code _code, SubCode _subcode, const Slice& msg, const Slice& msg2) Status::Status(Code _code, SubCode _subcode, const Slice& msg, const Slice& msg2)
@ -30,7 +27,7 @@ Status::Status(Code _code, SubCode _subcode, const Slice& msg, const Slice& msg2
const size_t len1 = msg.size(); const size_t len1 = msg.size();
const size_t len2 = msg2.size(); const size_t len2 = msg2.size();
const size_t size = len1 + (len2 ? (2 + len2) : 0); const size_t size = len1 + (len2 ? (2 + len2) : 0);
char* const result = (char*) malloc(size + 1); // +1 for null terminator char* const result = new char[size + 1]; // +1 for null terminator
memcpy(result, msg.data(), len1); memcpy(result, msg.data(), len1);
if (len2) { if (len2) {
result[len1] = ':'; result[len1] = ':';

16
util/util.h Normal file
View File

@ -0,0 +1,16 @@
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// This source code is licensed under both the GPLv2 (found in the
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
#pragma once
#ifndef FALLTHROUGH_INTENDED
#if defined(__clang__)
#define FALLTHROUGH_INTENDED [[clang::fallthrough]]
#elif defined(__GNUC__) && __GNUC__ >= 7
#define FALLTHROUGH_INTENDED [[gnu::fallthrough]]
#else
#define FALLTHROUGH_INTENDED do {} while (0)
#endif
#endif