From 653cec55ab2ceab03153ca0d9c357a215c8205ef Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 12 Apr 2023 12:22:43 +0200 Subject: [PATCH] log_vprintf: return void instead of int The returned value was actually incorrect (counting also formatting escape sequences and terminating nul byte). Since the return value should not be important for the caller, it is perhaps better not to complicate and don't return anything. --- src/debug.cpp | 7 ++----- src/debug.h | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/debug.cpp b/src/debug.cpp index fe1d90e25..83d04f86b 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -86,12 +86,12 @@ static void _dprintf(const char *format, ...) #endif /* WIN32 */ } -int log_vprintf(int level, const char *format, va_list ap) +void log_vprintf(int level, const char *format, va_list ap) { va_list aq; if (log_level < level) { - return 0; + return; } // get number of required bytes @@ -122,9 +122,7 @@ int log_vprintf(int level, const char *format, va_list ap) } else { prune_ansi_sequences_inplace(buf.get()); } - int ret = buf.get().size(); buf.submit(); - return ret; } void log_msg(int level, const char *format, ...) { @@ -132,7 +130,6 @@ void log_msg(int level, const char *format, ...) { va_start(ap, format); log_vprintf(level, format, ap); va_end(ap); - } void log_msg_once(int level, uint32_t id, const char *msg, ...) { diff --git a/src/debug.h b/src/debug.h index 297cdc417..f265b9920 100644 --- a/src/debug.h +++ b/src/debug.h @@ -92,7 +92,7 @@ void debug_file_dump(const char *key, void (*serialize)(const void *data, FILE * ///#define debug_msg(...) log_msg(LOG_LEVEL_DEBUG, "[pid/%d +%d %s] ", getpid(), __LINE__, __FILE__), log_msg(LOG_LEVEL_DEBUG, __VA_ARGS__) #define debug_msg(...) log_msg(LOG_LEVEL_DEBUG, __VA_ARGS__) void log_msg(int log_level, const char *format, ...) ATTRIBUTE(format (printf, 2, 3)); -int log_vprintf(int level, const char *format, va_list ap); +void log_vprintf(int level, const char *format, va_list ap); void log_msg_once(int log_level, uint32_t id, const char *msg, ...) ATTRIBUTE(format (printf, 3, 4));; void log_perror(int log_level, const char *msg);