From 127756a4a1ec0edc010cd15ef8f39addc487fa82 Mon Sep 17 00:00:00 2001 From: Matheus Marchini Date: Mon, 21 Jan 2019 18:16:56 +0000 Subject: [PATCH] src: fix compiler warnings --- src/llscan.cc | 7 +++++-- src/llv8.cc | 17 +++++++---------- src/printer.cc | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/llscan.cc b/src/llscan.cc index a6055c3c..38a1b8c6 100644 --- a/src/llscan.cc +++ b/src/llscan.cc @@ -553,7 +553,8 @@ bool FindReferencesCmd::DoExecute(SBDebugger d, char** cmd, * - Objects that refer to a particular string literal. * (lldb) findreferences -s "Hello World!" */ - case ScanType::kBadOption: { + case ScanType::kBadOption: + default: { result.SetError("Invalid search type"); result.SetStatus(eReturnStatusFailed); return false; @@ -1540,7 +1541,6 @@ inline static ByteOrder GetHostByteOrder() { } void LLScan::ScanMemoryRanges(FindJSObjectsVisitor& v) { - bool done = false; const uint64_t addr_size = process_.GetAddressByteSize(); bool swap_bytes = process_.GetByteOrder() != GetHostByteOrder(); @@ -1550,6 +1550,7 @@ void LLScan::ScanMemoryRanges(FindJSObjectsVisitor& v) { unsigned char* block = new unsigned char[block_size]; #ifndef LLDB_SBMemoryRegionInfoList_h_ + bool done = false; MemoryRange* head = ranges_; while (head != nullptr && !done) { @@ -1614,7 +1615,9 @@ void LLScan::ScanMemoryRanges(FindJSObjectsVisitor& v) { } if (increment == 0) { +#ifndef LLDB_SBMemoryRegionInfoList_h_ done = true; +#endif // LLDB_SBMemoryRegionInfoList_h_ break; } } diff --git a/src/llv8.cc b/src/llv8.cc index d081518d..ad643ea4 100644 --- a/src/llv8.cc +++ b/src/llv8.cc @@ -99,9 +99,9 @@ int64_t LLV8::LoadUnsigned(int64_t addr, uint32_t byte_size, Error& err) { double LLV8::LoadDouble(int64_t addr, Error& err) { SBError sberr; - int64_t value = process_.ReadUnsignedFromMemory(static_cast(addr), - sizeof(double), sberr); - if (sberr.Fail()) { + double value; + size_t result = process_.ReadMemory(static_cast(addr), &value, sizeof(double), sberr); + if (sberr.Fail() || result != sizeof(double)) { err = Error::Failure( "Failed to load double from v8 memory, " "addr=0x%016" PRIx64, @@ -110,7 +110,7 @@ double LLV8::LoadDouble(int64_t addr, Error& err) { } err = Error::Ok(); - return *reinterpret_cast(&value); + return value; } @@ -1108,9 +1108,7 @@ Value JSObject::GetDescriptorProperty(std::string key_name, Map map, if (descriptors.IsConstFieldDetails(details) || descriptors.IsDescriptorDetails(details)) { - Value value; - - value = descriptors.GetValue(i, err); + descriptors.GetValue(i, err); if (err.Fail()) return Value(); continue; @@ -1127,11 +1125,10 @@ Value JSObject::GetDescriptorProperty(std::string key_name, Map map, int64_t index = descriptors.FieldIndex(details) - in_object_count; if (descriptors.IsDoubleField(details)) { - double value; if (index < 0) { - value = GetInObjectValue(instance_size, index, err); + GetInObjectValue(instance_size, index, err); } else { - value = extra_properties.Get(index, err); + extra_properties.Get(index, err); } if (err.Fail()) return Value(); diff --git a/src/printer.cc b/src/printer.cc index c8b9d947..d309c947 100644 --- a/src/printer.cc +++ b/src/printer.cc @@ -615,8 +615,8 @@ std::string Printer::Stringify(v8::JSError js_error, Error& err) { if ((stack_len != 0) || ((arr.GetArrayLength(err) - 1) % multiplier != 0)) { Error::PrintInDebugMode( - "JSArray doesn't look like a Stack Frames array. stack_len: %lld " - "array_len: %lld", + "JSArray doesn't look like a Stack Frames array. stack_len: %ld " + "array_len: %ld", stack_len, arr.GetArrayLength(err)); output << rang::fg::yellow << ">" << rang::fg::reset; return output.str();