From a94d756411a3a7d50be9fcb43970daf7eaff0680 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Fri, 16 Aug 2024 00:01:51 +1000 Subject: [PATCH] Fix some pedantic compiler stuff and a warning off-by-1 Signed-off-by: bones_was_here --- builddate.c | 4 ++-- common.c | 2 +- sys_shared.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/builddate.c b/builddate.c index 268a9614..161c095b 100644 --- a/builddate.c +++ b/builddate.c @@ -20,12 +20,12 @@ const char *buildstring = // STRINGIFY(__clang_major__) // "." // STRINGIFY(__clang_minor__) -#elifdef __GNUC__ +#elif defined(__GNUC__) " GCC " // STRINGIFY(__GNUC__) // "." // STRINGIFY(__GNUC_MINOR__) -#elifdef _MSC_VER +#elif defined(_MSC_VER) " MSC " // STRINGIFY(_MSC_VER) #endif diff --git a/common.c b/common.c index 0d701bca..0870a454 100644 --- a/common.c +++ b/common.c @@ -1036,7 +1036,7 @@ int dpvsnprintf (char *buffer, size_t buffersize, const char *format, va_list ar if (result > 0) { msg[sizeof(msg) - 1] = '\n'; // may have been lost in truncation - Sys_Print(msg, min((size_t)result, sizeof(msg))); + Sys_Print(msg, min((size_t)result, sizeof(msg) - 1)); } } return -1; diff --git a/sys_shared.c b/sys_shared.c index d460b77b..0d6cf410 100644 --- a/sys_shared.c +++ b/sys_shared.c @@ -1011,16 +1011,16 @@ static void Sys_HandleCrash(int sig) sys.outfd = fileno(stderr); // not async-signal-safe :( #ifndef WIN32 fcntl(sys.outfd, F_SETFL, fcntl(sys.outfd, F_GETFL, 0) & ~O_NONBLOCK); - Sys_Print("\n\n\e[1;37;41m Engine Crash: ", 30); + Sys_Print("\n\n\x1B[1;37;41m Engine Crash: ", 30); Sys_Print(sigdesc, strlen(sigdesc)); - Sys_Print(" \e[m\n", 8); + Sys_Print(" \x1B[m\n", 8); #if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 // the first two addresses will be in this function and in signal() in libc backtrace_symbols_fd(stackframes + 2, framecount - 2, sys.outfd); #endif - Sys_Print("\e[1m", 4); + Sys_Print("\x1B[1m", 4); Sys_Print(engineversion, strlen(engineversion)); - Sys_Print("\e[m\n", 4); + Sys_Print("\x1B[m\n", 4); #else // Windows console doesn't support colours Sys_Print("\n\nEngine Crash: ", 16); Sys_Print(sigdesc, strlen(sigdesc)); -- 2.39.2