LibC: Fix some incorrect printf usages

This commit is contained in:
Sahan Fernando 2020-12-25 15:15:12 +11:00 committed by Andreas Kling
parent 6b01d1cf14
commit d780e2265d
Notes: sideshowbarker 2024-07-19 00:35:53 +09:00
10 changed files with 19 additions and 19 deletions

View file

@ -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);

View file

@ -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());
}

View file

@ -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;

View file

@ -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);

View file

@ -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)

View file

@ -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);

View file

@ -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<FlatPtr>(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();

View file

@ -32,6 +32,8 @@
#include <ctype.h>
#include <stdio.h>
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
struct Testcase {
const char* dest;
size_t dest_n;

View file

@ -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();
}

View file

@ -30,7 +30,7 @@
#include <string.h>
#include <unistd.h>
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;
}