Fix various compiler warnings and remove unused test
Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1963
This commit is contained in:
parent
026c796e06
commit
45f2a06a8b
src
communication/bolt/v1/decoder
data_structures/concurrent
query
storage/common/types
utils
tests/manual
@ -213,8 +213,7 @@ class Decoder {
|
||||
return false;
|
||||
}
|
||||
value = utils::Bswap(value);
|
||||
// cppcheck-suppress invalidPointerCast
|
||||
ret = *reinterpret_cast<double *>(&value);
|
||||
ret = utils::MemcpyCast<double>(value);
|
||||
*data = Value(ret);
|
||||
return true;
|
||||
}
|
||||
|
@ -769,7 +769,7 @@ class SkipList : private utils::Lockable<lock_t> {
|
||||
*/
|
||||
template <class It, class K>
|
||||
It find_or_larger(const K &item) const {
|
||||
Node *node, *pred = header;
|
||||
Node *node = nullptr, *pred = header;
|
||||
int h = static_cast<int>(pred->height) - 1;
|
||||
|
||||
while (true) {
|
||||
|
@ -380,7 +380,7 @@ void Load(query::TypedValueVectorCompare *comparator, slk::Reader *reader) {
|
||||
|
||||
|
||||
void Save(const query::GraphView &graph_view, slk::Builder *builder) {
|
||||
uint8_t enum_value;
|
||||
uint8_t enum_value = 0;
|
||||
switch (graph_view) {
|
||||
case query::GraphView::OLD:
|
||||
enum_value = 0;
|
||||
|
@ -36,8 +36,8 @@ class Label final {
|
||||
}
|
||||
|
||||
IdT Id() const { return static_cast<IdT>(id_ & IdMask); }
|
||||
Location Location() const {
|
||||
return static_cast<enum Location>(id_ & IdNotMask);
|
||||
storage::Location Location() const {
|
||||
return static_cast<storage::Location>(id_ & IdNotMask);
|
||||
}
|
||||
|
||||
friend bool operator==(const Label &a, const Label &b) {
|
||||
@ -78,8 +78,8 @@ class EdgeType final {
|
||||
}
|
||||
|
||||
IdT Id() const { return static_cast<IdT>(id_ & IdMask); }
|
||||
Location Location() const {
|
||||
return static_cast<enum Location>(id_ & IdNotMask);
|
||||
storage::Location Location() const {
|
||||
return static_cast<storage::Location>(id_ & IdNotMask);
|
||||
}
|
||||
|
||||
friend bool operator==(const EdgeType &a, const EdgeType &b) {
|
||||
@ -120,8 +120,8 @@ class Property final {
|
||||
}
|
||||
|
||||
IdT Id() const { return static_cast<IdT>(id_ & IdMask); }
|
||||
Location Location() const {
|
||||
return static_cast<enum Location>(id_ & IdNotMask);
|
||||
storage::Location Location() const {
|
||||
return static_cast<storage::Location>(id_ & IdNotMask);
|
||||
}
|
||||
|
||||
friend bool operator==(const Property &a, const Property &b) {
|
||||
|
@ -28,8 +28,8 @@ class Executor {
|
||||
scheduler_.Stop();
|
||||
}
|
||||
|
||||
Executor(Executor &&e) = default;
|
||||
Executor &operator=(Executor &&) = default;
|
||||
Executor(Executor &&e) = delete;
|
||||
Executor &operator=(Executor &&) = delete;
|
||||
Executor(const Executor &e) = delete;
|
||||
Executor &operator=(const Executor &) = delete;
|
||||
|
||||
|
@ -46,8 +46,6 @@ endif()
|
||||
add_manual_test(distributed_repl.cpp)
|
||||
target_link_libraries(${test_prefix}distributed_repl mg-distributed kvstore_dummy_lib gtest readline)
|
||||
|
||||
add_manual_test(endinan.cpp)
|
||||
|
||||
add_manual_test(generate_snapshot.cpp)
|
||||
target_link_libraries(${test_prefix}generate_snapshot mg-distributed kvstore_dummy_lib)
|
||||
|
||||
|
@ -1,65 +0,0 @@
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
|
||||
#include <byteswap.h>
|
||||
|
||||
char b[8] = {1, 2, 3, 4, 0, 0, 0, 1};
|
||||
|
||||
int64_t safe_int64(const char* b) {
|
||||
return int64_t(b[0]) << 56 | int64_t(b[1]) << 48 | int64_t(b[2]) << 40 |
|
||||
int64_t(b[3]) << 32 | int64_t(b[4]) << 24 | int64_t(b[5]) << 16 |
|
||||
int64_t(b[6]) << 8 | int64_t(b[7]);
|
||||
}
|
||||
|
||||
int64_t unsafe_int64(const char* b) {
|
||||
auto i = reinterpret_cast<const int64_t*>(b);
|
||||
return __bswap_64(*i);
|
||||
}
|
||||
|
||||
int32_t safe_int32(const char* b) {
|
||||
return b[0] << 24 | b[1] << 16 | b[2] << 8 | b[3];
|
||||
}
|
||||
|
||||
int32_t unsafe_int32(const char* b) {
|
||||
auto i = reinterpret_cast<const int32_t*>(b);
|
||||
return __bswap_32(*i);
|
||||
}
|
||||
|
||||
[[clang::optnone]] void test(uint64_t n) {
|
||||
for (uint64_t i = 0; i < n; ++i) unsafe_int64(b);
|
||||
}
|
||||
|
||||
uint8_t f[8] = {0x3F, 0xF1, 0x99, 0x99, 0x99, 0x99, 0x99, 0x9A};
|
||||
|
||||
double ff = 1.1;
|
||||
|
||||
double get_double(const uint8_t* b) {
|
||||
auto v = __bswap_64(*reinterpret_cast<const uint64_t*>(b));
|
||||
return *reinterpret_cast<const double*>(&v);
|
||||
}
|
||||
|
||||
void print_hex(const char* buf, size_t n) {
|
||||
for (size_t i = 0; i < n; ++i) printf("%02X ", (unsigned char)buf[i]);
|
||||
}
|
||||
|
||||
void print_hex(const uint8_t* buf, size_t n) { print_hex((const char*)buf, n); }
|
||||
|
||||
int main(void) {
|
||||
auto dd = get_double(f);
|
||||
|
||||
print_hex(f, 8);
|
||||
|
||||
std::cout << std::endl;
|
||||
print_hex((const uint8_t*)(&ff), 8);
|
||||
|
||||
std::cout << std::endl;
|
||||
print_hex((const uint8_t*)(&dd), 8);
|
||||
|
||||
std::cout << "dd: " << dd << std::endl;
|
||||
std::cout << "Safe: " << safe_int64(b) << std::endl;
|
||||
std::cout << unsafe_int64(b) << std::endl;
|
||||
|
||||
test(1000000ull);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user