Skip to content

Commit

Permalink
Fixed a boatload of compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
d0k3 committed Mar 22, 2022
1 parent d95a606 commit c13bba4
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 58 deletions.
16 changes: 8 additions & 8 deletions arm9/source/common/swkbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ static void DrawTextBox(const TouchBox* txtbox, const char* inputstr, const u32
// draw input string
DrawStringF(BOT_SCREEN, x, y, COLOR_STD_FONT, COLOR_STD_BG, "%c%-*.*s%c",
(*scroll) ? '<' : '|',
input_shown_size,
input_shown_size,
(int) input_shown_size,
(int) input_shown_size,
(*scroll > inputstr_size) ? "" : inputstr + *scroll,
(inputstr_size - (s32) *scroll > input_shown_size) ? '>' : '|'
);
Expand All @@ -159,11 +159,11 @@ static void DrawTextBox(const TouchBox* txtbox, const char* inputstr, const u32
}

DrawStringF(BOT_SCREEN, x-(FONT_WIDTH_EXT/2), y+10, COLOR_STD_FONT, COLOR_STD_BG, "%-*.*s^%-*.*s",
1 + cpos,
1 + cpos,
(int) (1 + cpos),
(int) (1 + cpos),
"",
input_shown_length - cpos,
input_shown_length - cpos,
(int) (input_shown_length - cpos),
(int) (input_shown_length - cpos),
""
);
}
Expand Down Expand Up @@ -255,7 +255,7 @@ bool ShowKeyboard(char* inputstr, const u32 max_size, const char *format, ...) {
static bool show_instr = true;
static const char* instr = "Keyboard Controls:\n \n←/→ - Move cursor\nR - Caps / Capslock\nX - Delete char\nY - Insert char\nA - Submit\nB - Cancel\n \nSELECT switches to\nclassic prompt";
if (show_instr) {
ShowPrompt(false, instr);
ShowPrompt(false, "%s", instr);
show_instr = false;
}

Expand Down Expand Up @@ -332,7 +332,7 @@ bool ShowKeyboard(char* inputstr, const u32 max_size, const char *format, ...) {
swkbd = swkbd_numpad;
} else if (key == KEY_SWITCH) {
ClearScreen(BOT_SCREEN, COLOR_STD_BG);
return ShowStringPrompt(inputstr, max_size, str);
return ShowStringPrompt(inputstr, max_size, "%s", str);
} else if (key == KEY_UNICODE) {
if (cursor > 3 && cursor <= inputstr_size) {
u16 codepoint = 0;
Expand Down
19 changes: 10 additions & 9 deletions arm9/source/common/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ void ShowIconString(u16* icon, int w, int h, const char *format, ...)
vsnprintf(str, STRBUF_SIZE, format, va);
va_end(va);

ShowIconStringF(MAIN_SCREEN, icon, w, h, str);
ShowIconStringF(MAIN_SCREEN, icon, w, h, "%s", str);
}

bool ShowPrompt(bool ask, const char *format, ...)
Expand Down Expand Up @@ -936,7 +936,8 @@ u32 ShowFileScrollPrompt(u32 n, const DirEntry** options, bool hide_ext, const c
if (n - n_show - scroll) {
char more_str[64 + 1];
snprintf(more_str, 64, " [%d more]", (int)(n - (n_show-1) - scroll));
DrawStringF(MAIN_SCREEN, x, yopt + (line_height+2)*(n_show-1), COLOR_LIGHTGREY, COLOR_STD_BG, "%-*s", item_width / font_width, more_str);
DrawStringF(MAIN_SCREEN, x, yopt + (line_height+2)*(n_show-1), COLOR_LIGHTGREY, COLOR_STD_BG,
"%-*s", (int) (item_width / font_width), more_str);
}
// show scroll bar
u32 bar_x = x + item_width + 2;
Expand Down Expand Up @@ -1076,15 +1077,15 @@ bool ShowInputPrompt(char* inputstr, u32 max_size, u32 resize, const char* alpha

DrawStringF(MAIN_SCREEN, x, y + str_height - 76, COLOR_STD_FONT, COLOR_STD_BG, "%c%-*.*s%c\n%-*.*s^%-*.*s",
(scroll) ? '<' : '|',
input_shown_size,
input_shown_size,
(int) input_shown_size,
(int) input_shown_size,
(scroll > inputstr_size) ? "" : inputstr + scroll,
(inputstr_size - (s32) scroll > input_shown_size) ? '>' : '|',
1 + cpos,
1 + cpos,
(int) 1 + cpos,
(int) 1 + cpos,
"",
input_shown_length - cpos,
input_shown_length - cpos,
(int) input_shown_length - cpos,
(int) input_shown_length - cpos,
""
);

Expand Down Expand Up @@ -1432,7 +1433,7 @@ int ShowBrightnessConfig(int set_brightness)
// draw initial UI stuff
DrawStringF(MAIN_SCREEN,
(SCREEN_WIDTH_MAIN - GetDrawStringWidth(brightness_str)) / 2,
(SCREEN_HEIGHT / 4) * 2, COLOR_STD_FONT, COLOR_STD_BG, brightness_str);
(SCREEN_HEIGHT / 4) * 2, COLOR_STD_FONT, COLOR_STD_BG, "%s", brightness_str);

// draw all color gradient bars
for (int x = 0; x < bar_width; x++) {
Expand Down
59 changes: 32 additions & 27 deletions arm9/source/godmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ u32 SplashInit(const char* modestr) {
}

if (modestr) DrawStringF(TOP_SCREEN, SCREEN_WIDTH_TOP - 10 - GetDrawStringWidth(modestr),
SCREEN_HEIGHT - 10 - GetDrawStringHeight(modestr), COLOR_STD_FONT, COLOR_TRANSPARENT, modestr);
SCREEN_HEIGHT - 10 - GetDrawStringHeight(modestr), COLOR_STD_FONT, COLOR_TRANSPARENT, "%s", modestr);

DrawStringF(BOT_SCREEN, pos_xb, pos_yb, COLOR_STD_FONT, COLOR_STD_BG, "%s\n%*.*s\n%s\n \n \n%s\n%s\n \n%s\n%s",
namestr, strnlen(namestr, 64), strnlen(namestr, 64),
"--------------------------------", "https://github.com/d0k3/GodMode9",
"Releases:", "https://github.com/d0k3/GodMode9/releases/", // this won't fit with a 8px width font
"Hourlies:", "https://d0k3.secretalgorithm.com/");
DrawStringF(BOT_SCREEN, pos_xu, pos_yu, COLOR_STD_FONT, COLOR_STD_BG, loadstr);
DrawStringF(BOT_SCREEN, pos_xu, pos_yu, COLOR_STD_FONT, COLOR_STD_BG, "%s", loadstr);
DrawStringF(BOT_SCREEN, pos_xb, pos_yu, COLOR_STD_FONT, COLOR_STD_BG, "built: " DBUILTL);

return 0;
Expand Down Expand Up @@ -330,7 +330,7 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, u32 curr_pan
snprintf(bytestr, 31, "%s Byte", numstr);
ResizeString(tempstr, bytestr, str_len_info, 8, false);
}
DrawStringF(MAIN_SCREEN, 4, info_start + 12 + 10, color_current, COLOR_STD_BG, tempstr);
DrawStringF(MAIN_SCREEN, 4, info_start + 12 + 10, color_current, COLOR_STD_BG, "%s", tempstr);
// path of file (if in search results)
if ((DriveType(curr_path) & DRV_SEARCH) && strrchr(curr_entry->path, '/')) {
char dirstr[256];
Expand All @@ -345,7 +345,7 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, u32 curr_pan

// right top - clipboard
DrawStringF(MAIN_SCREEN, SCREEN_WIDTH_MAIN - len_info, info_start, COLOR_STD_FONT, COLOR_STD_BG, "%*s",
len_info / FONT_WIDTH_EXT, (clipboard->n_entries) ? "[CLIPBOARD]" : "");
(int) (len_info / FONT_WIDTH_EXT), (clipboard->n_entries) ? "[CLIPBOARD]" : "");
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 : "", str_len_info, 8, true);
Expand All @@ -354,7 +354,7 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, u32 curr_pan
*tempstr = '\0';
if (clipboard->n_entries > n_cb_show) snprintf(tempstr, 60, "+ %lu more", clipboard->n_entries - n_cb_show);
DrawStringF(MAIN_SCREEN, SCREEN_WIDTH_MAIN - len_info - 4, info_start + 12 + (n_cb_show*10), COLOR_DARKGREY, COLOR_STD_BG,
"%*s", len_info / FONT_WIDTH_EXT, tempstr);
"%*s", (int) (len_info / FONT_WIDTH_EXT), tempstr);

