Skip to content

Commit

Permalink
src: fix warnings
Browse files Browse the repository at this point in the history
Fix various warnings which show up when compiling with gcc. For the most
part this doesn't change any semantics -- the only user-facing change is
a bug fix in `Printer::Stringify` caused by a missing `return`.
  • Loading branch information
kvakil authored and No9 committed Sep 24, 2022
1 parent 8234105 commit 1e111aa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/llscan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ bool FindReferencesCmd::DoExecute(SBDebugger d, char** cmd,
return false;
}

ObjectScanner* scanner;
ObjectScanner* scanner = nullptr;

switch (scan_options.scan_type) {
case ScanOptions::ScanType::kFieldValue: {
Expand Down Expand Up @@ -596,7 +596,7 @@ bool FindReferencesCmd::DoExecute(SBDebugger d, char** cmd,
void FindReferencesCmd::ScanForReferences(ObjectScanner* scanner) {
// Walk all the object instances and handle them according to their type.
TypeRecordMap mapstoinstances = llscan_->GetMapsToInstances();
for (auto const entry : mapstoinstances) {
for (auto const& entry : mapstoinstances) {
TypeRecord* typerecord = entry.second;

for (uint64_t addr : typerecord->GetInstances()) {
Expand Down
11 changes: 6 additions & 5 deletions src/llv8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,22 @@ double LLV8::LoadDouble(int64_t addr, Error& err) {
}


std::string LLV8::LoadBytes(int64_t addr, int64_t length, Error& err) {
std::string LLV8::LoadBytes(int64_t addr, size_t length, Error& err) {
uint8_t* buf = new uint8_t[length + 1];
SBError sberr;
process_.ReadMemory(addr, buf, static_cast<size_t>(length), sberr);
process_.ReadMemory(addr, buf, length, sberr);
if (sberr.Fail()) {
err = Error::Failure(
"Failed to load v8 backing store memory, "
"addr=0x%016" PRIx64 ", length=%" PRId64,
"addr=0x%016" PRIx64 ", length=%zu",
addr, length);
delete[] buf;
return std::string();
}

std::string res;
char tmp[10];
for (int i = 0; i < length; ++i) {
for (size_t i = 0; i < length; ++i) {
snprintf(tmp, sizeof(tmp), "%s%02x", (i == 0 ? "" : ", "), buf[i]);
res += tmp;
}
Expand Down Expand Up @@ -732,7 +732,8 @@ std::string Symbol::ToString(Error& err) {
return "Symbol()";
}
HeapObject name = Name(err);
RETURN_IF_INVALID(name, "Symbol(???)");
// Use \? so we don't treat this as a trigraph.
RETURN_IF_INVALID(name, "Symbol(\?\?\?)");
return "Symbol('" + String(name).ToString(err) + "')";
}

Expand Down
2 changes: 1 addition & 1 deletion src/llv8.h
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ class LLV8 {
inline CheckedType<T> LoadUnsigned(int64_t addr, uint32_t byte_size);
int64_t LoadUnsigned(int64_t addr, uint32_t byte_size, Error& err);
double LoadDouble(int64_t addr, Error& err);
std::string LoadBytes(int64_t addr, int64_t length, Error& err);
std::string LoadBytes(int64_t addr, size_t length, Error& err);
std::string LoadString(int64_t addr, int64_t length, Error& err);
std::string LoadTwoByteString(int64_t addr, int64_t length, Error& err);
uint8_t* LoadChunk(int64_t addr, int64_t length, Error& err);
Expand Down
6 changes: 3 additions & 3 deletions src/printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ std::string Printer::Stringify(v8::JSArrayBuffer js_array_buffer, Error& err) {
} else {
res += " [\n ";

int display_length = std::min<int>(*byte_length, options_.length);
size_t display_length = std::min<size_t>(*byte_length, options_.length);
res += llv8_->LoadBytes(*data, display_length, err);

if (display_length < *byte_length) {
Expand Down Expand Up @@ -430,7 +430,7 @@ std::string Printer::Stringify(v8::JSTypedArray js_typed_array, Error& err) {

res += " [\n ";

int display_length = std::min<int>(*byte_length, options_.length);
size_t display_length = std::min<size_t>(*byte_length, options_.length);
res += llv8_->LoadBytes(*data + *byte_offset, display_length, err);

if (display_length < *byte_length) {
Expand Down Expand Up @@ -511,7 +511,7 @@ std::string Printer::Stringify(v8::Map map, Error& err) {
return std::string(tmp) + ":" +
Stringify<v8::FixedArray>(descriptors, err) + ">";
} else {
std::string(tmp) + ">";
return std::string(tmp) + ">";
}
}

Expand Down

0 comments on commit 1e111aa

Please sign in to comment.