fusee/sept: update for gcc10

This commit is contained in:
Michael Scire 2020-05-07 18:49:46 -07:00
parent 232203f4c0
commit c72614f768
8 changed files with 50 additions and 24 deletions

View file

@ -23,13 +23,16 @@ FATFS sd_fs;
static bool g_sd_mounted = false; static bool g_sd_mounted = false;
static bool g_sd_initialized = false; static bool g_sd_initialized = false;
static bool g_ahb_redirect_enabled = false; static bool g_ahb_redirect_enabled = false;
sdmmc_t g_sd_sdmmc;
sdmmc_device_t g_sd_device;
bool mount_sd(void) bool mount_sd(void)
{ {
/* Already mounted. */ /* Already mounted. */
if (g_sd_mounted) if (g_sd_mounted)
return true; return true;
/* Enable AHB redirection if necessary. */ /* Enable AHB redirection if necessary. */
if (!g_ahb_redirect_enabled) { if (!g_ahb_redirect_enabled) {
mc_enable_ahb_redirect(); mc_enable_ahb_redirect();
@ -41,7 +44,7 @@ bool mount_sd(void)
if (sdmmc_device_sd_init(&g_sd_device, &g_sd_sdmmc, SDMMC_BUS_WIDTH_4BIT, SDMMC_SPEED_UHS_SDR104)) if (sdmmc_device_sd_init(&g_sd_device, &g_sd_sdmmc, SDMMC_BUS_WIDTH_4BIT, SDMMC_SPEED_UHS_SDR104))
{ {
g_sd_initialized = true; g_sd_initialized = true;
/* Mount SD. */ /* Mount SD. */
if (f_mount(&sd_fs, "", 1) == FR_OK) { if (f_mount(&sd_fs, "", 1) == FR_OK) {
print(SCREEN_LOG_LEVEL_INFO, "Mounted SD card!\n"); print(SCREEN_LOG_LEVEL_INFO, "Mounted SD card!\n");
@ -63,7 +66,7 @@ void unmount_sd(void)
sdmmc_device_finish(&g_sd_device); sdmmc_device_finish(&g_sd_device);
g_sd_mounted = false; g_sd_mounted = false;
} }
/* Disable AHB redirection if necessary. */ /* Disable AHB redirection if necessary. */
if (g_ahb_redirect_enabled) { if (g_ahb_redirect_enabled) {
mc_disable_ahb_redirect(); mc_disable_ahb_redirect();
@ -81,13 +84,13 @@ uint32_t get_file_size(const char *filename)
FIL f; FIL f;
if (f_open(&f, filename, FA_READ) != FR_OK) if (f_open(&f, filename, FA_READ) != FR_OK)
return 0; return 0;
/* Get the file size. */ /* Get the file size. */
uint32_t file_size = f_size(&f); uint32_t file_size = f_size(&f);
/* Close the file. */ /* Close the file. */
f_close(&f); f_close(&f);
return file_size; return file_size;
} }
@ -101,10 +104,10 @@ int read_from_file(void *dst, uint32_t dst_size, const char *filename)
FIL f; FIL f;
if (f_open(&f, filename, FA_READ) != FR_OK) if (f_open(&f, filename, FA_READ) != FR_OK)
return 0; return 0;
/* Sync. */ /* Sync. */
f_sync(&f); f_sync(&f);
/* Read from file. */ /* Read from file. */
UINT br = 0; UINT br = 0;
int res = f_read(&f, dst, dst_size, &br); int res = f_read(&f, dst, dst_size, &br);
@ -118,7 +121,7 @@ int write_to_file(void *src, uint32_t src_size, const char *filename)
/* SD card hasn't been mounted yet. */ /* SD card hasn't been mounted yet. */
if (!g_sd_mounted) if (!g_sd_mounted)
return 0; return 0;
/* Open the file for writing. */ /* Open the file for writing. */
FIL f; FIL f;
if (f_open(&f, filename, FA_CREATE_ALWAYS | FA_WRITE) != FR_OK) if (f_open(&f, filename, FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef FUSEE_FS_UTILS_H #ifndef FUSEE_FS_UTILS_H
#define FUSEE_FS_UTILS_H #define FUSEE_FS_UTILS_H
@ -23,8 +23,8 @@
#include "sdmmc/sdmmc.h" #include "sdmmc/sdmmc.h"
#include "utils.h" #include "utils.h"
sdmmc_t g_sd_sdmmc; extern sdmmc_t g_sd_sdmmc;
sdmmc_device_t g_sd_device; extern sdmmc_device_t g_sd_device;
bool mount_sd(void); bool mount_sd(void);
void unmount_sd(void); void unmount_sd(void);

View file

@ -70,7 +70,10 @@ static char* find_chars_or_comment(const char* s, const char* chars)
/* Version of strncpy that ensures dest (size bytes) is null-terminated. */ /* Version of strncpy that ensures dest (size bytes) is null-terminated. */
static char* strncpy0(char* dest, const char* src, size_t size) static char* strncpy0(char* dest, const char* src, size_t size)
{ {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(dest, src, size - 1); strncpy(dest, src, size - 1);
#pragma GCC diagnostic pop
dest[size - 1] = '\0'; dest[size - 1] = '\0';
return dest; return dest;
} }

View file

@ -70,7 +70,10 @@ static char* find_chars_or_comment(const char* s, const char* chars)
/* Version of strncpy that ensures dest (size bytes) is null-terminated. */ /* Version of strncpy that ensures dest (size bytes) is null-terminated. */
static char* strncpy0(char* dest, const char* src, size_t size) static char* strncpy0(char* dest, const char* src, size_t size)
{ {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(dest, src, size - 1); strncpy(dest, src, size - 1);
#pragma GCC diagnostic pop
dest[size - 1] = '\0'; dest[size - 1] = '\0';
return dest; return dest;
} }

View file

@ -119,10 +119,16 @@ static int emummc_ini_handler(void *user, const char *section, const char *name,
} else if (strcmp(name, EMUMMC_ID_KEY) == 0) { } else if (strcmp(name, EMUMMC_ID_KEY) == 0) {
sscanf(value, "%lx", &emummc_cfg->id); sscanf(value, "%lx", &emummc_cfg->id);
} else if (strcmp(name, EMUMMC_PATH_KEY) == 0) { } else if (strcmp(name, EMUMMC_PATH_KEY) == 0) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(emummc_cfg->path, value, sizeof(emummc_cfg->path) - 1); strncpy(emummc_cfg->path, value, sizeof(emummc_cfg->path) - 1);
#pragma GCC diagnostic pop
emummc_cfg->path[sizeof(emummc_cfg->path) - 1] = '\0'; emummc_cfg->path[sizeof(emummc_cfg->path) - 1] = '\0';
} else if (strcmp(name, EMUMMC_NINTENDO_PATH_KEY) == 0) { } else if (strcmp(name, EMUMMC_NINTENDO_PATH_KEY) == 0) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(emummc_cfg->nintendo_path, value, sizeof(emummc_cfg->nintendo_path) - 1); strncpy(emummc_cfg->nintendo_path, value, sizeof(emummc_cfg->nintendo_path) - 1);
#pragma GCC diagnostic pop
emummc_cfg->nintendo_path[sizeof(emummc_cfg->nintendo_path) - 1] = '\0'; emummc_cfg->nintendo_path[sizeof(emummc_cfg->nintendo_path) - 1] = '\0';
} else { } else {
return 0; return 0;
@ -356,7 +362,10 @@ static bool nxboot_configure_emummc(exo_emummc_config_t *exo_emummc_config) {
/* Initialize values from emummc config. */ /* Initialize values from emummc config. */
exo_emummc_config->base_cfg.id = emummc_cfg.id; exo_emummc_config->base_cfg.id = emummc_cfg.id;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(exo_emummc_config->emu_dir_path, emummc_cfg.nintendo_path, sizeof(exo_emummc_config->emu_dir_path)); strncpy(exo_emummc_config->emu_dir_path, emummc_cfg.nintendo_path, sizeof(exo_emummc_config->emu_dir_path));
#pragma GCC diagnostic pop
exo_emummc_config->emu_dir_path[sizeof(exo_emummc_config->emu_dir_path) - 1] = '\0'; exo_emummc_config->emu_dir_path[sizeof(exo_emummc_config->emu_dir_path) - 1] = '\0';
if (emummc_cfg.enabled) { if (emummc_cfg.enabled) {
@ -370,7 +379,10 @@ static bool nxboot_configure_emummc(exo_emummc_config_t *exo_emummc_config) {
} }
} else if (is_valid_folder(emummc_cfg.path)) { } else if (is_valid_folder(emummc_cfg.path)) {
exo_emummc_config->base_cfg.type = EMUMMC_TYPE_FILES; exo_emummc_config->base_cfg.type = EMUMMC_TYPE_FILES;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(exo_emummc_config->file_cfg.path, emummc_cfg.path, sizeof(exo_emummc_config->file_cfg.path)); strncpy(exo_emummc_config->file_cfg.path, emummc_cfg.path, sizeof(exo_emummc_config->file_cfg.path));
#pragma GCC diagnostic pop
exo_emummc_config->file_cfg.path[sizeof(exo_emummc_config->file_cfg.path) - 1] = '\0'; exo_emummc_config->file_cfg.path[sizeof(exo_emummc_config->file_cfg.path) - 1] = '\0';
int num_parts = 0; int num_parts = 0;

View file

@ -23,13 +23,15 @@ FATFS sd_fs;
static bool g_sd_mounted = false; static bool g_sd_mounted = false;
static bool g_sd_initialized = false; static bool g_sd_initialized = false;
static bool g_ahb_redirect_enabled = false; static bool g_ahb_redirect_enabled = false;
sdmmc_t g_sd_sdmmc;
sdmmc_device_t g_sd_device;
bool mount_sd(void) bool mount_sd(void)
{ {
/* Already mounted. */ /* Already mounted. */
if (g_sd_mounted) if (g_sd_mounted)
return true; return true;
/* Enable AHB redirection if necessary. */ /* Enable AHB redirection if necessary. */
if (!g_ahb_redirect_enabled) { if (!g_ahb_redirect_enabled) {
mc_enable_ahb_redirect(); mc_enable_ahb_redirect();
@ -41,7 +43,7 @@ bool mount_sd(void)
if (sdmmc_device_sd_init(&g_sd_device, &g_sd_sdmmc, SDMMC_BUS_WIDTH_4BIT, SDMMC_SPEED_UHS_SDR104)) if (sdmmc_device_sd_init(&g_sd_device, &g_sd_sdmmc, SDMMC_BUS_WIDTH_4BIT, SDMMC_SPEED_UHS_SDR104))
{ {
g_sd_initialized = true; g_sd_initialized = true;
/* Mount SD. */ /* Mount SD. */
if (f_mount(&sd_fs, "", 1) == FR_OK) { if (f_mount(&sd_fs, "", 1) == FR_OK) {
print(SCREEN_LOG_LEVEL_INFO, "Mounted SD card!\n"); print(SCREEN_LOG_LEVEL_INFO, "Mounted SD card!\n");
@ -63,7 +65,7 @@ void unmount_sd(void)
sdmmc_device_finish(&g_sd_device); sdmmc_device_finish(&g_sd_device);
g_sd_mounted = false; g_sd_mounted = false;
} }
/* Disable AHB redirection if necessary. */ /* Disable AHB redirection if necessary. */
if (g_ahb_redirect_enabled) { if (g_ahb_redirect_enabled) {
mc_disable_ahb_redirect(); mc_disable_ahb_redirect();
@ -81,13 +83,13 @@ uint32_t get_file_size(const char *filename)
FIL f; FIL f;
if (f_open(&f, filename, FA_READ) != FR_OK) if (f_open(&f, filename, FA_READ) != FR_OK)
return 0; return 0;
/* Get the file size. */ /* Get the file size. */
uint32_t file_size = f_size(&f); uint32_t file_size = f_size(&f);
/* Close the file. */ /* Close the file. */
f_close(&f); f_close(&f);
return file_size; return file_size;
} }
@ -101,10 +103,10 @@ int read_from_file(void *dst, uint32_t dst_size, const char *filename)
FIL f; FIL f;
if (f_open(&f, filename, FA_READ) != FR_OK) if (f_open(&f, filename, FA_READ) != FR_OK)
return 0; return 0;
/* Sync. */ /* Sync. */
f_sync(&f); f_sync(&f);
/* Read from file. */ /* Read from file. */
UINT br = 0; UINT br = 0;
int res = f_read(&f, dst, dst_size, &br); int res = f_read(&f, dst, dst_size, &br);
@ -118,7 +120,7 @@ int write_to_file(void *src, uint32_t src_size, const char *filename)
/* SD card hasn't been mounted yet. */ /* SD card hasn't been mounted yet. */
if (!g_sd_mounted) if (!g_sd_mounted)
return 0; return 0;
/* Open the file for writing. */ /* Open the file for writing. */
FIL f; FIL f;
if (f_open(&f, filename, FA_CREATE_ALWAYS | FA_WRITE) != FR_OK) if (f_open(&f, filename, FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)

View file

@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef FUSEE_FS_UTILS_H #ifndef FUSEE_FS_UTILS_H
#define FUSEE_FS_UTILS_H #define FUSEE_FS_UTILS_H
@ -23,8 +23,8 @@
#include "sdmmc/sdmmc.h" #include "sdmmc/sdmmc.h"
#include "utils.h" #include "utils.h"
sdmmc_t g_sd_sdmmc; extern sdmmc_t g_sd_sdmmc;
sdmmc_device_t g_sd_device; extern sdmmc_device_t g_sd_device;
bool mount_sd(void); bool mount_sd(void);
void unmount_sd(void); void unmount_sd(void);

View file

@ -70,7 +70,10 @@ static char* find_chars_or_comment(const char* s, const char* chars)
/* Version of strncpy that ensures dest (size bytes) is null-terminated. */ /* Version of strncpy that ensures dest (size bytes) is null-terminated. */
static char* strncpy0(char* dest, const char* src, size_t size) static char* strncpy0(char* dest, const char* src, size_t size)
{ {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(dest, src, size - 1); strncpy(dest, src, size - 1);
#pragma GCC diagnostic pop
dest[size - 1] = '\0'; dest[size - 1] = '\0';
return dest; return dest;
} }