From a2048f12556094d10312e87519f8f22d0c9f6ed7 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Tue, 30 Aug 2016 17:27:50 +0200 Subject: [PATCH] fix bitshifting --- arangod/VocBase/datafile.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/arangod/VocBase/datafile.cpp b/arangod/VocBase/datafile.cpp index eeaf41c99e..f9f62a8b15 100644 --- a/arangod/VocBase/datafile.cpp +++ b/arangod/VocBase/datafile.cpp @@ -1352,25 +1352,22 @@ bool TRI_datafile_t::check(bool ignoreFailures) { LOG(INFO) << "raw marker data following:"; char const* p = reinterpret_cast(marker); char const* e = reinterpret_cast(marker) + DatafileHelper::AlignedSize(size); + + if (e + 16 < end) { + // add some extra bytes for following data + e += 16; + } + std::string line; std::string raw; size_t printed = 0; while (p < e) { // print offset line.append("0x"); - static const uint64_t BitMasks[] = { - 0xFF00000000000000ULL, - 0x00FF000000000000ULL, - 0x0000FF0000000000ULL, - 0x000000FF00000000ULL, - 0x00000000FF000000ULL, - 0x0000000000FF0000ULL, - 0x000000000000FF00ULL, - 0x00000000000000FFULL - }; + static const uint64_t Bits[] = { 56, 48, 40, 32, 24, 16, 8, 0 }; uint64_t offset = static_cast(static_cast(p - _data)); for (uint64_t i = 0; i < 8; ++i) { - uint8_t c = static_cast(offset & BitMasks[i]); + uint8_t c = static_cast((static_cast(offset) >> Bits[i]) && 0xFFULL); uint8_t n1 = c >> 4; uint8_t n2 = c & 0x0F;