]> Chaos Git - corbenik/corbenik.git/commitdiff
Minor cleanup.
authorchaoskagami <chaos.kagami@gmail.com>
Sat, 8 Oct 2016 15:11:26 +0000 (11:11 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Sat, 8 Oct 2016 15:11:26 +0000 (11:11 -0400)
I recently learned that the C standard differentiates between empty parameters
and (void) parameters (wow me) so clean up to clarify what does and doesn't take
arguments.

Functions called from menus are left as accepts-any to prevent GCC from potentially
fucking up optimizations.

17 files changed:
configure.ac
include/input.h
include/interrupt.h
include/menu.h
include/option.h
include/patch_format.h
include/patcher.h
include/std/allocator.h
include/std/draw.h
source/config-backend-file.c
source/input.c
source/interrupt.c
source/main.c
source/menu.c
source/patcher.c
source/std/allocator.c
source/std/draw.c

index 0ea6e4ec65376770db9615f650444e43e53d7317..5c0e9fef7e0ec13140a9bc3fa8fc5a2c0be68e4e 100644 (file)
@@ -52,7 +52,7 @@ ldflags:         ${LDFLAGS}
 ocflags:         ${OCFLAGS}
 
 Chainloader:     ${CHAINLOADER}
-Chainloader:     ${UNITTESTS}
+Unit tests:      ${UNITTESTS}
 "
 
 AC_OUTPUT
index be263f39b5265aeb4711b619a4ed0eea80b9de6f..7fdfa79dab73e31647f7bf8b5df799f080b7a654 100644 (file)
@@ -13,6 +13,6 @@ uint32_t wait_key(_UNUSED int sleep);
 /* Displays a prompt on the bottom screen if the relevant option is enabled and waits on input
  * to continue.
  */
-void wait();
+void wait(void);
 
 #endif
index 8a25f56c6c33842e27e94f403b17a62400a0a63a..e5146849a4daf576fd35b8410615e015bf5db929 100644 (file)
@@ -3,6 +3,6 @@
 
 /* Install interrupt handlers via libctr9.
  */
-void install_interrupts();
+void install_interrupts(void);
 
 #endif
index 7f3938774ea8c66fa07fb1095a37bf9789ba82a5..c4880703e39cd5d279162b892fafe82fe38170fd 100644 (file)
@@ -4,4 +4,7 @@
 void reset();
 void poweroff();
 
+void reset_patch_menu(void);
+void add_patch_menu(const char *name);
+
 #endif
index ec93fb8bdd2cbfe873baa9a3b92d9ce268927c6e..851a06ea8c62d0b32f4ba494c9bf58575b4ef561 100644 (file)
@@ -95,11 +95,11 @@ extern struct config_file *config;
 
 /* Loads the config file off SD from the configured location.
  */
-void load_config();
+void load_config(void);
 
 /* Saves the config file to SD at the configured location.
  */
-void save_config();
+void save_config(void);
 
 /* Changes an option according to internal rules. Used in menus.
  */
index c16b6007ee7d871ca59588da790e8a22aa04cf6a..75c56f0a8a067a0c049a96cdd0495758e9d99e6c 100644 (file)
@@ -27,6 +27,7 @@
 #define PATH_MODULE_TWL      PATH_MODULES "/twl"        ///< TWL FIRM Sysmodule location
 
 #define PATH_PATCHES         SBINDIR                 ///< Patch binary folder.
+#define PATH_AUX_PATCHES     BINDIR                  ///< Patch binary folder.
 
 #define PATH_BITS            LIBEXECDIR              ///< Path to misc bits we need (emunand code, reboot code, etc)
 
index 17ae1380cb8f060ce3eddfad6cfe9e3e36445bb9..456e95f5f17dfe51fa4f0ccc034b35e61390e3a1 100644 (file)
@@ -11,7 +11,7 @@ int patch_firm_all(uint64_t tid, firm_h* firm, const char* module_path);
  *
  * \return Zero on success.
  */
-int generate_patch_cache();
+int generate_patch_cache(void);
 
 int patch_svc_calls(firm_h* firm_loc);
 int patch_reboot(firm_h* firm_loc);
index ae96dc6d9fa3db08e53348461bce52bbfc74a482..c0fad2b74485b4152ef10d0b81549dcf6e92a07d 100644 (file)
@@ -16,7 +16,7 @@ void *sbrk(size_t bytes);
 
 /* Prints stats for allocation to stderr.
  */
-void print_alloc_stats();
+void print_alloc_stats(void);
 
 /* Allocate memory for use (debugging only, don't call)
  *
index 7ac1c7a8504fdc33a43419d3d6b4ea039d2a4aad..5ef14df85084c5cee037d6f2381b750aefdf6507 100644 (file)
@@ -39,11 +39,11 @@ extern struct framebuffers *framebuffers;
 
 /* Initialize stdlib functionality. Must be called before ANY other functions here can be used.
  */
-void std_init();
+void std_init(void);
 
 /* Take a screenshot and save to path.
  */
-void screenshot();
+void screenshot(void);
 
 /* Fill an area on the screen with a color.
  *
@@ -66,7 +66,7 @@ void fill_line(void* channel, unsigned int y, uint8_t color);
 
 /* Clears background image bitmaps.
  */
-void clear_bg();
+void clear_bg(void);
 
 /* Loads top background image from a path.
  *
@@ -82,7 +82,7 @@ void load_bg_bottom(const char* fname_bottom);
 
 /* Clears the displays either to black or the background image.
  */
-void clear_screens();
+void clear_screens(void);
 
 /* Draws a character to the screen. Internal use.
  *
index 3ea12e2bb0d043b35b85b2041b8df4dd2652335b..abef848f337e65959136c125d4c0b04227904868 100644 (file)
@@ -8,10 +8,8 @@ char *config_file_path = NULL;
 int changed_consoles = 0;
 uint32_t cid[4];
 
-void list_patches_build(const char *name, int desc_is_fname);
-
 void
-regenerate_config()
+regenerate_config(void)
 {
     for(int i=0; i < 4; i++)
         config->magic[i] = CONFIG_MAGIC[i];
@@ -28,7 +26,7 @@ regenerate_config()
 }
 
 void
-mk_structure()
+mk_structure(void)
 {
     f_mkdir(PREFIX);
       f_mkdir(LIBEXECDIR);
@@ -56,7 +54,7 @@ mk_structure()
 }
 
 void
-update_config()
+update_config(void)
 {
     int updated = 0;
 
@@ -74,10 +72,10 @@ update_config()
     }
 }
 
-void get_cfg_path();
+void get_cfg_path(void);
 
 void
-load_config()
+load_config(void)
 {
     mk_structure(); // Make directory structure if needed.
 
@@ -138,13 +136,15 @@ load_config()
         }
     }
 
-    list_patches_build(PATH_PATCHES, 0);
+    reset_patch_menu();
+    add_patch_menu(PATH_PATCHES);
+    add_patch_menu(PATH_AUX_PATCHES);
 
     update_config();
 }
 
 void
-save_config()
+save_config(void)
 {
     if (changed_consoles) {
         FILE* f = fopen(SYSCONFDIR "/current-nand-cid", "w");
index 15da0d5036b257cca8255353e46125110ae417d7..2cf88112230e7e4f9e61f05bf3e44415b30dead3 100644 (file)
@@ -41,7 +41,7 @@ wait_key(_UNUSED int sleep)
 extern int doing_autoboot;
 
 void
-wait()
+wait(void)
 {
     if (get_opt_u32(OPTION_TRACE) && !doing_autoboot) {
         fprintf(stderr, "[Waiting...]");
index 5bbb62eec712783a1152ce7c69fba922ecdec98a..1800e31f36ffe77c5173567edcde179841ec3e1d 100644 (file)
@@ -45,7 +45,7 @@ void fiq_INT(_UNUSED uint32_t* regs) {
     fprintf(stderr, "FIQ called. Returning.\n");
 }
 
-void install_interrupts() {
+void install_interrupts(void) {
     ctr_interrupt_prepare();
     ctr_irq_initialize();
 
index 5d63a52736f6a8066972bc2fe340cb1cdf15ac02..f7a363b89da98764fb7677372ba41d7cc1723125 100644 (file)
@@ -9,8 +9,8 @@
 int is_n3ds = 0;
 int doing_autoboot = 0;
 
-int menu_handler();
-void shut_up();
+int menu_handler(void);
+void shut_up(void);
 
 extern int changed_consoles;
 
index 8f24501cc57401f7308538aada0580173785b792..659e2b04296d38c8ee6459ec551fa3496956a7a5 100644 (file)
@@ -10,7 +10,6 @@ uint8_t *enable_list;
 struct options_s *firm = NULL;
 
 static int current_menu_index_patches = 0;
-static int desc_is_fname_sto = 0;
 
 #if defined(CHAINLOADER) && CHAINLOADER == 1
 void chainload_menu();
@@ -121,7 +120,7 @@ static struct options_s config_opts[] = {
       "Internal options for the CFW.\nThese are part of " FW_NAME " itself.",
       option, options, (void(*)(void*))show_menu, NULL, 0, 0 },
     { "Patches",
-      "External bytecode patches found in `" PATH_PATCHES "`.\nYou can choose which to enable.",
+      "External bytecode patches found in `" PATH_PATCHES "` and `" PATH_AUX_PATCHES "` .\nYou can choose which to enable.",
       option, NULL, (void(*)(void*))show_menu, NULL, 0, 0 },
 
     // Sentinel.
@@ -219,10 +218,7 @@ void patch_func(char* fpath) {
             return;
 
         patches[current_menu_index_patches].name = strdup_self(p.name);
-        if (desc_is_fname_sto)
-            patches[current_menu_index_patches].param = strdup_self(fpath);
-        else
-            patches[current_menu_index_patches].desc = strdup_self(p.desc);
+        patches[current_menu_index_patches].desc = strdup_self(p.desc);
 
         uint32_t val = p.uuid;
 
@@ -235,9 +231,6 @@ void patch_func(char* fpath) {
         patches[current_menu_index_patches].func  = patch_set_enable;
         patches[current_menu_index_patches].value = patch_get_enable;
 
-        if (desc_is_fname_sto)
-            enable_list[p.uuid] = 0;
-
         current_menu_index_patches++;
     }
 }
@@ -274,15 +267,9 @@ poweroff()
     ctr_system_poweroff();
 }
 
-// This is dual purpose. When we actually list
-// patches to build the cache - desc_is_fname
-// will be set to 1.
-
 void
-list_patches_build(const char *name, int desc_is_fname)
+reset_patch_menu(void)
 {
-    desc_is_fname_sto = desc_is_fname;
-
     current_menu_index_patches = 0;
 
     if (!patches)
@@ -297,7 +284,11 @@ list_patches_build(const char *name, int desc_is_fname)
     patches[0].highlight = 1;
 
     current_menu_index_patches += 1;
+}
 
+void
+add_patch_menu(const char *name)
+{
     recurse_call(name, patch_func);
 
     patches[current_menu_index_patches].name = NULL;
@@ -314,7 +305,7 @@ void config_main_menu() {
 }
 
 void
-menu_handler()
+menu_handler(void)
 {
     show_menu(main_s);
 }
index 5393f47b88ae36d9af150deaa055e3ea899792a1..ed7901d4267aa9a7564e3797b78e6997b1649677 100644 (file)
@@ -33,7 +33,7 @@ patch_cache_func(char* fpath)
 }
 
 int
-generate_patch_cache()
+generate_patch_cache(void)
 {
     // Remove cache
     rrmdir(PATH_LOADER_CACHE);
index 01f6bd79fad961ff875d101f80f1e3c5e75e5305..7aa5c3dc66efebddd14afef8f3c5769d86ec08eb 100644 (file)
@@ -138,7 +138,7 @@ void free(void* ptr) {
 }
 
 #ifdef MALLOC_DEBUG
-void print_alloc_stats() {
+void print_alloc_stats(void) {
        fprintf(stderr, "[A] %u [F] %u [M] %u [B] %lu\n", alloc_count, free_count, allocated_memory, (uint32_t)heap_end - (uint32_t)&__end__);
 }
 #endif
index 1ddeb5315f4b090082b3fee0f2f23a4a2c3f46c9..84a8ebf9e62dbf4bbf81d14c31f5747f5c5cb0df 100644 (file)
@@ -35,7 +35,7 @@ uint8_t* font_data = NULL;
 
 static uint8_t alphamap[256] = {0};
 
-void std_init() {
+void std_init(void) {
     for(uint16_t i=0; i < 0x100; i++) {
         alphamap[i] = 0;
         if (i > 0x7F)
@@ -104,7 +104,7 @@ void fill_line(void* channel, unsigned int y, uint8_t color) {
 }
 
 // This is (roughly) the screenshot specs as used by smeas scrtool.
-void screenshot() {
+void screenshot(void) {
     f_unlink(PATH_TEMP "/screenshot.ppm");
 
     // Open the screenshot blob used by hbmenu et al
@@ -151,7 +151,7 @@ void screenshot() {
     fprintf(stderr, "Screenshot: %s\n", PATH_TEMP "/screenshot.ppm");
 }
 
-void clear_bg() {
+void clear_bg(void) {
     memset(top_bg, 0, TOP_SIZE);
     memset(bottom_bg, 0, BOTTOM_SIZE);
 }
@@ -359,7 +359,7 @@ draw_character(uint8_t *screen, const unsigned int character, unsigned int ch_x,
 }
 
 void
-shut_up()
+shut_up(void)
 {
     kill_output = 1; // Immediately cancel all output operations.
 }