From 44a35e57f69c24ae68b1afa79a45f9805767772c Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sun, 14 Apr 2024 00:22:14 +0300 Subject: [PATCH] Avoid GCC false positives --- Makefile | 2 +- SDL/main.c | 5 +++-- SDL/utils.c | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 912c4fadc..14967bc8f 100644 --- a/Makefile +++ b/Makefile @@ -164,7 +164,7 @@ endif # These must come before the -Wno- flags WARNINGS += -Werror -Wall -Wno-unknown-warning -Wno-unknown-warning-option -Wno-missing-braces -WARNINGS += -Wno-nonnull -Wno-unused-result -Wno-multichar -Wno-int-in-bool-context +WARNINGS += -Wno-nonnull -Wno-unused-result -Wno-multichar -Wno-int-in-bool-context -Wno-format-truncation # Only add this flag if the compiler supports it ifeq ($(shell $(CC) -x c -c $(NULL) -o $(NULL) -Werror -Wpartial-availability 2> $(NULL); echo $$?),0) diff --git a/SDL/main.c b/SDL/main.c index 00bf8eeb6..173e42bc4 100644 --- a/SDL/main.c +++ b/SDL/main.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -689,7 +690,7 @@ static void load_boot_rom(GB_gameboy_t *gb, GB_boot_rom_t type) }; bool use_built_in = true; if (configuration.bootrom_path[0]) { - static char path[4096]; + static char path[PATH_MAX + 1]; snprintf(path, sizeof(path), "%s/%s", configuration.bootrom_path, names[type]); use_built_in = GB_load_boot_rom(gb, path); } @@ -890,7 +891,7 @@ restart: } } -static char prefs_path[1024] = {0, }; +static char prefs_path[PATH_MAX + 1] = {0, }; static void save_configuration(void) { diff --git a/SDL/utils.c b/SDL/utils.c index 603e34a83..32945fd67 100644 --- a/SDL/utils.c +++ b/SDL/utils.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "utils.h" static const char *resource_folder(void) @@ -18,7 +19,7 @@ static const char *resource_folder(void) char *resource_path(const char *filename) { - static char path[1024]; + static char path[PATH_MAX + 1]; snprintf(path, sizeof(path), "%s%s", resource_folder(), filename); #ifdef DATA_DIR