mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:57:43 +00:00
Everywhere: Fix incorrect uses of String::format and StringBuilder::appendf
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
This commit is contained in:
parent
009c753a12
commit
099b83fd28
6 changed files with 13 additions and 13 deletions
|
@ -296,7 +296,7 @@ const MmapRegion* Emulator::find_text_region(FlatPtr address)
|
||||||
|
|
||||||
String Emulator::create_backtrace_line(FlatPtr address)
|
String Emulator::create_backtrace_line(FlatPtr address)
|
||||||
{
|
{
|
||||||
String minimal = String::format("=={%d}== %p", getpid(), address);
|
String minimal = String::format("=={%d}== %p", getpid(), (void*)address);
|
||||||
const auto* region = find_text_region(address);
|
const auto* region = find_text_region(address);
|
||||||
if (!region)
|
if (!region)
|
||||||
return minimal;
|
return minimal;
|
||||||
|
@ -322,11 +322,11 @@ String Emulator::create_backtrace_line(FlatPtr address)
|
||||||
auto& elf = it->value.debug_info->elf();
|
auto& elf = it->value.debug_info->elf();
|
||||||
String symbol = elf.symbolicate(address - region->base());
|
String symbol = elf.symbolicate(address - region->base());
|
||||||
|
|
||||||
auto line_without_source_info = String::format("=={%d}== %p [%s]: %s", getpid(), address, lib_name.characters(), symbol.characters());
|
auto line_without_source_info = String::format("=={%d}== %p [%s]: %s", getpid(), (void*)address, lib_name.characters(), symbol.characters());
|
||||||
|
|
||||||
auto source_position = it->value.debug_info->get_source_position(address - region->base());
|
auto source_position = it->value.debug_info->get_source_position(address - region->base());
|
||||||
if (source_position.has_value())
|
if (source_position.has_value())
|
||||||
return String::format("=={%d}== %p [%s]: %s (\033[34;1m%s\033[0m:%u)", getpid(), address, lib_name.characters(), symbol.characters(), LexicalPath(source_position.value().file_path).basename().characters(), source_position.value().line_number);
|
return String::format("=={%d}== %p [%s]: %s (\033[34;1m%s\033[0m:%zu)", getpid(), (void*)address, lib_name.characters(), symbol.characters(), LexicalPath(source_position.value().file_path).basename().characters(), source_position.value().line_number);
|
||||||
|
|
||||||
return line_without_source_info;
|
return line_without_source_info;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_b
|
||||||
m_timer = add<Core::Timer>();
|
m_timer = add<Core::Timer>();
|
||||||
m_timer->on_timeout = [this] {
|
m_timer->on_timeout = [this] {
|
||||||
++m_time_elapsed;
|
++m_time_elapsed;
|
||||||
m_time_label.set_text(String::format("%u.%u", m_time_elapsed / 10, m_time_elapsed % 10));
|
m_time_label.set_text(String::formatted("{}.{}", m_time_elapsed / 10, m_time_elapsed % 10));
|
||||||
};
|
};
|
||||||
m_timer->set_interval(100);
|
m_timer->set_interval(100);
|
||||||
m_mine_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/mine.png");
|
m_mine_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/mine.png");
|
||||||
|
|
|
@ -407,7 +407,7 @@ void Process::dump_regions()
|
||||||
|
|
||||||
for (auto& sorted_region : sorted_regions) {
|
for (auto& sorted_region : sorted_regions) {
|
||||||
auto& region = *sorted_region;
|
auto& region = *sorted_region;
|
||||||
klog() << String::format("%08x", region.vaddr().get()) << " -- " << String::format("%08x", region.vaddr().offset(region.size() - 1).get()) << " " << String::format("%08x", region.size()) << " " << (region.is_readable() ? 'R' : ' ') << (region.is_writable() ? 'W' : ' ') << (region.is_executable() ? 'X' : ' ') << (region.is_shared() ? 'S' : ' ') << (region.is_stack() ? 'T' : ' ') << (region.vmobject().is_anonymous() ? 'A' : ' ') << " " << region.name().characters();
|
klog() << String::format("%08x", region.vaddr().get()) << " -- " << String::format("%08x", region.vaddr().offset(region.size() - 1).get()) << " " << String::format("%08zx", region.size()) << " " << (region.is_readable() ? 'R' : ' ') << (region.is_writable() ? 'W' : ' ') << (region.is_executable() ? 'X' : ' ') << (region.is_shared() ? 'S' : ' ') << (region.is_stack() ? 'T' : ' ') << (region.vmobject().is_anonymous() ? 'A' : ' ') << " " << region.name().characters();
|
||||||
}
|
}
|
||||||
MM.dump_kernel_regions();
|
MM.dump_kernel_regions();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1000,9 +1000,9 @@ static bool symbolicate(const RecognizedSymbol& symbol, const Process& process,
|
||||||
}
|
}
|
||||||
unsigned offset = symbol.address - symbol.symbol->address;
|
unsigned offset = symbol.address - symbol.symbol->address;
|
||||||
if (symbol.symbol->address == g_highest_kernel_symbol_address && offset > 4096) {
|
if (symbol.symbol->address == g_highest_kernel_symbol_address && offset > 4096) {
|
||||||
builder.appendf("%p\n", mask_kernel_addresses ? 0xdeadc0de : symbol.address);
|
builder.appendf("%p\n", (void*)(mask_kernel_addresses ? 0xdeadc0de : symbol.address));
|
||||||
} else {
|
} else {
|
||||||
builder.appendf("%p %s +%u\n", mask_kernel_addresses ? 0xdeadc0de : symbol.address, demangle(symbol.symbol->name).characters(), offset);
|
builder.appendf("%p %s +%u\n", (void*)(mask_kernel_addresses ? 0xdeadc0de : symbol.address), demangle(symbol.symbol->name).characters(), offset);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ void MemoryManager::parse_memory_map()
|
||||||
|
|
||||||
auto* mmap = (multiboot_memory_map_t*)(low_physical_to_virtual(multiboot_info_ptr->mmap_addr));
|
auto* mmap = (multiboot_memory_map_t*)(low_physical_to_virtual(multiboot_info_ptr->mmap_addr));
|
||||||
for (; (unsigned long)mmap < (low_physical_to_virtual(multiboot_info_ptr->mmap_addr)) + (multiboot_info_ptr->mmap_length); mmap = (multiboot_memory_map_t*)((unsigned long)mmap + mmap->size + sizeof(mmap->size))) {
|
for (; (unsigned long)mmap < (low_physical_to_virtual(multiboot_info_ptr->mmap_addr)) + (multiboot_info_ptr->mmap_length); mmap = (multiboot_memory_map_t*)((unsigned long)mmap + mmap->size + sizeof(mmap->size))) {
|
||||||
klog() << "MM: Multiboot mmap: base_addr = " << String::format("0x%08x", mmap->addr) << ", length = " << String::format("0x%08x", mmap->len) << ", type = 0x" << String::format("%x", mmap->type);
|
klog() << "MM: Multiboot mmap: base_addr = " << String::format("0x%08llx", mmap->addr) << ", length = " << String::format("0x%08llx", mmap->len) << ", type = 0x" << String::format("%x", mmap->type);
|
||||||
if (mmap->type != MULTIBOOT_MEMORY_AVAILABLE)
|
if (mmap->type != MULTIBOOT_MEMORY_AVAILABLE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ void MemoryManager::parse_memory_map()
|
||||||
|
|
||||||
auto diff = (FlatPtr)mmap->addr % PAGE_SIZE;
|
auto diff = (FlatPtr)mmap->addr % PAGE_SIZE;
|
||||||
if (diff != 0) {
|
if (diff != 0) {
|
||||||
klog() << "MM: got an unaligned region base from the bootloader; correcting " << String::format("%p", mmap->addr) << " by " << diff << " bytes";
|
klog() << "MM: got an unaligned region base from the bootloader; correcting " << String::format("%p", (void*)mmap->addr) << " by " << diff << " bytes";
|
||||||
diff = PAGE_SIZE - diff;
|
diff = PAGE_SIZE - diff;
|
||||||
mmap->addr += diff;
|
mmap->addr += diff;
|
||||||
mmap->len -= diff;
|
mmap->len -= diff;
|
||||||
|
@ -883,7 +883,7 @@ void MemoryManager::dump_kernel_regions()
|
||||||
klog() << "BEGIN END SIZE ACCESS NAME";
|
klog() << "BEGIN END SIZE ACCESS NAME";
|
||||||
ScopedSpinLock lock(s_mm_lock);
|
ScopedSpinLock lock(s_mm_lock);
|
||||||
for (auto& region : MM.m_kernel_regions) {
|
for (auto& region : MM.m_kernel_regions) {
|
||||||
klog() << String::format("%08x", region.vaddr().get()) << " -- " << String::format("%08x", region.vaddr().offset(region.size() - 1).get()) << " " << String::format("%08x", region.size()) << " " << (region.is_readable() ? 'R' : ' ') << (region.is_writable() ? 'W' : ' ') << (region.is_executable() ? 'X' : ' ') << (region.is_shared() ? 'S' : ' ') << (region.is_stack() ? 'T' : ' ') << (region.vmobject().is_anonymous() ? 'A' : ' ') << " " << region.name().characters();
|
klog() << String::format("%08x", region.vaddr().get()) << " -- " << String::format("%08x", region.vaddr().offset(region.size() - 1).get()) << " " << String::format("%08zx", region.size()) << " " << (region.is_readable() ? 'R' : ' ') << (region.is_writable() ? 'W' : ' ') << (region.is_executable() ? 'X' : ' ') << (region.is_shared() ? 'S' : ' ') << (region.is_stack() ? 'T' : ' ') << (region.vmobject().is_anonymous() ? 'A' : ' ') << " " << region.name().characters();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ Vector<Command> Node::to_lazy_evaluated_commands(RefPtr<Shell> shell)
|
||||||
|
|
||||||
void Node::dump(int level) const
|
void Node::dump(int level) const
|
||||||
{
|
{
|
||||||
print_indented(String::format("%s at %d:%d (from %d.%d to %d.%d)",
|
print_indented(String::formatted("{} at {}:{} (from {}.{} to {}.{})",
|
||||||
class_name().characters(),
|
class_name().characters(),
|
||||||
m_position.start_offset,
|
m_position.start_offset,
|
||||||
m_position.end_offset,
|
m_position.end_offset,
|
||||||
|
@ -1591,9 +1591,9 @@ Join::~Join()
|
||||||
void MatchExpr::dump(int level) const
|
void MatchExpr::dump(int level) const
|
||||||
{
|
{
|
||||||
Node::dump(level);
|
Node::dump(level);
|
||||||
print_indented(String::format("(expression)", m_expr_name.characters()), level + 1);
|
print_indented(String::formatted("(expression: {})", m_expr_name.characters()), level + 1);
|
||||||
m_matched_expr->dump(level + 2);
|
m_matched_expr->dump(level + 2);
|
||||||
print_indented(String::format("(named: %s)", m_expr_name.characters()), level + 1);
|
print_indented(String::formatted("(named: {})", m_expr_name.characters()), level + 1);
|
||||||
print_indented("(entries)", level + 1);
|
print_indented("(entries)", level + 1);
|
||||||
for (auto& entry : m_entries) {
|
for (auto& entry : m_entries) {
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue