diff --git a/Libraries/LibC/malloc.cpp b/Libraries/LibC/malloc.cpp index 2ed388e52bd..37b748d0446 100644 --- a/Libraries/LibC/malloc.cpp +++ b/Libraries/LibC/malloc.cpp @@ -318,7 +318,7 @@ static void free_impl(void* ptr) auto* block = (ChunkedBlock*)block_base; #ifdef MALLOC_DEBUG - dbgprintf("LibC: freeing %p in allocator %p (size=%u, used=%u)\n", ptr, block, block->bytes_per_chunk(), block->used_chunks()); + dbgprintf("LibC: freeing %p in allocator %p (size=%zu, used=%zu)\n", ptr, block, block->bytes_per_chunk(), block->used_chunks()); #endif if (s_scrub_free) @@ -332,7 +332,7 @@ static void free_impl(void* ptr) size_t good_size; auto* allocator = allocator_for_size(block->m_size, good_size); #ifdef MALLOC_DEBUG - dbgprintf("Block %p no longer full in size class %u\n", block, good_size); + dbgprintf("Block %p no longer full in size class %zu\n", block, good_size); #endif g_malloc_stats.number_of_freed_full_blocks++; allocator->full_blocks.remove(block); @@ -346,7 +346,7 @@ static void free_impl(void* ptr) auto* allocator = allocator_for_size(block->m_size, good_size); if (allocator->block_count < number_of_chunked_blocks_to_keep_around_per_size_class) { #ifdef MALLOC_DEBUG - dbgprintf("Keeping block %p around for size class %u\n", block, good_size); + dbgprintf("Keeping block %p around for size class %zu\n", block, good_size); #endif g_malloc_stats.number_of_keeps++; allocator->usable_blocks.remove(block); @@ -356,7 +356,7 @@ static void free_impl(void* ptr) return; } #ifdef MALLOC_DEBUG - dbgprintf("Releasing block %p for size class %u\n", block, good_size); + dbgprintf("Releasing block %p for size class %zu\n", block, good_size); #endif g_malloc_stats.number_of_frees++; allocator->usable_blocks.remove(block); diff --git a/Libraries/LibDiff/Format.cpp b/Libraries/LibDiff/Format.cpp index d1a5711247c..b6ee7d172bb 100644 --- a/Libraries/LibDiff/Format.cpp +++ b/Libraries/LibDiff/Format.cpp @@ -34,7 +34,7 @@ String generate_only_additions(const String& text) { auto lines = text.split('\n', true); // Keep empty StringBuilder builder; - builder.appendf("@@ -1,%u +1,%u @@\n", lines.size()); + builder.appendf("@@ -1,%zu +1,%zu @@\n", lines.size()); for (const auto& line : lines) { builder.appendf("+%s\n", line.characters()); } diff --git a/Libraries/LibGUI/BoxLayout.cpp b/Libraries/LibGUI/BoxLayout.cpp index f4b93b6f85c..10aa0f7932c 100644 --- a/Libraries/LibGUI/BoxLayout.cpp +++ b/Libraries/LibGUI/BoxLayout.cpp @@ -48,7 +48,7 @@ void BoxLayout::run(Widget& widget) should_log = true; #endif if (should_log) - dbgprintf("BoxLayout: running layout on %s{%p}, entry count: %d\n", widget.class_name(), &widget, m_entries.size()); + dbgprintf("BoxLayout: running layout on %s{%p}, entry count: %zu\n", widget.class_name(), &widget, m_entries.size()); if (m_entries.is_empty()) return; @@ -94,7 +94,7 @@ void BoxLayout::run(Widget& widget) available_size -= { margins().left() + margins().right(), margins().top() + margins().bottom() }; if (should_log) - dbgprintf("BoxLayout: Number of visible: %d/%d\n", number_of_visible_entries, m_entries.size()); + dbgprintf("BoxLayout: Number of visible: %d/%zu\n", number_of_visible_entries, m_entries.size()); int number_of_entries_with_automatic_size = number_of_visible_entries - number_of_entries_with_fixed_size; diff --git a/Libraries/LibGfx/ICOLoader.cpp b/Libraries/LibGfx/ICOLoader.cpp index 72fb62663b8..70b842a7f54 100644 --- a/Libraries/LibGfx/ICOLoader.cpp +++ b/Libraries/LibGfx/ICOLoader.cpp @@ -208,7 +208,7 @@ static bool load_ico_directory(ICOLoadingContext& context) return false; } #ifdef ICO_DEBUG - printf("load_ico_directory: index %lu width: %u height: %u offset: %lu size: %lu\n", + printf("load_ico_directory: index %zu width: %u height: %u offset: %lu size: %lu\n", i, desc.width, desc.height, desc.offset, desc.size); #endif context.images.append(desc); diff --git a/Libraries/LibVT/Terminal.cpp b/Libraries/LibVT/Terminal.cpp index afed43f0ade..1943a5bd5c9 100644 --- a/Libraries/LibVT/Terminal.cpp +++ b/Libraries/LibVT/Terminal.cpp @@ -246,7 +246,7 @@ void Terminal::escape$t(const ParamVector& params) { if (params.size() < 1) return; - dbgprintf("FIXME: escape$t: Ps: %u (param count: %d)\n", params[0], params.size()); + dbgprintf("FIXME: escape$t: Ps: %u (param count: %zu)\n", params[0], params.size()); } void Terminal::DECSTBM(const ParamVector& params) diff --git a/Libraries/LibWeb/Dump.cpp b/Libraries/LibWeb/Dump.cpp index 491bb6d3c06..b82ec1243b9 100644 --- a/Libraries/LibWeb/Dump.cpp +++ b/Libraries/LibWeb/Dump.cpp @@ -393,7 +393,7 @@ void dump_rule(const CSS::StyleRule& rule) void dump_sheet(const CSS::StyleSheet& sheet) { - dbgprintf("StyleSheet{%p}: %d rule(s)\n", &sheet, sheet.rules().size()); + dbgprintf("StyleSheet{%p}: %zu rule(s)\n", &sheet, sheet.rules().size()); for (auto& rule : sheet.rules()) { dump_rule(rule); diff --git a/Userland/DynamicLoader/main.cpp b/Userland/DynamicLoader/main.cpp index 10e08a3b959..f5fca108e94 100644 --- a/Userland/DynamicLoader/main.cpp +++ b/Userland/DynamicLoader/main.cpp @@ -188,7 +188,7 @@ static void allocate_tls() { size_t total_tls_size = 0; for (const auto& data : g_loaders) { - VERBOSE("%s: TLS Size: %u\n", data.key.characters(), data.value->tls_size()); + VERBOSE("%s: TLS Size: %zu\n", data.key.characters(), data.value->tls_size()); total_tls_size += data.value->tls_size(); } if (total_tls_size) { @@ -270,7 +270,7 @@ static FlatPtr loader_main(auxv_t* auxvp) VERBOSE("loaded all dependencies"); for ([[maybe_unused]] auto& lib : g_loaders) { - VERBOSE("%s - tls size: %u, tls offset: %u\n", lib.key.characters(), lib.value->tls_size(), lib.value->tls_offset()); + VERBOSE("%s - tls size: %zu, tls offset: %zu\n", lib.key.characters(), lib.value->tls_size(), lib.value->tls_offset()); } allocate_tls(); @@ -283,7 +283,7 @@ static FlatPtr loader_main(auxv_t* auxvp) if (main_program_lib->is_dynamic()) entry_point += reinterpret_cast(main_program_lib->text_segment_load_address().as_ptr()); - VERBOSE("entry point: %p\n", entry_point); + VERBOSE("entry point: %p\n", (void*)entry_point); // This will unmap the temporary memory maps we had for loading the libraries clear_temporary_objects_mappings(); diff --git a/Userland/Tests/LibC/snprintf-correctness.cpp b/Userland/Tests/LibC/snprintf-correctness.cpp index 9f9b43c49da..3089419df32 100644 --- a/Userland/Tests/LibC/snprintf-correctness.cpp +++ b/Userland/Tests/LibC/snprintf-correctness.cpp @@ -32,6 +32,8 @@ #include #include +#pragma GCC diagnostic ignored "-Wformat-nonliteral" + struct Testcase { const char* dest; size_t dest_n; diff --git a/Userland/cal.cpp b/Userland/cal.cpp index e2d2f7ca614..c5b436eb9ce 100644 --- a/Userland/cal.cpp +++ b/Userland/cal.cpp @@ -155,14 +155,12 @@ int main(int argc, char** argv) insert_month_to_print(0, i++, year); insert_month_to_print(1, i++, year); insert_month_to_print(2, i, year); - printf(print_buffer); - printf("\n"); + printf("%s\n", print_buffer); clean_buffers(); } } else { insert_month_to_print(0, month, year); - printf(print_buffer); - printf("\n\n"); + printf("%s\n\n", print_buffer); clean_buffers(); } diff --git a/Userland/seq.cpp b/Userland/seq.cpp index e47d94fe0b2..a7a6ea7c229 100644 --- a/Userland/seq.cpp +++ b/Userland/seq.cpp @@ -30,7 +30,7 @@ #include #include -const char* g_usage = R"(Usage: +const char* const g_usage = R"(Usage: seq [-h|--help] seq LAST seq FIRST LAST @@ -39,7 +39,7 @@ const char* g_usage = R"(Usage: static void print_usage(FILE* stream) { - fprintf(stream, g_usage); + fputs(g_usage, stream); return; }