]> Chaos Git - corbenik/corbenik.git/commitdiff
Change a few flags (for now) and fix a bunch of warnings
authorchaoskagami <chaos.kagami@gmail.com>
Sat, 30 Jul 2016 04:58:04 +0000 (00:58 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Sat, 30 Jul 2016 04:58:04 +0000 (00:58 -0400)
common.mk
source/display.c
source/firm/firm.c
source/interp.c
source/menu.c
source/patch/module.c
source/patch/reboot.c
source/patch/svc.c
source/patcher.c
source/std/abort.c
source/std/draw.c

index 403e7cc69f1748bbcab1aa6a7a9cabfd31769bd6..8417af27f94eb3e8216eae555ceec00df9073b89 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -9,10 +9,10 @@ REVISION := $(shell git rev-parse HEAD | head -c10)+$(shell git rev-list --count
 AM_CFLAGS= -std=gnu11 -Os -g -fomit-frame-pointer -ffast-math \
        -Wpedantic -Wall -Wextra -Wcast-align -Wcast-qual \
        -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op \
-       -Wmissing-declarations -Wmissing-include-dirs -Wredundant-decls \
+       -Wmissing-include-dirs -Wredundant-decls \
        -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wswitch-default \
        -Wundef -Wno-unused $(THUMBFLAGS) $(SIZE_OPTIMIZATION) $(INCPATHS) $(C9FLAGS) \
-       -fshort-wchar -fno-builtin -std=gnu11 -DVERSION=\"$(REVISION)\" \
+       -fshort-wchar -fno-builtin -std=gnu11 -DREVISION=\"$(REVISION)\" \
        -DFW_NAME=\"corbenik\" $(PATHARGS)
 
 
index a58dd00d2ed086af5c17bddd7625f59c80acf217..ab70d45d5ce22ea3957981ea4fb03f2a9a64709e 100644 (file)
@@ -28,7 +28,9 @@ show_menu(struct options_s *options, uint8_t *toggles)
     int cursor_min = -1;
     int cursor_max = -1;
     int exit = 0;
-    int window_size = (TOP_HEIGHT / font_h) - 3;
+
+    // Font height is user-controlled. Realistically, if it's higher than a signed int, that's not my fault.
+    int window_size = (TOP_HEIGHT / (int)font_h) - 3;
     int window_top = 0, window_bottom = window_size;
     int less_mode = 0;
 
@@ -82,12 +84,12 @@ show_menu(struct options_s *options, uint8_t *toggles)
             header("A:Enter B:Back DPAD:Nav Select:Info");
 
 
-        int i = window_top;
-        while (options[i].index != -1) { // -1 Sentinel.
+        for (int i = window_top; options[i].index != -1; ++i) { // -1 Sentinel.
             if (i > window_bottom)
                 break;
 
-            set_cursor(TOP_SCREEN, 0, i-window_top+2);
+            // NOTE - Signed to unsigned conversion here. Again, not an issue.
+            set_cursor(TOP_SCREEN, 0, (unsigned int)(i - window_top + 2) );
 
             if (options[i].allowed == boolean_val || (is_n3ds && options[i].allowed == boolean_val_n3ds)) {
                 if (cursor_y == i) {
@@ -120,7 +122,6 @@ show_menu(struct options_s *options, uint8_t *toggles)
                     accent_color(TOP_SCREEN, 1);
                 fprintf(TOP_SCREEN, "%s\x1b[0m", options[i].name);
             }
-            ++i;
         }
 
         uint32_t key = wait_key(1);
@@ -192,6 +193,8 @@ show_menu(struct options_s *options, uint8_t *toggles)
                     clear_disp(TOP_SCREEN);
                 }
                 break;
+            default:
+                break;
         }
 
         if (cursor_y < cursor_min)
index 0a54d640113b1141af8797f747c8b162fbe9ff04..07a03b8fc13f194a50cd87a6b535892210bf1af3 100644 (file)
@@ -37,10 +37,11 @@ int decrypt_arm9bin(arm9bin_h *header, uint64_t firm_title, uint8_t version);
 void dump_firm(firm_h** buffer, uint8_t index) {
     if (*buffer != NULL) return;
 
-    uint32_t firm_offset = 0x0B130000 + (index % 2) * 0x400000,
-             firm_size   = 0x00100000; // 1MB, because
+    // NOTE - Cast, because GCC is making assumptions about 'index'.
+    uint32_t firm_offset = (uint32_t)(0x0B130000 + (index % 2) * 0x400000),
+             firm_b_size = 0x00100000; // 1MB, because
 
-    buffer[0] = static_allocate(firm_size);
+    buffer[0] = static_allocate(firm_b_size);
 
     uint8_t ctr[0x10],
             cid[0x10],
@@ -48,7 +49,7 @@ void dump_firm(firm_h** buffer, uint8_t index) {
 
     firm_h* firm = buffer[0];
 
-    if (sdmmc_nand_readsectors(firm_offset / SECTOR_SIZE, firm_size / SECTOR_SIZE, (uint8_t*)firm))
+    if (sdmmc_nand_readsectors(firm_offset / SECTOR_SIZE, firm_b_size / SECTOR_SIZE, (uint8_t*)firm))
         abort("  Failed to read NAND!\n");
 
     fprintf(stderr, "  Read FIRM%u off NAND.\n", index);
@@ -60,7 +61,7 @@ void dump_firm(firm_h** buffer, uint8_t index) {
 
     use_aeskey(0x06);
     set_ctr(ctr);
-    aes(firm, firm, firm_size / AES_BLOCK_SIZE, ctr, AES_CTR_MODE);
+    aes(firm, firm, firm_b_size / AES_BLOCK_SIZE, ctr, AES_CTR_MODE);
 
     fprintf(stderr, "  AES decrypted FIRM%u.\n", index);
 
@@ -489,7 +490,7 @@ find_proc9(firm_h *firm, firm_section_h *process9, exefs_h **p9exefs)
                         *p9exefs = (exefs_h *)(p9exheader + 1);
                         process9->address = p9exheader->sci.textCodeSet.address;
                         process9->size = (*p9exefs)->fileHeaders[0].size;
-                        process9->offset = (void *)((*p9exefs) + 1) - (void *)firm;
+                        process9->offset = (uint32_t)((*p9exefs) + 1) - (uint32_t)firm;
                         fprintf(stderr, "  Found process9 offset\n");
                         return 0;
                     }
index dbcfdba4fc5557ac14fd0249167719320cbcbd28..aff685716958af611a3f3870be38a1a5d3022508 100644 (file)
@@ -440,7 +440,7 @@ exec_bytecode(uint8_t *bytecode, uint32_t len, uint8_t* stack, uint32_t stack_si
                 break;
             case OP_SEEK: // Jump to offset if greater than or equal
                 code++;
-                offset = code[0] + (code[1] << 8) + (code[2] << 16) + (code[3] << 24);
+                offset = (uint32_t)(code[0] + (code[1] << 8) + (code[2] << 16) + (code[3] << 24));
                 if (debug) {
 #ifdef LOADER
                     log("seek\n");
index 36adf095a31dc48c04fe16ea9159a1c3e6773dfc..e2ef4e3bd1449a97e0d575804ef88eabf9a50f4a 100644 (file)
@@ -56,7 +56,7 @@ static struct options_s options[] = {
     //    { IGNORE_BROKEN_SHIT,  "Allow unsafe options", boolean_val, 0, 0 },
 
     // Sentinel.
-    { -1, "", "", 0, -1, -1 }, // cursor_min and cursor_max are stored in the last two.
+    { -1, "", "", 0, 0, 0 }, // cursor_min and cursor_max are stored in the last two.
 };
 
 extern unsigned int font_w;
@@ -187,7 +187,7 @@ static struct options_s info_d[] = {
     { 0, "  Native FIRM: ", "The version of NATIVE_FIRM in use.", not_option, 0, 0},
     { 0, "  AGB FIRM:    ", "The version of AGB_FIRM in use. This is used to run GBA games.", not_option, 0, 0},
     { 0, "  TWL FIRM:    ", "The version of TWL_FIRM in use. This is used to run DS games and DSiWare.", not_option, 0, 0},
-    { 0, "  " FW_NAME ":    " VERSION " (" REL ")", FW_NAME "'s version.", not_option, 0, 0},
+    { 0, "  " FW_NAME ":    " REVISION " (" REL ")", FW_NAME "'s version.", not_option, 0, 0},
     { -1, "", "", not_option, 0, 0 }
 };
 static int is_setup_info = 0;
@@ -296,7 +296,7 @@ static struct options_s main_s[] = {
     { 0, "Boot Firmware",      "Generates caches, patches the firmware, and boots it.\nMake sure to 'Save Configuration' first if any options changed.", break_menu, 0, 0 },
 
     // Sentinel.
-    { -1, "", "", 0, -1, -1 }, // cursor_min and cursor_max are stored in the last two.
+    { -1, "", "", 0, 0, 0 }, // cursor_min and cursor_max are stored in the last two.
 };
 
 void
index 264394496d2579e5e567634031c5dbdc32b4cb61..f630c49524f833e1b4a59ffdccaa96322392b3e8 100644 (file)
@@ -2,7 +2,8 @@
 
 /* Not possible to be implemented as bytecode. Hey, can't win em all. */
 
-PATCH(modules)
+int
+patch_modules()
 {
     // TODO - load other module cxis here
     FILE *f = fopen(PATH_MODULES "/loader.cxi", "r");
@@ -71,7 +72,7 @@ PATCH(modules)
             // Copy the module into the firm
             memcpy(sysmodule, module, module->contentSize * 0x200);
         }
-        sysmodule = (ncch_h *)((uintptr_t)sysmodule + sysmodule->contentSize * 0x200);
+        sysmodule = (ncch_h *)((uint32_t)sysmodule + sysmodule->contentSize * 0x200);
     }
 
     fprintf(stderr, "Module: injected modules.\n");
index e787c6d64e2edae2f5e8f569c8d45f52f6666b17..00765d0ea40be5c3e21c1f4a6bb75c16f3b7f30d 100644 (file)
@@ -1,3 +1,6 @@
+/* This code was all nicked from Luma (before the GPL headers were corrected by TuxSH)
+   Someone please remind me to fix this code.*/
+
 #include <common.h>
 #include <ctr9/io.h>
 
index 97cca8021049dce1711108591700332c28607ada..5d40e7c8fce1f340ab395b18595ef07bd8959878 100644 (file)
@@ -6,7 +6,8 @@ int svc_offs_init = 0;
 
 // This code handles restoration of backdoor
 
-PATCH(services)
+int
+patch_services()
 {
     if (svc_offs_init == 0) {
         arm11Section1 = (uint8_t *)firm_loc + firm_loc->section[1].offset;
@@ -41,7 +42,7 @@ PATCH(services)
         fclose(data);
 
         //        memcpy(svc_tab_open, svcbackdoor, sizeof(svcbackdoor));
-        svcTable[0x7B] = 0xFFFF0000 + ((uint8_t *)svc_tab_open - (uint8_t *)exceptionsPage);
+        svcTable[0x7B] = 0xFFFF0000 + (uint32_t)((uint8_t *)svc_tab_open - (uint8_t *)exceptionsPage);
 
         svc_tab_open += size;
 
index 2d6f9c56cd3b745921e08175997896b6c734fee1..46029ae068247ced0047c5eab0ace8eb9d5c61e9 100644 (file)
@@ -3,8 +3,6 @@
 
 // TODO - Basically all this needs to move to patcher programs.
 
-uint32_t wait_key(int sleep);
-
 extern int patch_services();
 extern int patch_modules();
 extern int patch_reboot();
index d2179501347174523597284e7a011415c9a1e3a4..4a71952d7ce7a7890dc6bc947dafd71a02e9bdb7 100644 (file)
@@ -5,7 +5,6 @@
 #include <common.h>
 
 void poweroff();
-uint32_t wait_key(int sleep);
 
 void abort(const char* x, ...) {
     va_list ap;
index 8b6029788c0d14238c6f0cd59b3ce063b39c00a0..dc7582c5f599b91dc2c8edcbc9ab81110a2d1d8a 100644 (file)
@@ -622,7 +622,11 @@ vfprintf(void *channel, const char *format, va_list ap)
                     }
                     break;
                 case 's':
-                    // Using puts isn't correct here...
+                    // FIXME - Substring ANSI colors will screw up hard, so don't do that.
+                    //         once the color handling is moved to putc as a state machine this
+                    //         will no longer be an issue.
+
+                    //         For now, this warning stays.
                     disable_format = 1; // Disable format strings.
                     fprintf(channel, va_arg(ap, char *));
                     disable_format = 0; // Reenable.