From 8d0563380db8f3412de1fabf5ad74ccde1159eac Mon Sep 17 00:00:00 2001 From: Visual Ehrmanntraut Date: Fri, 27 Jun 2025 12:16:04 +0300 Subject: Improve type safety of new logging system and its handling of varargs - Replaced loglevel arguments and globals using the `int` type with the `loglevel` enum. - Moved logging print func handler function declaration to typedef. - Fixed misuse of `print_func` where a char* was passed in place of `va_list` via a wrapper function `print_funcf`. - Fixed reuse of varargs in `logger` causing a segfault when `stderr_enabled` is true. - Fixed length in `snprintf` call inside `logger_hex_dump` truncating the printed text. --- src/idevicerestore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/idevicerestore.c') diff --git a/src/idevicerestore.c b/src/idevicerestore.c index 3dd4bb9..f4ced47 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -1744,7 +1744,7 @@ static void plain_progress_func(struct progress_info_entry** progress_info, int } } -static void tty_print(int level, const char* format, va_list varglist) +static void tty_print(enum loglevel level, const char* fmt, va_list ap) { switch (level) { case 0: @@ -1760,7 +1760,7 @@ static void tty_print(int level, const char* format, va_list varglist) break; } - cvfprintf(stdout, format, varglist); + cvfprintf(stdout, fmt, ap); cprintf(COLOR_RESET); } -- cgit v1.1-32-gdbae