diff options
author | Sahan Fernando <sahan.h.fernando@gmail.com> | 2021-01-12 00:30:22 +1100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-11 21:06:32 +0100 |
commit | 099b83fd286dddcc5cf0c766241dd2b1a3098796 (patch) | |
tree | ddd4e749b9e6b977d93f39f0e2ad4b2ca4e0161a | |
parent | 009c753a12d646617be9a6fec9e99cc1e500d5b5 (diff) | |
download | serenity-099b83fd286dddcc5cf0c766241dd2b1a3098796.zip |
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.
-rw-r--r-- | DevTools/UserspaceEmulator/Emulator.cpp | 6 | ||||
-rw-r--r-- | Games/Minesweeper/Field.cpp | 2 | ||||
-rw-r--r-- | Kernel/Process.cpp | 2 | ||||
-rw-r--r-- | Kernel/Thread.cpp | 4 | ||||
-rw-r--r-- | Kernel/VM/MemoryManager.cpp | 6 | ||||
-rw-r--r-- | Shell/AST.cpp | 6 |
6 files changed, 13 insertions, 13 deletions
diff --git a/DevTools/UserspaceEmulator/Emulator.cpp b/DevTools/UserspaceEmulator/Emulator.cpp index 8e3881ac40..c463d24618 100644 --- a/DevTools/UserspaceEmulator/Emulator.cpp +++ b/DevTools/UserspaceEmulator/Emulator.cpp @@ -296,7 +296,7 @@ const MmapRegion* Emulator::find_text_region(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); if (!region) return minimal; @@ -322,11 +322,11 @@ String Emulator::create_backtrace_line(FlatPtr address) auto& elf = it->value.debug_info->elf(); 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()); 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; } diff --git a/Games/Minesweeper/Field.cpp b/Games/Minesweeper/Field.cpp index 75183d1963..351a900094 100644 --- a/Games/Minesweeper/Field.cpp +++ b/Games/Minesweeper/Field.cpp @@ -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->on_timeout = [this] { ++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_mine_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/mine.png"); diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index d080431969..4b3f6357ef 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -407,7 +407,7 @@ void Process::dump_regions() for (auto& sorted_region : sorted_regions) { 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(); } diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 71283101f0..9ba54f4ef5 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -1000,9 +1000,9 @@ static bool symbolicate(const RecognizedSymbol& symbol, const Process& process, } unsigned offset = symbol.address - symbol.symbol->address; 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 { - 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; } diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp index c33c59f647..f7d7298dbd 100644 --- a/Kernel/VM/MemoryManager.cpp +++ b/Kernel/VM/MemoryManager.cpp @@ -132,7 +132,7 @@ void MemoryManager::parse_memory_map() 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))) { - 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) continue; @@ -145,7 +145,7 @@ void MemoryManager::parse_memory_map() auto diff = (FlatPtr)mmap->addr % PAGE_SIZE; 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; mmap->addr += diff; mmap->len -= diff; @@ -883,7 +883,7 @@ void MemoryManager::dump_kernel_regions() klog() << "BEGIN END SIZE ACCESS NAME"; ScopedSpinLock lock(s_mm_lock); 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(); } } diff --git a/Shell/AST.cpp b/Shell/AST.cpp index 11b7ba7ed8..992452f503 100644 --- a/Shell/AST.cpp +++ b/Shell/AST.cpp @@ -211,7 +211,7 @@ Vector<Command> Node::to_lazy_evaluated_commands(RefPtr<Shell> shell) 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(), m_position.start_offset, m_position.end_offset, @@ -1591,9 +1591,9 @@ Join::~Join() void MatchExpr::dump(int level) const { 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); - 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); for (auto& entry : m_entries) { StringBuilder builder; |