]> Chaos Git - corbenik/corbenik.git/commitdiff
Fix as many warnings as I possibly can at the moment and -Werror on most
authorchaoskagami <chaos.kagami@gmail.com>
Thu, 18 Aug 2016 16:32:47 +0000 (12:32 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Thu, 18 Aug 2016 16:32:47 +0000 (12:32 -0400)
20 files changed:
common.mk
include/arm11.h
include/common.h
include/menu-backend.h
include/menu.h [new file with mode: 0644]
include/option.h
include/std/draw.h
include/std/memory.h
source/chainloader.c
source/firm/decryptor.c
source/firm/firm.c
source/menu-backend.c
source/menu.c
source/patch/emunand.c
source/patch/module.c
source/patch/reboot.c
source/std/abort.c
source/std/draw.c
source/std/fs.c
source/std/memory.c

index 216f4a96d1545527141a116cd8325cd50ef3a93b..326bcab14c0add03ed3bfa916a6220d693206286 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -6,17 +6,18 @@ SIZE_OPTIMIZATION = -Wl,--gc-sections -ffunction-sections
 
 REVISION := $(shell git rev-parse HEAD | head -c10)+$(shell git rev-list --count HEAD)
 
-AM_CFLAGS= -std=gnu11 -Os -g -fomit-frame-pointer -ffast-math \
+AM_CFLAGS= -std=gnu11 -Os -g -ffast-math \
        -Wpedantic -Wall -Wextra -Wcast-align -Wcast-qual \
        -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op \
        -Wmissing-include-dirs -Wredundant-decls \
        -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wswitch-default \
-       -Wundef -Wno-unused $(THUMBFLAGS) $(SIZE_OPTIMIZATION) $(INCPATHS) $(C9FLAGS) \
+       -Wundef -Wno-unused -Werror -Wno-error=cast-align -Wno-error=strict-overflow -Wno-error=pedantic \
+       $(THUMBFLAGS) $(SIZE_OPTIMIZATION) $(INCPATHS) $(C9FLAGS) \
        -fno-builtin -std=gnu11 -DREVISION=\"$(REVISION)\" \
        -DFW_NAME=\"corbenik\" $(PATHARGS)
 
 
-AM_LDFLAGS=-Wl,--use-blx,--pic-veneer,-q -nostdlib -Wl,-z,defs -lgcc \
-       -L$(top_srcdir)/external/libctr9/src
+AM_LDFLAGS=-Wl,--use-blx,--pic-veneer,-q -nostdlib -nodefaultlibs -Wl,-z,defs -lgcc \
+       -lc -L$(top_srcdir)/external/libctr9/src
 
 OCFLAGS=--set-section-flags .bss=alloc,load,contents
index 822eeb4a8b487b55aac42592c05bf667419e40dd..e4c3ba352eacaa583df020c4892cae2c279092d1 100644 (file)
@@ -32,7 +32,7 @@
 #define PDC1_FRAMEBUFFER_SETUP_FBB_ADDR_1 PDC1_FRAMEBUFFER_SETUP_REG(0x94)
 #define PDC1_FRAMEBUFFER_SETUP_FBB_ADDR_2 PDC1_FRAMEBUFFER_SETUP_REG(0x98)
 
-#define MAKE_FRAMEBUFFER_PIXFMT(col, plx, screen) ((col & 0b111) | ((plx & 1) << 5) | ((screen & 1) << 6) | 0b10000000001100000000)
+#define MAKE_FRAMEBUFFER_PIXFMT(col, plx, screen) ((col & 0x7) | ((plx & 1) << 5) | ((screen & 1) << 6) | 0x80300)
 
 #define RGBA8        0
 #define BGR8         1
index 53c17881795b4971e99c033d08845a9f7c12ccfe..e9d82f2695f57c939c4c643edda8c9a388aea555 100644 (file)
@@ -19,6 +19,8 @@
 #include <firm/decryptor.h>
 #include <firm/firm.h>
 
+#include <menu.h>
+#include <menu-backend.h>
 #include <arm11.h>
 #include <interrupt.h>
 #include <option.h>
index 16aa7208d80a9f74f022a170452cf17d70d1a636..3f46fb590472b48a9295eec7241757d66c15bc99 100644 (file)
@@ -1,6 +1,37 @@
 #ifndef __MENU_BACKEND_H__
 #define __MENU_BACKEND_H__
 
+/* Menu entry type. Determines how the menu is displayed and which (if any) options
+ * can be changed.
+ */
+enum type
+{
+    boolean_val = 0,      ///< Toggleable boolean
+    ranged_val = 1,       ///< N1 - N2, left and right to pick.
+    mask_val = 2,         ///< Bitmask allowed values.
+    not_option = 3,       ///< Skip over this.
+    call_fun = 4,         ///< Call a function. Treat (a) as (void)(*)(void).
+    boolean_val_n3ds = 5, ///< Toggle, but only show on n3DS
+    break_menu = 6        ///< Exit the menu (same as B)
+};
+
+typedef void (*func_call_t)(uint32_t data);
+
+struct range_str
+{
+    int a, b;
+};
+
+struct options_s
+{
+    int64_t index;     ///< Option index. Used for displaying values.
+    char name[64];     ///< Name of patch to display in menus.
+    char desc[256];    ///< Description of option, shown when pressing select
+    enum type allowed; ///< Misnomer, FIXME. Type of menu entry. See enum type.
+    uint32_t a, b;     ///< Should be union, FIXME. Data values used for menu entry.
+    uint8_t indent;    ///< Indentation/ownership level of menu.
+} __attribute__((packed));
+
 /* Set the accent foreground color for a screen.
  *
  * \param screen Which screen it should be set for
diff --git a/include/menu.h b/include/menu.h
new file mode 100644 (file)
index 0000000..7f39387
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef __MENU_H
+#define __MENU_H
+
+void reset();
+void poweroff();
+
+#endif
index 667e780eee4be69fff6b8ef99d6172801016aecb..e1a2f4fb5bec04352aa0252e151b19497268623d 100644 (file)
@@ -36,37 +36,6 @@ extern struct config_file config;
 extern struct config_file *config;
 #endif
 
-/* Menu entry type. Determines how the menu is displayed and which (if any) options
- * can be changed.
- */
-enum type
-{
-    boolean_val = 0,      ///< Toggleable boolean
-    ranged_val = 1,       ///< N1 - N2, left and right to pick.
-    mask_val = 2,         ///< Bitmask allowed values.
-    not_option = 3,       ///< Skip over this.
-    call_fun = 4,         ///< Call a function. Treat (a) as (void)(*)(void).
-    boolean_val_n3ds = 5, ///< Toggle, but only show on n3DS
-    break_menu = 6        ///< Exit the menu (same as B)
-};
-
-typedef void (*func_call_t)(uint32_t data);
-
-struct range_str
-{
-    int a, b;
-};
-
-struct options_s
-{
-    int64_t index;     ///< Option index. Used for displaying values.
-    char name[64];     ///< Name of patch to display in menus.
-    char desc[256];    ///< Description of option, shown when pressing select
-    enum type allowed; ///< Misnomer, FIXME. Type of menu entry. See enum type.
-    uint32_t a, b;     ///< Should be union, FIXME. Data values used for menu entry.
-    uint8_t indent;    ///< Indentation/ownership level of menu.
-} __attribute__((packed));
-
 #define OPTION_LOADER              2   ///< Use builtin loader module replacer.
 
 #define OPTION_SVCS                3   ///< Inject svcBackdoor (FIXME, misnomer)
index 9759b163a18179015159c803e6055e5d233911d7..0f24e5e77b5f303933ab57d03a827501a70aa856 100644 (file)
@@ -54,7 +54,7 @@ void screenshot();
  * \param y2 Y2 coordinate
  * \param color Color to fill with
  */
-void rect(void* channel, int x, int y, int x2, int y2, uint8_t color);
+void rect(void* channel, unsigned int x, unsigned int y, unsigned int x2, unsigned int y2, uint8_t color);
 
 /* Fill a line behind characters with a color.
  *
@@ -62,7 +62,7 @@ void rect(void* channel, int x, int y, int x2, int y2, uint8_t color);
  * \param y Which line to fill
  * \param color Color to fill with
  */
-void fill_line(void* channel, int y, uint8_t color);
+void fill_line(void* channel, unsigned int y, uint8_t color);
 
 /* Clears background image bitmaps.
  */
@@ -93,7 +93,7 @@ void clear_screens();
  * \param color_fg RGB color to draw character as (as uint32_t)
  * \param color_bg RGB color to draw behind character (as uint32_t)
  */
-void draw_character(uint8_t *screen, const uint32_t character, int ch_x, int ch_y, const uint32_t color_fg, const uint32_t color_bg);
+void draw_character(uint8_t *screen, const unsigned int character, unsigned int ch_x, unsigned int ch_y, const uint32_t color_fg, const uint32_t color_bg);
 
 /* Sets the font.
  *
@@ -112,14 +112,14 @@ void set_font(const char* filename);
  * \param buf Handle to output to.
  * \param c Character (as int) to output
  */
-void putc(void *buf, const int c);
+void putc(void *buf, int c);
 
 /* Outputs a string to a handle
  *
  * \param buf Handle to output to.
  * \param string String to output
  */
-void puts(void *buf, const char *string);
+void puts(void *buf, char *string);
 
 /* Flushes a handle
  *
@@ -159,11 +159,11 @@ void clear_disp(uint8_t *screen);
  * \param Format string.
  * \param ... Format arguments
  */
-void fprintf(void *channel, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
+void fprintf(void *channel, char *format, ...) __attribute__ ((format (printf, 2, 3)));
 
 /* See fprintf. Takes a va_list instead of variable arguments.
  */
-void vfprintf(void *channel, const char *format, va_list ap);
+void vfprintf(void *channel, char *format, va_list ap);
 
 #define BLACK     0
 #define BLUE      1
index 369e91a1267160df9f1f9c5c29891796e78d6622..7546d74b0bb040c37844522c9f42a734c97c320d 100644 (file)
@@ -4,7 +4,7 @@
 #include <stdint.h>
 #include <stddef.h>
 
-size_t strlen(const char *string);
+size_t strlen(char *string);
 void memcpy(void *dest, const void *src, size_t size);
 void memmove(void *dest, const void *src, size_t size);
 void memset(void *dest, const int filler, size_t size);
index 7cb1d77018be847102cb90ec27ef0eb3662b0840..775b8e56ddff664bf7fe0feaf5cbc696b11d89fb 100644 (file)
@@ -4,11 +4,8 @@
 #include <common.h>
 
 uint32_t current_chain_index = 0;
-
 struct options_s *chains = NULL;
 
-int show_menu(struct options_s *options, uint8_t *toggles);
-
 // TODO - The near same function is called in different places. It would
 //        be better to have a recursive listing that calls a function for
 //        each entry (it would cut code density)
@@ -76,6 +73,8 @@ void chainload_file(char* chain_file_data)
        memcpy((void*)0x23FFFE00, framebuffers, sizeof(struct framebuffers));
 
     ((void(*)(void*, uint32_t))0x24F00000)(chain_data, size + 256 + 8); // Size of payload + argv.
+
+    while(1);
 }
 
 void chain_file_hdl(char* fpath) {
index 32dbde3c05ee693f3cc16e5cfcc8587ddc2fdbaf..4196555771003187e48c9e9eebea41d19caea910 100644 (file)
@@ -21,7 +21,7 @@ ncch_getctr(const ncch_h *ncch, uint8_t *ctr, uint8_t type)
             ctr[i] = partitionID[7 - i]; // Convert to big endian & normal input
         ctr[8] = type;
     } else if (version == 1) {
-        int x = 0;
+        unsigned int x = 0;
         if (type == NCCHTYPE_EXHEADER)
             x = MEDIA_UNITS;
         else if (type == NCCHTYPE_EXEFS)
index bc2be84cfea2245807d11ab7c2d210e210a4d178..c8a5ac6275b60bd3402c2ad060d5bba053473e49 100644 (file)
@@ -188,12 +188,12 @@ decrypt_cetk_key(void *key, const void *cetk)
 {
        static int got_cetk = 0;
        uint8_t iv[AES_BLOCK_SIZE] = { 0 };
-       uint32_t sigtype = __builtin_bswap32(*(uint32_t *)cetk);
+       uint32_t sigtype = __builtin_bswap32(*(const uint32_t *)cetk);
 
        if (sigtype != SIG_TYPE_RSA2048_SHA256)
                return 1;
 
-       ticket_h *ticket = (ticket_h *)(cetk + sizeof(sigtype) + 0x13C);
+       const ticket_h *ticket = (const ticket_h *)((const uint8_t*)cetk + sizeof(sigtype) + 0x13C);
        if (ticket->ticketCommonKeyYIndex != 1)
                return 1;
 
@@ -222,7 +222,7 @@ decrypt_firm_title(firm_h *dest, ncch_h *ncch, uint32_t *size, void *key)
     uint8_t exefs_key[16] = { 0 };
     uint8_t exefs_iv[16] = { 0 };
 
-    fprintf(stderr, "  Decrypting FIRM container (size is %u blocks)\n", *size / AES_BLOCK_SIZE);
+    fprintf(stderr, "  Decrypting FIRM container (size is %lu blocks)\n", *size / AES_BLOCK_SIZE);
 
     setup_aeskey(0x16, key);
     use_aeskey(0x16);
@@ -240,7 +240,7 @@ decrypt_firm_title(firm_h *dest, ncch_h *ncch, uint32_t *size, void *key)
     exefs_h *exefs = (exefs_h *)((uint8_t *)ncch + ncch->exeFSOffset * MEDIA_UNITS);
     uint32_t exefs_size = ncch->exeFSSize * MEDIA_UNITS;
 
-    fprintf(stderr, "  Decrypting ExeFs for FIRM (size is %u blocks)\n", exefs_size / AES_BLOCK_SIZE);
+    fprintf(stderr, "  Decrypting ExeFs for FIRM (size is %lu blocks)\n", exefs_size / AES_BLOCK_SIZE);
 
     setup_aeskeyY(0x2C, exefs_key);
     use_aeskey(0x2C);
@@ -283,7 +283,7 @@ decrypt_arm9bin(arm9bin_h *header, uint64_t firm_title, uint8_t version)
     int size = atoi(header->size);
 
     use_aeskey(slot);
-    ctr_decrypt(arm9bin, arm9bin, size / AES_BLOCK_SIZE, AES_CNT_CTRNAND_MODE, header->ctr);
+    ctr_decrypt(arm9bin, arm9bin, (size_t)size / AES_BLOCK_SIZE, AES_CNT_CTRNAND_MODE, header->ctr);
 
     if (firm_title == NATIVE_FIRM_TITLEID)
         return *(uint32_t *)arm9bin != ARM9BIN_MAGIC;
@@ -460,6 +460,8 @@ boot_firm()
     *a11_entry = (uint32_t)firm_loc->a11Entry;
 
     ((void (*)())firm_loc->a9Entry)();
+
+    while(1);
 }
 
 int
index 92b13a5631717659f5181ba4c6800444fe105f33..fc58efac22ac8d0c9bf7acf8c734a9df3f464f8b 100644 (file)
@@ -99,7 +99,7 @@ show_menu(struct options_s *options, uint8_t *toggles)
             set_cursor(TOP_SCREEN, 0, (unsigned int)(i - window_top + 2) );
 
             int indent = options[i].indent;
-            for(int i=0; i < indent; i++)
+            for(int j=0; j < indent; j++)
                 fprintf(TOP_SCREEN, "  ");
 
             if (options[i].allowed == boolean_val || (is_n3ds && options[i].allowed == boolean_val_n3ds)) {
index 1e19a8adeaef5cf6c07da2331a43db6274899675..4905a4e9e55443f5ae2a29191a3f50277e73a4f0 100644 (file)
@@ -81,7 +81,7 @@ void patch_func(char* fpath) {
             strncpy(patches[current_menu_index_patches].desc, fpath, 255);
         else
             strncpy(patches[current_menu_index_patches].desc, p.desc, 255);
-        patches[current_menu_index_patches].index = p.uuid;
+        patches[current_menu_index_patches].index = (int64_t)p.uuid;
         patches[current_menu_index_patches].allowed = boolean_val;
         patches[current_menu_index_patches].a = 0;
         patches[current_menu_index_patches].b = 0;
index 642651361adf8cc2cb53aea61e662b81abc3cd9f..a217ac389c8beeb6dcd21d0d1b965935f2094eb2 100644 (file)
@@ -63,7 +63,7 @@ getSDMMC(uint8_t *pos, uint32_t size)
     const uint8_t pattern[] = { 0x21, 0x20, 0x18, 0x20 };
     const uint8_t *off = memfind(pos, size, pattern, 4);
 
-    uint32_t ret = *(uint32_t *)(off + 9) + *(uint32_t *)(off + 0xD);
+    uint32_t ret = *(const uint32_t *)(off + 9) + *(const uint32_t *)(off + 0xD);
 
     fprintf(stderr, "emunand: SDMMC code @ %lx\n", ret);
 
index aebee2793782f1f14a953413c4c781980f5015f5..ebe785788f2b07ae3e56b47ce0ea3b2b5afd1b2d 100644 (file)
@@ -45,7 +45,7 @@ patch_modules()
                 uint32_t need_units = (module->contentSize - sysmodule->contentSize);
 
                 memmove((uint8_t *)sysmodule + module->contentSize * 0x200, (uint8_t *)sysmodule + sysmodule->contentSize * 0x200,
-                        ((uint8_t *)firm_loc + firm_size) - ((uint8_t *)sysmodule + (module->contentSize * 0x200)));
+                        ((uint32_t)firm_loc + firm_size) - ((uint32_t)sysmodule + (module->contentSize * 0x200)));
 
                 sysmodule_section->size += 0x200 * need_units;
                 for (int i = section_index + 1; i < 4; i++) {
@@ -62,7 +62,7 @@ patch_modules()
             else if (module->contentSize < sysmodule->contentSize) {
                 // NOTE - This doesn't change the sysmodule section size; it isn't needed to do so.
                 fprintf(stderr, "Module: Shrink %lu units\n", sysmodule->contentSize - module->contentSize);
-                int remaining_size =
+                uint32_t remaining_size =
                     sysmodule_section->size - (((uint32_t)sysmodule + sysmodule->contentSize * 0x200) - ((uint32_t)firm_loc + sysmodule_section->offset));
                 // Sysmodule section size - (End location of this sysmodule -
                 // Sysmodule section) =>
index 2c0ab057b85d1c45bfeef214d921fb8b7b961293..96ebd6875c59d40d5dac4f91423a3ff6c15e1319 100644 (file)
@@ -35,7 +35,7 @@ patch_reboot()
     fprintf(stderr, "reboot: firmlaunch @ %lx\n", (uint32_t)off);
 
     // Firmlaunch function offset - offset in BLX opcode (A4-16 - ARM DDI 0100E) + 1
-    uint32_t fOpenOffset = (uint32_t)(off + 9 - (-((*(uint32_t *)off & 0x00FFFFFF) << 2) & (0xFFFFFF << 2)) - process9Offset + process9MemAddr);
+    uint32_t fOpenOffset = (uint32_t)(off + 9 - (-((*(uint32_t *)off & 0x00FFFFFF) << 2) & (0xFFFFFF << 2)) - (uint32_t)process9Offset + process9MemAddr);
 
     fprintf(stderr, "reboot: fopen @ %lx\n", fOpenOffset);
 
index 4a71952d7ce7a7890dc6bc947dafd71a02e9bdb7..48db2f1476cbf72fc322fea290fe5173e1e4a15c 100644 (file)
@@ -4,9 +4,7 @@
 #include <stdarg.h>
 #include <common.h>
 
-void poweroff();
-
-void abort(const char* x, ...) {
+void abort(char* x, ...) {
     va_list ap;
     va_start(ap, x);
 
index 557db37a42d6afb6bbf4eaea20557d04974584b7..65c38be240aee7f69b3c807158f225e80b67411c 100644 (file)
@@ -66,9 +66,9 @@ static uint32_t colors[16] = {
     0xffffff  // White
 }; // VGA color table.
 
-void rect(void* channel, int x, int y, int x2, int y2, uint8_t color) {
+void rect(void* channel, unsigned int x, unsigned int y, unsigned int x2, unsigned int y2, uint8_t color) {
     uint8_t* screen = NULL;
-    int height = 0;
+    unsigned int height = 0;
     if (channel == stdout) {
         screen = framebuffers->top_left;
         height = TOP_HEIGHT;
@@ -79,11 +79,11 @@ void rect(void* channel, int x, int y, int x2, int y2, uint8_t color) {
         return; // Invalid on non-screen displays.
     }
 
-    for(int y_a = y; y_a < y2; y_a++) {
-        for(int x_a = x; x_a < x2; x_a++) {
-            int xDisplacement = (x_a * SCREEN_DEPTH * height);
-            int yDisplacement = ((height - y_a - 1) * SCREEN_DEPTH);
-            int pos = xDisplacement + yDisplacement;
+    for(unsigned int y_a = y; y_a < y2; y_a++) {
+        for(unsigned int x_a = x; x_a < x2; x_a++) {
+            unsigned int xDisplacement = (x_a * SCREEN_DEPTH * height);
+            unsigned int yDisplacement = ((height - y_a - 1) * SCREEN_DEPTH);
+            unsigned int pos = xDisplacement + yDisplacement;
 
             screen[pos + 1] = colors[color & 0xF];
             screen[pos + 2] = colors[color & 0xF] >> 8;
@@ -93,8 +93,8 @@ void rect(void* channel, int x, int y, int x2, int y2, uint8_t color) {
     }
 }
 
-void fill_line(void* channel, int y, uint8_t color) {
-    int x2 = 0;
+void fill_line(void* channel, unsigned int y, uint8_t color) {
+    unsigned int x2 = 0;
     if (channel == stdout)
         x2 = TOP_WIDTH;
     else if (channel == stderr)
@@ -281,13 +281,13 @@ set_cursor(void *channel, unsigned int x, unsigned int y)
 }
 
 void
-draw_character(uint8_t *screen, const uint32_t character, int ch_x, int ch_y, const uint32_t color_fg, const uint32_t color_bg)
+draw_character(uint8_t *screen, const unsigned int character, unsigned int ch_x, unsigned int ch_y, const uint32_t color_fg, const uint32_t color_bg)
 {
     if (!isprint(character))
         return; // Don't output non-printables.
 
-    _UNUSED int width = 0;
-    int height = 0;
+    _UNUSED unsigned int width = 0;
+    unsigned int height = 0;
     uint8_t* buffer_bg;
     if (screen == framebuffers->top_left || screen == framebuffers->top_right) {
         width = TOP_WIDTH;
@@ -301,8 +301,8 @@ draw_character(uint8_t *screen, const uint32_t character, int ch_x, int ch_y, co
         return; // Invalid buffer.
     }
 
-    int x = (font_w + font_kern) * ch_x;
-    int y = font_h * ch_y;
+    unsigned int x = (font_w + font_kern) * ch_x;
+    unsigned int y = font_h * ch_y;
 
     if (x >= width || y >= height)
         return; // OOB
@@ -310,12 +310,12 @@ draw_character(uint8_t *screen, const uint32_t character, int ch_x, int ch_y, co
     unsigned int c_font_w = (font_w / 8) + (font_w % 8 ? 1 : 0);
 
     for (unsigned int yy = 0; yy < font_h; yy++) {
-        int xDisplacement   = (x * SCREEN_DEPTH * height);
-        int yDisplacement   = ((height - (y + yy) - 1) * SCREEN_DEPTH);
+        unsigned int xDisplacement   = (x * SCREEN_DEPTH * height);
+        unsigned int yDisplacement   = ((height - (y + yy) - 1) * SCREEN_DEPTH);
         unsigned int pos    = xDisplacement + yDisplacement;
 
-        int xDisplacementBg = (x * 3 * height);
-        int yDisplacementBg = ((height - (y + yy) - 1) * 3);
+        unsigned int xDisplacementBg = (x * 3 * height);
+        unsigned int yDisplacementBg = ((height - (y + yy) - 1) * 3);
         unsigned int pos_b  = xDisplacementBg + yDisplacementBg;
 
         unsigned char char_dat = font_data[(character - ' ') * (c_font_w * font_h) + yy];
@@ -446,17 +446,24 @@ ansi_statemach(void* buf, const int c)
                                                case 4: // Background color
                                    *color &= 0xf0; // Remove bg color.
                                    *color |= ((*val % 40) & 0xf);
+                            break;
+                        default: // ???
                             break;
                                        }
                                        *state = ANSI_END;
                                }
                        }
                        return 1;
+        default:
+            *state = TEXT;
+            return 1;
        }
+
+    return 0; // Should not be reached.
 }
 
 void
-putc(void *buf, const int c)
+putc(void *buf, int c)
 {
        if(ansi_statemach(buf, c) == 1) // Inside ANSI escape?
                return;
@@ -513,7 +520,7 @@ putc(void *buf, const int c)
                 cursor_x[0] = 0; // Reset to beginning of line.
                 break;
             default:
-                draw_character(screen, c, cursor_x[0], cursor_y[0], colors[(color[0] >> 4) & 0xF], colors[color[0] & 0xF]);
+                draw_character(screen, (unsigned int)c, cursor_x[0], cursor_y[0], colors[(color[0] >> 4) & 0xF], colors[color[0] & 0xF]);
 
                 cursor_x[0]++;
 
@@ -526,12 +533,12 @@ putc(void *buf, const int c)
 }
 
 void
-puts(void *buf, const char *string)
+puts(void *buf, char *string)
 {
     if ((buf == stdout || buf == stderr) && kill_output)
         return;
 
-    char *ref = (char *)string;
+    char *ref = string;
 
     while (ref[0] != 0) {
         putc(buf, ref[0]);
@@ -543,10 +550,11 @@ void
 put_int64(void *channel, int64_t n, int length)
 {
     char conv[32], out[32];
+    size_t i = 0, sign = 0;
+
     memset(conv, 0, 32);
     memset(out, 0, 32);
 
-    int i = 0, sign = 0;
     if (n < 0) {
         n = -n;
         sign = 1;
@@ -563,8 +571,8 @@ put_int64(void *channel, int64_t n, int length)
     if (length > 0)
         out[length] = '\0';
 
-    int len = strlen(conv);
-    for (int i = 0; i < len; i++)
+    size_t len = strlen(conv);
+    for (i = 0; i < len; i++)
         out[i] = conv[(len - 1) - i];
 
     puts(channel, out);
@@ -574,10 +582,11 @@ void
 put_uint64(void *channel, uint64_t n, int length)
 {
     char conv[32], out[32];
+    size_t i = 0;
+
     memset(conv, 0, 32);
     memset(out, 0, 32);
 
-    int i = 0;
     do {
         conv[i++] = (n % 10) + '0';
     } while ((n /= 10) != 0);
@@ -585,8 +594,8 @@ put_uint64(void *channel, uint64_t n, int length)
     if (length > 0)
         out[length] = '\0';
 
-    int len = strlen(conv);
-    for (int i = 0; i < len; i++)
+    size_t len = strlen(conv);
+    for (i = 0; i < len; i++)
         out[i] = conv[(len - 1) - i];
 
     puts(channel, out);
@@ -630,7 +639,7 @@ fflush(void *channel)
 int disable_format = 0;
 
 void
-vfprintf(void *channel, const char *format, va_list ap)
+vfprintf(void *channel, char *format, va_list ap)
 {
     if ((channel == stdout || channel == stderr) && kill_output)
         return;
@@ -671,15 +680,10 @@ vfprintf(void *channel, const char *format, va_list ap)
                             break;
                     }
                     break;
-                case 's':
-                    //         For now, this warning stays.
-                    disable_format = 1; // Disable format strings.
-                    fprintf(channel, va_arg(ap, char *));
-                    disable_format = 0; // Reenable.
-                    break;
                 case 'c':
                     putc(channel, va_arg(ap, int));
                     break;
+                case 's':
                 case 'p':
                     puts(channel, va_arg(ap, char *));
                     break;
@@ -709,7 +713,7 @@ vfprintf(void *channel, const char *format, va_list ap)
 }
 
 void
-fprintf(void *channel, const char *format, ...)
+fprintf(void *channel, char *format, ...)
 {
     // The output suppression is in all the functions to minimize overhead.
     // Function calls and format conversions take time and we don't just want
@@ -726,7 +730,7 @@ fprintf(void *channel, const char *format, ...)
 }
 
 void
-printf(void *channel, const char *format, ...)
+printf(char *format, ...)
 {
     va_list ap;
     va_start(ap, format);
index d4204f8345bde823eada2aa9fa655ad0b3288e9e..85998101cd05b893c93903226206192992a18c1b 100644 (file)
@@ -12,7 +12,7 @@ static int set_up_fs = 0;
 // This function is based on PathDeleteWorker from GodMode9.
 // It was easier to just import it.
 int
-recurse_call_back(char *fpath, void (*call_fun)(char*))
+recurse_call_back(char *fpath, void (*call_fun_param)(char*))
 {
     FILINFO fno;
     DIR pdir;
@@ -35,9 +35,9 @@ recurse_call_back(char *fpath, void (*call_fun)(char*))
 
         if (f2.fattrib & AM_DIR) {
             // return value won't matter
-            recurse_call_back(fpath, call_fun);
+            recurse_call_back(fpath, call_fun_param);
         } else {
-            call_fun(fpath);
+            call_fun_param(fpath);
         }
     }
 
@@ -45,15 +45,15 @@ recurse_call_back(char *fpath, void (*call_fun)(char*))
     --fname;
     fname[0] = 0;
 
-    call_fun(fpath);
+    call_fun_param(fpath);
 
     return 0;
 }
 
-void recurse_call(char *name, void (*call_fun)(char*)) {
+void recurse_call(char *name, void (*call_fun_param)(char*)) {
     char fpath[256];
     strncpy(fpath, name, 256);
-    recurse_call_back(fpath, call_fun);
+    recurse_call_back(fpath, call_fun_param);
 }
 
 int
@@ -61,7 +61,7 @@ rrmdir(char *name)
 {
     char fpath[256];
     strncpy(fpath, name, 256);
-    recurse_call(fpath, f_unlink);
+    recurse_call(fpath, (void (*)(char*))f_unlink);
     return 0;
 }
 
index fa30d53f811c25d598b5e47c1e68836781af3f40..6609d6c312f8e3c7dda4dfd18b4e901ff4bd8769 100644 (file)
@@ -4,12 +4,12 @@
 #include <stddef.h>
 
 size_t
-strlen(const char *string)
+strlen(char *string)
 {
-    char *string_end = (char *)string;
+    char *string_end = string;
     while (string_end[0])
         string_end++;
-    return string_end - string;
+    return (size_t)(string_end - string);
 }
 
 size_t
@@ -46,7 +46,7 @@ void
 memmove(void *dest, const void *src, size_t size)
 {
     // memcpy does the job of moving backwards just fine
-    if (dest < src || (uint8_t*)src + size <= (uint8_t*)dest) {
+    if (dest < src || (const uint8_t*)src + size <= (uint8_t*)dest) {
         memcpy(dest, src, size);
         return;
     }