// bottom: instruction block
char instr[512];
Expand All @@ -370,7 +370,7 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, u32 curr_pan
"R+←→ - Switch to prev/next pane\n",
(clipboard->n_entries) ? "SELECT - Clear Clipboard\n" : "SELECT - Restore Clipboard\n", // only if clipboard is full
"START - Reboot / [+R] Poweroff\nHOME button for HOME menu"); // generic end part
DrawStringF(MAIN_SCREEN, instr_x, SCREEN_HEIGHT - 4 - GetDrawStringHeight(instr), COLOR_STD_FONT, COLOR_STD_BG, instr);
DrawStringF(MAIN_SCREEN, instr_x, SCREEN_HEIGHT - 4 - GetDrawStringHeight(instr), COLOR_STD_FONT, COLOR_STD_BG, "%s", instr);
}

void DrawDirContents(DirStruct* contents, u32 cursor, u32* scroll) {
Expand Down Expand Up @@ -573,11 +573,11 @@ u32 FileHexViewer(const char* path) {
static bool show_instr = true;
static const char* instr = "Hexeditor Controls:\n \n↑↓→←(+R) - Scroll\nR+Y - Switch view\nX - Search / goto...\nA - Enter edit mode\nA+↑↓→← - Edit value\nB - Exit\n";
if (show_instr) { // show one time instructions
ShowPrompt(false, instr);
ShowPrompt(false, "%s", instr);
show_instr = false;
}

if (MAIN_SCREEN != TOP_SCREEN) ShowString(instr);
if (MAIN_SCREEN != TOP_SCREEN) ShowString("%s", instr);
memcpy(bottom_cpy, BOT_SCREEN, SCREEN_SIZE_BOT);

data = buffer;
Expand Down Expand Up @@ -708,7 +708,7 @@ u32 FileHexViewer(const char* path) {

// draw offset / ASCII representation
if (x_off >= 0) DrawStringF(screen, x_off - x0, y, cutoff ? COLOR_HVOFFS : COLOR_HVOFFSI,
COLOR_STD_BG, "%08X", (unsigned int) offset + curr_pos);
COLOR_STD_BG, "%08X", (unsigned int) (offset + curr_pos));
if (x_ascii >= 0) {
for (u32 i = 0; i < cols; i++)
DrawCharacter(screen, ascii[i], x_ascii - x0 + (FONT_WIDTH_EXT * i), y, COLOR_HVASCII, COLOR_STD_BG);
Expand Down Expand Up @@ -799,7 +799,7 @@ u32 FileHexViewer(const char* path) {
// check for user edits
u32 diffs = 0;
for (u32 i = 0; i < edit_bsize; i++) if (buffer[i] != buffer_cpy[i]) diffs++;
if (diffs && ShowPrompt(true, "You made edits in %i place(s).\nWrite changes to file?", diffs))
if (diffs && ShowPrompt(true, "You made edits in %lu place(s).\nWrite changes to file?", diffs))
if (!FileSetData(path, buffer, min(edit_bsize, (fsize - edit_start)), edit_start, false))
ShowPrompt(false, "Failed writing to file!");
data = buffer;
Expand Down Expand Up @@ -1295,8 +1295,9 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan
if (searchdrv > 0) optionstr[searchdrv-1] = "Open containing folder";
if (titleman > 0) optionstr[titleman-1] = "Open title folder";

int user_select = ShowSelectPrompt(n_opt, optionstr, (n_marked > 1) ?
"%s%0.0s\n(%lu files selected)" : "%s%s", pathstr, tidstr, n_marked);
int user_select = (int) ((n_marked > 1) ?
ShowSelectPrompt(n_opt, optionstr, "%s\n(%lu files selected)", pathstr, n_marked) :
ShowSelectPrompt(n_opt, optionstr, "%s%s", pathstr, tidstr));
if (user_select == hexviewer) { // -> show in hex viewer
FileHexViewer(file_path);
GetDirContents(current_dir, current_path);
Expand Down Expand Up @@ -1484,8 +1485,9 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan
if (setup > 0) optionstr[setup-1] = "Set as default";

// auto select when there is only one option
user_select = (n_opt <= 1) ? n_opt : (int) ShowSelectPrompt(n_opt, optionstr, (n_marked > 1) ?
"%s%0.0s\n(%lu files selected)" : "%s%s", pathstr, tidstr, n_marked);
user_select = (n_opt <= 1) ? n_opt : (int) ((n_marked > 1) ?
ShowSelectPrompt(n_opt, optionstr, "%s\n(%lu files selected)", pathstr, n_marked) :
ShowSelectPrompt(n_opt, optionstr, "%s%s", pathstr, tidstr));
if (user_select == mount) { // -> mount file as image
const char* mnt_drv_paths[] = { "7:", "G:", "K:", "T:", "I:", "D:" }; // maybe move that to fsdrive.h
if (clipboard->n_entries && (DriveType(clipboard->entry[0].path) & DRV_IMAGE))
Expand Down Expand Up @@ -1523,8 +1525,9 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan
if (cryptable_inplace) {
optionstr[0] = "Decrypt to " OUTPUT_PATH;
optionstr[1] = "Decrypt inplace";
user_select = (int) ShowSelectPrompt(2, optionstr, (n_marked > 1) ?
"%s%0.0s\n(%lu files selected)" : "%s%s", pathstr, tidstr, n_marked);
user_select = (int) ((n_marked > 1) ?
ShowSelectPrompt(2, optionstr, "%s\n(%lu files selected)", pathstr, n_marked) :
ShowSelectPrompt(2, optionstr, "%s%s", pathstr, tidstr));
} else user_select = 1;
bool inplace = (user_select == 2);
if (!user_select) { // do nothing when no choice is made
Expand Down Expand Up @@ -1577,8 +1580,9 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan
if (cryptable_inplace) {
optionstr[0] = "Encrypt to " OUTPUT_PATH;
optionstr[1] = "Encrypt inplace";
user_select = (int) ShowSelectPrompt(2, optionstr, (n_marked > 1) ?
"%s%0.0s\n(%lu files selected)" : "%s%s", pathstr, tidstr, n_marked);
user_select = (int) ((n_marked > 1) ?
ShowSelectPrompt(2, optionstr, "%s\n(%lu files selected)", pathstr, n_marked) :
ShowSelectPrompt(2, optionstr, "%s%s", pathstr, tidstr));
} else user_select = 1;
bool inplace = (user_select == 2);
if (!user_select) { // do nothing when no choice is made
Expand Down Expand Up @@ -1677,8 +1681,9 @@ u32 FileHandlerMenu(char* current_path, u32* cursor, u32* scroll, PaneData** pan
if (CheckVirtualDrive("E:")) {
optionstr[0] = "Install to SysNAND";
optionstr[1] = "Install to EmuNAND";
user_select = (int) ShowSelectPrompt(2, optionstr, (n_marked > 1) ?
"%s%0.0s\n(%lu files selected)" : "%s%s", pathstr, tidstr, n_marked);
user_select = (int) ((n_marked > 1) ?
ShowSelectPrompt(2, optionstr, "%s\n(%lu files selected)", pathstr, n_marked) :
ShowSelectPrompt(2, optionstr, "%s%s", pathstr, tidstr));
if (!user_select) return 0;
else to_emunand = (user_select == 2);
}
Expand Down Expand Up @@ -2195,7 +2200,7 @@ u32 HomeMoreMenu(char* current_path) {
if (sysinfo > 0) optionstr[sysinfo - 1] = "System info";
if (readme > 0) optionstr[readme - 1] = "Show ReadMe";

int user_select = ShowSelectPrompt(n_opt, optionstr, promptstr);
int user_select = ShowSelectPrompt(n_opt, optionstr, "%s", promptstr);
if (user_select == sdformat) { // format SD card
bool sd_state = CheckSDMountState();
char slabel[DRV_LABEL_LEN] = { '\0' };
Expand Down Expand Up @@ -2223,7 +2228,7 @@ u32 HomeMoreMenu(char* current_path) {
return 0;
}
else if (user_select == multi) { // switch EmuNAND offset
while (ShowPrompt(true, "Current EmuNAND offset is %06X.\nSwitch to next offset?", GetEmuNandBase())) {
while (ShowPrompt(true, "Current EmuNAND offset is %06lX.\nSwitch to next offset?", GetEmuNandBase())) {
if (clipboard->n_entries && (DriveType(clipboard->entry[0].path) & DRV_EMUNAND))
clipboard->n_entries = 0; // remove EmuNAND clipboard entries
DismountDriveType(DRV_EMUNAND);
Expand Down Expand Up @@ -2264,7 +2269,7 @@ u32 HomeMoreMenu(char* current_path) {
if (!seed_sys || BuildSeedInfo(NULL, true) != 0)
seed_sys = seed_emu = false;
}
ShowPrompt(false, "Built in " OUTPUT_PATH ":\n \n%18.18-s %s\n%18.18-s %s\n%18.18-s %s",
ShowPrompt(false, "Built in " OUTPUT_PATH ":\n \n%-18.18s %s\n%-18.18s %s\n%-18.18s %s",
TIKDB_NAME_ENC, tik_enc_sys ? tik_enc_emu ? "OK (Sys&Emu)" : "OK (Sys)" : "Failed",
TIKDB_NAME_DEC, tik_dec_sys ? tik_dec_emu ? "OK (Sys&Emu)" : "OK (Sys)" : "Failed",
SEEDINFO_NAME, seed_sys ? seed_emu ? "OK (Sys&Emu)" : "OK (Sys)" : "Failed");
Expand All @@ -2277,7 +2282,7 @@ u32 HomeMoreMenu(char* current_path) {
int emu = (CheckHealthAndSafetyInject("4:") == 0) ? (int) ++n_opt : -1;
if (sys > 0) optionstr[sys - 1] = "Restore H&S (SysNAND)";
if (emu > 0) optionstr[emu - 1] = "Restore H&S (EmuNAND)";
user_select = (n_opt > 1) ? ShowSelectPrompt(n_opt, optionstr, promptstr) : n_opt;
user_select = (n_opt > 1) ? ShowSelectPrompt(n_opt, optionstr, "%s", promptstr) : n_opt;
if (user_select > 0) {
InjectHealthAndSafety(NULL, (user_select == sys) ? "1:" : "4:");
GetDirContents(current_dir, current_path);
Expand Down Expand Up @@ -2719,14 +2724,14 @@ u32 GodMode(int entrypoint) {
if (current_dir->entry[c].marked) n_marked++;
}
if (n_marked) {
if (ShowPrompt(true, "Delete %u path(s)?", n_marked)) {
if (ShowPrompt(true, "Delete %lu path(s)?", n_marked)) {
u32 n_errors = 0;
ShowString("Deleting files, please wait...");
for (u32 c = 0; c < current_dir->n_entries; c++)
if (current_dir->entry[c].marked && !PathDelete(current_dir->entry[c].path))
n_errors++;
ClearScreenF(true, false, COLOR_STD_BG);
if (n_errors) ShowPrompt(false, "Failed deleting %u/%u path(s)", n_errors, n_marked);
if (n_errors) ShowPrompt(false, "Failed deleting %lu/%lu path(s)", n_errors, n_marked);
}
} else if (curr_entry->type != T_DOTDOT) {
char namestr[UTF_BUFFER_BYTESIZE(28)];
Expand Down Expand Up @@ -2881,7 +2886,7 @@ u32 GodMode(int entrypoint) {
u32 tmnum = 2;
if (!CheckSDMountState() || (tmnum = ShowSelectPrompt(
(CheckVirtualDrive("E:")) ? 4 : 2, tmoptionstr,
"Title manager menu.\nSelect titles source:", buttonstr))) {
"Title manager menu.\nSelect titles source:"))) {
const char* tpath = tmpaths[tmnum-1];
if (InitImgFS(tpath)) {
SetTitleManagerMode(true);
Expand Down
2 changes: 1 addition & 1 deletion arm9/source/system/xrq.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void XRQ_DumpRegisters(u32 xrq, u32 *regs)
u32 draw_y_upd = draw_y + draw_height - 10;

ClearScreen(MAIN_SCREEN, COLOR_STD_BG);
DrawStringF(MAIN_SCREEN, draw_x, draw_y, COLOR_STD_FONT, COLOR_STD_BG, dumpstr);
DrawStringF(MAIN_SCREEN, draw_x, draw_y, COLOR_STD_FONT, COLOR_STD_BG, "%s", dumpstr);

/* Dump STACK */
sp = regs[13] & ~0xF;
Expand Down
8 changes: 4 additions & 4 deletions arm9/source/utils/gameutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ u32 VerifyNcsdFile(const char* path) {
if (!size) continue;
if (VerifyNcchFile(path, offset, size) != 0) {
ShowPrompt(false, "%s\nContent%lu (%08lX@%08lX):\nVerification failed",
pathstr, i, size, offset, i);
pathstr, i, size, offset);
return 1;
}
}
Expand Down Expand Up @@ -789,7 +789,7 @@ u32 VerifyCiaFile(const char* path) {
if (!(cnt_index[index/8] & (1 << (7-(index%8))))) continue; // don't check missing contents
if (VerifyTmdContent(path, next_offset, chunk, titlekey) != 0) {
ShowPrompt(false, "%s\nID %08lX (%08llX@%08llX)\nVerification failed",
pathstr, getbe32(chunk->id), getbe64(chunk->size), next_offset, i);
pathstr, getbe32(chunk->id), getbe64(chunk->size), next_offset);
free(cia);
return 1;
}
Expand Down Expand Up @@ -927,7 +927,7 @@ u32 VerifyFirmFile(const char* path) {
void* section = ((u8*) firm_buffer) + sct->offset;
if (!(sct->size)) continue;
if (sha_cmp(sct->hash, section, sct->size, SHA256_MODE) != 0) {
ShowPrompt(false, "%s\nSection %u hash mismatch", pathstr, i);
ShowPrompt(false, "%s\nSection %lu hash mismatch", pathstr, i);
free(firm_buffer);
return 1;
}
Expand Down Expand Up @@ -3589,7 +3589,7 @@ u32 ShowGameCheckerInfo(const char* path) {
if (!ShowPrompt(state_verify < 0,
"%s\n%s %s Title\n \n"
"Title ID: %016llX\n"
"Title version: %u.%u.%u\n"
"Title version: %lu.%lu.%lu\n"
"Contents size: %s\n"
"%s\n%s \n"
"Ticket/TMD: %s/%s\n"
Expand Down
Loading

0 comments on commit c13bba4

Please sign in to comment.