From 67b45b701ab34eafcc18a571392c054f080e741c Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Wed, 3 Jan 2024 11:17:28 +0100 Subject: [PATCH 1/3] mark I_ErrorOrSuccess() with attribute NORETURN --- src/i_system.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i_system.h b/src/i_system.h index 0dbd1412..9c601d54 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -58,7 +58,7 @@ ticcmd_t* I_BaseTiccmd (void); // killough 3/20/98: add const // killough 4/25/98: add gcc attributes -void I_ErrorOrSuccess(int err_code, const char *error, ...) PRINTF_ATTR(2, 3); +void I_ErrorOrSuccess(int err_code, const char *error, ...) NORETURN PRINTF_ATTR(2, 3); #define I_Error(...) I_ErrorOrSuccess(-1, __VA_ARGS__) #define I_Success(...) I_ErrorOrSuccess(0, __VA_ARGS__) From c7b2362a590e5ee07d535c6ad8d955e7443bdca3 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Wed, 3 Jan 2024 11:24:35 +0100 Subject: [PATCH 2/3] properly error out of G_NextWeapon() in case of error --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index f46569a9..7a4d0733 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -295,7 +295,7 @@ static int G_NextWeapon(int direction) if (i == arrlen(weapon_order_table)) { - return wp_nochange; + I_Error("G_NextWeapon: Invalid weapon type %d", (int)weapon); } // Switch weapon. Don't loop forever. From 5a5c46f6b0934199ea1ae5e7ffcb995e49741010 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Wed, 3 Jan 2024 11:43:33 +0100 Subject: [PATCH 3/3] define the __GNUC__ macro for cppcheck CI --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1b36d33d..a000cbd0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -145,4 +145,5 @@ jobs: - name: Run cppcheck shell: bash run: | - cppcheck --version ; cppcheck --error-exitcode=1 -j4 -q --force -U_WIN32 -Isrc opl src setup textscreen + cppcheck --version + cppcheck --error-exitcode=1 -j4 -q --force -D__GNUC__ -U_MSC_VER -U_WIN32 -Isrc opl src setup textscreen