From ffd757f3e33abf2a4fc147ca8cc682a38328a96e Mon Sep 17 00:00:00 2001 From: Yonder Date: Mon, 29 Aug 2022 17:42:14 -0400 Subject: [PATCH] Fixed warnings of unhandled switch cases This was unnoticed after moving code to `printcode`. This ensures safety if `printcode` called outside of `main`. --- README.md | 3 ++- compile.sh | 2 +- src/makecode.c | 9 +++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d018365..4138de7 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,8 @@ Code Name\ncode`), and raw (`code`). Simply run `./compile.sh` at root directory of project. This script uses GCC to compile the sources. It also computes the md5, sha1, and sha256 hash of the compiled result afterwards using `md5sum`, `sha1sum`, and `sha256sum`. You can pass `asan` as the first argument to the script to build a debug build with AddressSanitizer (this isn't supported on a -Windows build). For building for Windows, run `./compile.sh` with MSYS2 MinGW x64 or run `.\compile.bat`. +Windows build) with all warnings to be printed. For building for Windows, run `./compile.sh` with MSYS2 MinGW x64 or +run `.\compile.bat`. ## Credits - Shio, SirMangler, and many others for their work on PrimeHack, a modification of Dolphin Emulator to allow for FPS diff --git a/compile.sh b/compile.sh index f687dea..415758e 100644 --- a/compile.sh +++ b/compile.sh @@ -5,7 +5,7 @@ if [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ] || [ "$(expr substr $(u OUTEXT=".exe" elif [ $# -gt 0 ]; then if [ "$1" == "asan" ]; then - ASAN="-fsanitize=address -g" + ASAN="-fsanitize=address -g -Wall" fi fi if [ ! -d "./dst" ]; then mkdir ./dst ; fi diff --git a/src/makecode.c b/src/makecode.c index d1d24e7..2bf459b 100644 --- a/src/makecode.c +++ b/src/makecode.c @@ -359,6 +359,9 @@ int printcode(Code code, Game game, GameRegion region, CodeFormat format, uint8_ val_version_mp1 = 0x0002; break; + default: + fprintf(stderr, "Invalid game specified."); + return MCS_INVLDARG; } } else if (region == GMR_PAL) { val_id1 = 0x474D; // GM @@ -387,6 +390,9 @@ int printcode(Code code, Game game, GameRegion region, CodeFormat format, uint8_ } break; + default: + fprintf(stderr, "Invalid game specified."); + return MCS_INVLDARG; } uint32_t addr_exception_hook = 0x80000048, @@ -891,6 +897,9 @@ blr runppcasm(10, hm_ppcasm); break; + default: + fprintf(stderr, "Invalid code specified."); + return MCS_INVLDARG; } endifv(0, (addr_memstart >> 16), (addr_memstart >> 16));