Avoid GCC false positives

This commit is contained in:
Lior Halphon
2024-04-14 00:22:14 +03:00
parent 038a2c5892
commit 44a35e57f6
3 changed files with 6 additions and 4 deletions

View File

@@ -164,7 +164,7 @@ endif
# These must come before the -Wno- flags # These must come before the -Wno- flags
WARNINGS += -Werror -Wall -Wno-unknown-warning -Wno-unknown-warning-option -Wno-missing-braces 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 # 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) ifeq ($(shell $(CC) -x c -c $(NULL) -o $(NULL) -Werror -Wpartial-availability 2> $(NULL); echo $$?),0)

View File

@@ -4,6 +4,7 @@
#include <ctype.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <limits.h>
#include <OpenDialog/open_dialog.h> #include <OpenDialog/open_dialog.h>
#include <SDL.h> #include <SDL.h>
#include <Core/gb.h> #include <Core/gb.h>
@@ -689,7 +690,7 @@ static void load_boot_rom(GB_gameboy_t *gb, GB_boot_rom_t type)
}; };
bool use_built_in = true; bool use_built_in = true;
if (configuration.bootrom_path[0]) { 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]); snprintf(path, sizeof(path), "%s/%s", configuration.bootrom_path, names[type]);
use_built_in = GB_load_boot_rom(gb, path); 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) static void save_configuration(void)
{ {

View File

@@ -2,6 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <limits.h>
#include "utils.h" #include "utils.h"
static const char *resource_folder(void) static const char *resource_folder(void)
@@ -18,7 +19,7 @@ static const char *resource_folder(void)
char *resource_path(const char *filename) 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); snprintf(path, sizeof(path), "%s%s", resource_folder(), filename);
#ifdef DATA_DIR #ifdef DATA_DIR