diff --git a/Makefile b/Makefile index c0db758..ab5256f 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ export INCLUDE := -I"$(shell pwd)/common" export ASFLAGS := -g -x assembler-with-cpp $(INCLUDE) export CFLAGS := -DDBUILTS="\"$(DBUILTS)\"" -DDBUILTL="\"$(DBUILTL)\"" -DVERSION="\"$(VERSION)\"" -DFLAVOR="\"$(FLAVOR)\"" \ - -g -O2 -Wall -Wextra -Wpedantic -Wcast-align -Wno-main \ + -g -O2 -Wall -Wextra -Wpedantic -Wcast-align -Wformat=2 -Wno-main \ -fomit-frame-pointer -ffast-math -std=gnu11 \ -Wno-unused-function $(INCLUDE) -ffunction-sections -fdata-sections export LDFLAGS := -Tlink.ld -nostartfiles -Wl,--gc-sections,-z,max-page-size=512 diff --git a/arm9/source/common/ui.c b/arm9/source/common/ui.c index 19197db..f6cb3c5 100644 --- a/arm9/source/common/ui.c +++ b/arm9/source/common/ui.c @@ -346,9 +346,9 @@ void TruncateString(char* dest, const char* orig, int nsize, int tpos) { if (nsize < 0) { return; } else if (nsize <= 3) { - snprintf(dest, nsize, orig); + snprintf(dest, nsize, "%s", orig); } else if (nsize >= osize) { - snprintf(dest, nsize + 1, orig); + snprintf(dest, nsize + 1, "%s", orig); } else { if (tpos + 3 > nsize) tpos = nsize - 3; snprintf(dest, nsize + 1, "%-.*s...%-.*s", tpos, orig, nsize - (3 + tpos), orig + osize - (nsize - (3 + tpos))); diff --git a/arm9/source/filesys/fsdrive.c b/arm9/source/filesys/fsdrive.c index eb904d4..5bca2f2 100644 --- a/arm9/source/filesys/fsdrive.c +++ b/arm9/source/filesys/fsdrive.c @@ -89,7 +89,7 @@ bool GetRootDirContentsWorker(DirStruct* contents) { DirEntry* entry = &(contents->entry[n_entries]); if (!DriveType(drvnum[i])) continue; // drive not available memset(entry->path, 0x00, 64); - snprintf(entry->path + 0, 4, drvnum[i]); + snprintf(entry->path + 0, 4, "%s", drvnum[i]); if ((*(drvnum[i]) >= '7') && (*(drvnum[i]) <= '9') && !(GetMountState() & IMG_NAND)) // Drive 7...9 handling snprintf(entry->path + 4, 32, "[%s] %s", drvnum[i], (*(drvnum[i]) == '7') ? "FAT IMAGE" : diff --git a/arm9/source/filesys/fsutil.c b/arm9/source/filesys/fsutil.c index 4d2253f..0470969 100644 --- a/arm9/source/filesys/fsutil.c +++ b/arm9/source/filesys/fsutil.c @@ -808,7 +808,7 @@ bool FileSelectorWorker(char* result, const char* text, const char* path, const } char temp_str[256]; - snprintf(temp_str, 256, entry->name); + snprintf(temp_str, 256, "%s", entry->name); if (hide_ext && (entry->type == T_FILE)) { char* dot = strrchr(temp_str, '.'); if (dot) *dot = '\0'; @@ -823,7 +823,7 @@ bool FileSelectorWorker(char* result, const char* text, const char* path, const const char* optionstr[_MAX_FS_OPT+1] = { NULL }; for (u32 i = 0; i <= _MAX_FS_OPT; i++) optionstr[i] = opt_names[i]; - u32 user_select = ShowSelectPrompt(n_opt, optionstr, text); + u32 user_select = ShowSelectPrompt(n_opt, optionstr, "%s", text); if (!user_select) return false; DirEntry* res_local = res_entry[user_select-1]; if (res_local && (res_local->type == T_DIR)) { // selected dir diff --git a/arm9/source/godmode.c b/arm9/source/godmode.c index c498436..a77d2e3 100644 --- a/arm9/source/godmode.c +++ b/arm9/source/godmode.c @@ -161,7 +161,7 @@ void DrawTopBar(const char* curr_path) { DrawRectangle(TOP_SCREEN, 0, 0, SCREEN_WIDTH_TOP, 12, COLOR_TOP_BAR); if (*curr_path) TruncateString(tempstr, curr_path, len_path / FONT_WIDTH_EXT, 8); else snprintf(tempstr, 16, "[root]"); - DrawStringF(TOP_SCREEN, bartxt_x, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, tempstr); + DrawStringF(TOP_SCREEN, bartxt_x, bartxt_start, COLOR_STD_BG, COLOR_TOP_BAR, "%s", tempstr); bool show_time = true; #ifdef SHOW_FREE @@ -261,10 +261,10 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, u32 curr_pan strncpy(dirstr, curr_entry->path, 256); *(strrchr(dirstr, '/')+1) = '\0'; ResizeString(tempstr, dirstr, len_info / FONT_WIDTH_EXT, 8, false); - DrawStringF(MAIN_SCREEN, 4, info_start + 12 + 10 + 10, color_current, COLOR_STD_BG, tempstr); + DrawStringF(MAIN_SCREEN, 4, info_start + 12 + 10 + 10, color_current, COLOR_STD_BG, "%s", tempstr); } else { ResizeString(tempstr, "", len_info / FONT_WIDTH_EXT, 8, false); - DrawStringF(MAIN_SCREEN, 4, info_start + 12 + 10 + 10, color_current, COLOR_STD_BG, tempstr); + DrawStringF(MAIN_SCREEN, 4, info_start + 12 + 10 + 10, color_current, COLOR_STD_BG, "%s", tempstr); } // right top - clipboard @@ -273,7 +273,7 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, u32 curr_pan for (u32 c = 0; c < n_cb_show; c++) { u32 color_cb = COLOR_ENTRY(&(clipboard->entry[c])); ResizeString(tempstr, (clipboard->n_entries > c) ? clipboard->entry[c].name : "", len_info / FONT_WIDTH_EXT, 8, true); - DrawStringF(MAIN_SCREEN, SCREEN_WIDTH_MAIN - len_info - 4, info_start + 12 + (c*10), color_cb, COLOR_STD_BG, tempstr); + DrawStringF(MAIN_SCREEN, SCREEN_WIDTH_MAIN - len_info - 4, info_start + 12 + (c*10), color_cb, COLOR_STD_BG, "%s", tempstr); } *tempstr = '\0'; if (clipboard->n_entries > n_cb_show) snprintf(tempstr, 60, "+ %lu more", clipboard->n_entries - n_cb_show); @@ -1567,7 +1567,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan optionstr[n_opt] = "EmuNAND H&S inject"; destdrv[n_opt++] = "4:"; } - user_select = (n_opt > 1) ? (int) ShowSelectPrompt(n_opt, optionstr, pathstr) : n_opt; + user_select = (n_opt > 1) ? (int) ShowSelectPrompt(n_opt, optionstr, "%s", pathstr) : n_opt; if (user_select) { ShowPrompt(false, "%s\nH&S inject %s", pathstr, (InjectHealthAndSafety(file_path, destdrv[user_select-1]) == 0) ? "success" : "failed"); @@ -1633,7 +1633,7 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan destdrv[n_opt++] = "4:"; } if (n_opt) { - user_select = (n_opt > 1) ? (int) ShowSelectPrompt(n_opt, optionstr, pathstr) : 1; + user_select = (n_opt > 1) ? (int) ShowSelectPrompt(n_opt, optionstr, "%s", pathstr) : 1; if (user_select) { ShowPrompt(false, "%s\nCTRNAND transfer %s", pathstr, (TransferCtrNandImage(file_path, destdrv[user_select-1]) == 0) ? "success" : "failed"); @@ -2157,7 +2157,7 @@ u32 GodMode(int entrypoint) { const char* optionstr[2] = { "Open this folder", "Open containing folder" }; char pathstr[32 + 1]; TruncateString(pathstr, curr_entry->path, 32, 8); - user_select = ShowSelectPrompt(2, optionstr, pathstr); + user_select = ShowSelectPrompt(2, optionstr, "%s", pathstr); } if (user_select) { strncpy(current_path, curr_entry->path, 256); @@ -2323,7 +2323,7 @@ u32 GodMode(int entrypoint) { snprintf(promptstr, 64, "Paste \"%s\" here?", namestr); } else snprintf(promptstr, 64, "Paste %lu paths here?", clipboard->n_entries); user_select = ((DriveType(clipboard->entry[0].path) & curr_drvtype & DRV_STDFAT)) ? - ShowSelectPrompt(2, optionstr, promptstr) : (ShowPrompt(true, promptstr) ? 1 : 0); + ShowSelectPrompt(2, optionstr, "%s", promptstr) : (ShowPrompt(true, "%s", promptstr) ? 1 : 0); if (user_select) { for (u32 c = 0; c < clipboard->n_entries; c++) { char namestr[36+1]; @@ -2354,7 +2354,7 @@ u32 GodMode(int entrypoint) { char newname[256]; char namestr[20+1]; TruncateString(namestr, curr_entry->name, 20, 12); - snprintf(newname, 255, curr_entry->name); + snprintf(newname, 255, "%s", curr_entry->name); if (ShowStringPrompt(newname, 256, "Rename %s?\nEnter new name below.", namestr)) { if (!PathRename(curr_entry->path, newname)) ShowPrompt(false, "Failed renaming path:\n%s", namestr); diff --git a/arm9/source/nand/sdmmc.c b/arm9/source/nand/sdmmc.c index ce7d3b9..4cfeca1 100644 --- a/arm9/source/nand/sdmmc.c +++ b/arm9/source/nand/sdmmc.c @@ -497,4 +497,4 @@ u32 sdmmc_sdcard_init() if(Nand_Init() != 0) ret &= 1; if(SD_Init() != 0) ret &= 2; return ret; -} \ No newline at end of file +} diff --git a/arm9/source/nand/sdmmc.h b/arm9/source/nand/sdmmc.h index 17bc809..cd75bc1 100644 --- a/arm9/source/nand/sdmmc.h +++ b/arm9/source/nand/sdmmc.h @@ -99,4 +99,4 @@ int sdmmc_sdcard_writesectors(u32 sector_no, u32 numsectors, const u8 *in); int sdmmc_nand_readsectors(u32 sector_no, u32 numsectors, u8 *out); int sdmmc_nand_writesectors(u32 sector_no, u32 numsectors, const u8 *in); void sdmmc_get_cid(bool isNand, u32 *info); -mmcdevice *getMMCDevice(int drive); \ No newline at end of file +mmcdevice *getMMCDevice(int drive); diff --git a/arm9/source/system/bps.c b/arm9/source/system/bps.c index 0b9e2c9..e899277 100644 --- a/arm9/source/system/bps.c +++ b/arm9/source/system/bps.c @@ -432,4 +432,4 @@ int ApplyBPMPatch(const char* patchName, const char* sourcePath, const char* tar fvx_close(&patchFile); return BEAT_SUCCESS; -} \ No newline at end of file +} diff --git a/arm9/source/system/ips.c b/arm9/source/system/ips.c index 7b0104b..7dd4f88 100644 --- a/arm9/source/system/ips.c +++ b/arm9/source/system/ips.c @@ -196,4 +196,4 @@ int ApplyIPSPatch(const char* patchName, const char* inName, const char* outName fvx_lseek(&outFile, outSize); f_truncate(&outFile); return ret(error); -} \ No newline at end of file +} diff --git a/arm9/source/system/ips.h b/arm9/source/system/ips.h index f0b484c..cbc3b39 100644 --- a/arm9/source/system/ips.h +++ b/arm9/source/system/ips.h @@ -4,4 +4,4 @@ #pragma once -int ApplyIPSPatch(const char* patchName, const char* sourceName, const char* targetName); \ No newline at end of file +int ApplyIPSPatch(const char* patchName, const char* sourceName, const char* targetName); diff --git a/arm9/source/utils/scripting.c b/arm9/source/utils/scripting.c index 6e7d5e5..928e3ae 100644 --- a/arm9/source/utils/scripting.c +++ b/arm9/source/utils/scripting.c @@ -718,8 +718,8 @@ bool for_handler(char* path, const char* dir, const char* pattern, bool recursiv } if (dir) { // open a dir - snprintf(lpattern, 64, pattern); - snprintf(ldir, 256, dir); + snprintf(lpattern, 64, "%s", pattern); + snprintf(ldir, 256, "%s", dir); if (dp) return false; // <- this should never happen if (fvx_opendir(&fdir[0], dir) != FR_OK) return false; @@ -1805,7 +1805,7 @@ bool ExecuteGM9Script(const char* path_script) { free(bitmap); } else { if (strncmp(preview_str, "off", _VAR_CNT_LEN) == 0) preview_str = "(preview disabled)"; - DrawStringCenter(TOP_SCREEN, COLOR_STD_FONT, COLOR_STD_BG, preview_str); + DrawStringCenter(TOP_SCREEN, COLOR_STD_FONT, COLOR_STD_BG, "%s", preview_str); } preview_mode = 0; @@ -1874,7 +1874,7 @@ bool ExecuteGM9Script(const char* path_script) { if (!(flags & _FLG('s'))) { // not silent if (!*err_str) { char* msg_fail = get_var("ERRORMSG", NULL); - if (msg_fail && *msg_fail) ShowPrompt(false, msg_fail); + if (msg_fail && *msg_fail) ShowPrompt(false, "%s", msg_fail); else snprintf(err_str, _ERR_STR_LEN, "error message fail"); } if (*err_str) { @@ -1926,7 +1926,7 @@ bool ExecuteGM9Script(const char* path_script) { if (result) { // success message if applicable char* msg_okay = get_var("SUCCESSMSG", NULL); - if (msg_okay && *msg_okay) ShowPrompt(false, msg_okay); + if (msg_okay && *msg_okay) ShowPrompt(false, "%s", msg_okay); }