From 8952c193c34b0f1a16a8c11baeb347dce4c5fd38 Mon Sep 17 00:00:00 2001 From: Vincent Barrilliot Date: Sun, 12 Nov 2023 18:30:11 +0100 Subject: [PATCH] Try make logging more stable --- src/log.c | 23 +++++------------------ src/log.h | 18 +++++++++--------- src/m68k/bios_m68k.c | 1 - 3 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/log.c b/src/log.c index e696234..80b20c9 100644 --- a/src/log.c +++ b/src/log.c @@ -293,32 +293,19 @@ static void log_to_channel_A_low_level(const char *message) { * Caveat: * The total length should not exceed 512 chars. */ +#if DEFAULT_LOG_LEVEL >= 0 +static char logbuf[200]; // Should hopefully be long enough ! It's here so we don't require more stack space +#endif void logmsg(short level, const char * message, ...) { if (level > log_level) return; - char buf[80]; // Should hopefully be long enough ! - va_list args; va_start(args, message); - vsprintf(buf, message, args); + vsnprintf(logbuf, sizeof(logbuf), message, args); va_end(args); - do_log(buf); -} - -void trace(const char * message, ...) { - if (LOG_TRACE > log_level) - return; - - char buf[80]; // Should hopefully be long enough ! - - va_list args; - va_start(args, message); - vsprintf(buf, message, args); - va_end(args); - - (*do_log)(buf); + do_log(logbuf); } /* diff --git a/src/log.h b/src/log.h index 09ece8c..6a96584 100644 --- a/src/log.h +++ b/src/log.h @@ -81,7 +81,7 @@ extern void log_setlevel(short level); * message = the message to log */ extern void logmsg(short level, const char * message, ...); -extern void trace(const char * message, ...); + /* * Log a message to the console * @@ -176,14 +176,14 @@ extern void log_c(short log_level, char c); #endif #if DEFAULT_LOG_LEVEL >= LOG_TRACE -# define TRACE(m) trace(m) -# define TRACE1(a,b) trace(a, b) -# define TRACE2(a,b,c) trace(a, b, c) -# define TRACE3(a,b,c,d) trace(a, b, c, d) -# define TRACE4(a,b,c,d,e) trace(a, b, c, d, e) -# define TRACE5(a,b,c,d,e,f) trace(a, b, c, d, e, f) -# define TRACE6(a,b,c,d,e,f,g) trace(a, b, c, d, e, f, g) -# define TRACE7(a,b,c,d,e,f,g,h) trace(a, b, c, d, e, f, g, h) +# define TRACE(m) logmsg(LOG_TRACE, m) +# define TRACE1(a,b) logmsg(LOG_TRACE, a, b) +# define TRACE2(a,b,c) logmsg(LOG_TRACE, a, b, c) +# define TRACE3(a,b,c,d) logmsg(LOG_TRACE, a, b, c, d) +# define TRACE4(a,b,c,d,e) logmsg(LOG_TRACE, a, b, c, d, e) +# define TRACE5(a,b,c,d,e,f) logmsg(LOG_TRACE, a, b, c, d, e, f) +# define TRACE6(a,b,c,d,e,f,g) logmsg(LOG_TRACE, a, b, c, d, e, f, g) +# define TRACE7(a,b,c,d,e,f,g,h) logmsg(LOG_TRACE, a, b, c, d, e, f, g, h) #else # define TRACE(m) # define TRACE1(a,b) diff --git a/src/m68k/bios_m68k.c b/src/m68k/bios_m68k.c index 12f8425..15ea94a 100644 --- a/src/m68k/bios_m68k.c +++ b/src/m68k/bios_m68k.c @@ -238,7 +238,6 @@ unsigned long syscall_dispatch(int32_t function, int32_t param0, int32_t param1, /* Misc functions */ switch (function) { case KFN_TIME_JIFFIES: - TRACE("KFN_TIME_JIFFIES"); return rtc_get_jiffies(); case KFN_TIME_SETRTC: