From: chaoskagami Date: Sat, 8 Oct 2016 15:11:26 +0000 (-0400) Subject: Minor cleanup. X-Git-Tag: v0.3.1~66^2~11 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=254a0d4f09dbac9b3b52a691049b1974a796a23b;p=corbenik%2Fcorbenik.git Minor cleanup. 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. --- diff --git a/configure.ac b/configure.ac index 0ea6e4e..5c0e9fe 100644 --- a/configure.ac +++ b/configure.ac @@ -52,7 +52,7 @@ ldflags: ${LDFLAGS} ocflags: ${OCFLAGS} Chainloader: ${CHAINLOADER} -Chainloader: ${UNITTESTS} +Unit tests: ${UNITTESTS} " AC_OUTPUT diff --git a/include/input.h b/include/input.h index be263f3..7fdfa79 100644 --- a/include/input.h +++ b/include/input.h @@ -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 diff --git a/include/interrupt.h b/include/interrupt.h index 8a25f56..e514684 100644 --- a/include/interrupt.h +++ b/include/interrupt.h @@ -3,6 +3,6 @@ /* Install interrupt handlers via libctr9. */ -void install_interrupts(); +void install_interrupts(void); #endif diff --git a/include/menu.h b/include/menu.h index 7f39387..c488070 100644 --- a/include/menu.h +++ b/include/menu.h @@ -4,4 +4,7 @@ void reset(); void poweroff(); +void reset_patch_menu(void); +void add_patch_menu(const char *name); + #endif diff --git a/include/option.h b/include/option.h index ec93fb8..851a06e 100644 --- a/include/option.h +++ b/include/option.h @@ -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. */ diff --git a/include/patch_format.h b/include/patch_format.h index c16b600..75c56f0 100644 --- a/include/patch_format.h +++ b/include/patch_format.h @@ -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) diff --git a/include/patcher.h b/include/patcher.h index 17ae138..456e95f 100644 --- a/include/patcher.h +++ b/include/patcher.h @@ -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); diff --git a/include/std/allocator.h b/include/std/allocator.h index ae96dc6..c0fad2b 100644 --- a/include/std/allocator.h +++ b/include/std/allocator.h @@ -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) * diff --git a/include/std/draw.h b/include/std/draw.h index 7ac1c7a..5ef14df 100644 --- a/include/std/draw.h +++ b/include/std/draw.h @@ -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. * diff --git a/source/config-backend-file.c b/source/config-backend-file.c index 3ea12e2..abef848 100644 --- a/source/config-backend-file.c +++ b/source/config-backend-file.c @@ -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"); diff --git a/source/input.c b/source/input.c index 15da0d5..2cf8811 100644 --- a/source/input.c +++ b/source/input.c @@ -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...]"); diff --git a/source/interrupt.c b/source/interrupt.c index 5bbb62e..1800e31 100644 --- a/source/interrupt.c +++ b/source/interrupt.c @@ -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(); diff --git a/source/main.c b/source/main.c index 5d63a52..f7a363b 100644 --- a/source/main.c +++ b/source/main.c @@ -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; diff --git a/source/menu.c b/source/menu.c index 8f24501..659e2b0 100644 --- a/source/menu.c +++ b/source/menu.c @@ -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); } diff --git a/source/patcher.c b/source/patcher.c index 5393f47..ed7901d 100644 --- a/source/patcher.c +++ b/source/patcher.c @@ -33,7 +33,7 @@ patch_cache_func(char* fpath) } int -generate_patch_cache() +generate_patch_cache(void) { // Remove cache rrmdir(PATH_LOADER_CACHE); diff --git a/source/std/allocator.c b/source/std/allocator.c index 01f6bd7..7aa5c3d 100644 --- a/source/std/allocator.c +++ b/source/std/allocator.c @@ -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 diff --git a/source/std/draw.c b/source/std/draw.c index 1ddeb53..84a8ebf 100644 --- a/source/std/draw.c +++ b/source/std/draw.c @@ -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. }