From a85c516926ab3eaf4c92492c96cae112864ad1f1 Mon Sep 17 00:00:00 2001 From: Scoopta Date: Mon, 6 Jan 2020 00:39:47 -0800 Subject: [PATCH] Good C practices --- inc/map.h | 6 +++--- inc/utils.h | 2 +- inc/wofi.h | 10 +++++----- modes/dmenu.c | 4 ++-- modes/drun.c | 2 +- modes/run.c | 4 ++-- src/main.c | 2 +- src/map.c | 4 ++-- src/utils.c | 2 +- src/wofi.c | 10 +++++----- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/inc/map.h b/inc/map.h index e68722d..77a2844 100644 --- a/inc/map.h +++ b/inc/map.h @@ -23,11 +23,11 @@ #include #include -struct map* map_init(); +struct map* map_init(void); -struct map* map_init_void(); +struct map* map_init_void(void); -void map_free(); +void map_free(struct map* map); bool map_put(struct map* map, const char* key, char* value); diff --git a/inc/utils.h b/inc/utils.h index 429761b..f1d0324 100644 --- a/inc/utils.h +++ b/inc/utils.h @@ -27,7 +27,7 @@ #include -time_t utils_get_time_millis(); +time_t utils_get_time_millis(void); void utils_sleep_millis(time_t millis); diff --git a/inc/wofi.h b/inc/wofi.h index a84507f..6265225 100644 --- a/inc/wofi.h +++ b/inc/wofi.h @@ -54,15 +54,15 @@ struct wl_list* wofi_read_cache(char* mode); void wofi_insert_widget(char* mode, char** text, char* search_text, char** actions, size_t action_count); -bool wofi_allow_images(); +bool wofi_allow_images(void); -bool wofi_allow_markup(); +bool wofi_allow_markup(void); -uint64_t wofi_get_image_size(); +uint64_t wofi_get_image_size(void); -bool wofi_mod_shift(); +bool wofi_mod_shift(void); -bool wofi_mod_control(); +bool wofi_mod_control(void); void wofi_term_run(const char* cmd); #endif diff --git a/modes/dmenu.c b/modes/dmenu.c index 2c8454e..6e5ee79 100644 --- a/modes/dmenu.c +++ b/modes/dmenu.c @@ -95,10 +95,10 @@ void wofi_dmenu_exec(const gchar* cmd) { exit(0); } -const char** wofi_dmenu_get_arg_names() { +const char** wofi_dmenu_get_arg_names(void) { return arg_names; } -size_t wofi_dmenu_get_arg_count() { +size_t wofi_dmenu_get_arg_count(void) { return sizeof(arg_names) / sizeof(char*); } diff --git a/modes/drun.c b/modes/drun.c index e0b9d6a..f4ddd45 100644 --- a/modes/drun.c +++ b/modes/drun.c @@ -175,7 +175,7 @@ static void insert_dir(char* app_dir, struct map* cached, struct map* entries) { closedir(dir); } -void wofi_drun_init() { +void wofi_drun_init(void) { struct map* cached = map_init(); struct map* entries = map_init(); struct wl_list* cache = wofi_read_cache(MODE); diff --git a/modes/run.c b/modes/run.c index 843a655..b6dbe15 100644 --- a/modes/run.c +++ b/modes/run.c @@ -121,10 +121,10 @@ void wofi_run_exec(const gchar* cmd) { exit(errno); } -const char** wofi_run_get_arg_names() { +const char** wofi_run_get_arg_names(void) { return arg_names; } -size_t wofi_run_get_arg_count() { +size_t wofi_run_get_arg_count(void) { return sizeof(arg_names) / sizeof(char*); } diff --git a/src/main.c b/src/main.c index 07b8334..7e830d3 100644 --- a/src/main.c +++ b/src/main.c @@ -76,7 +76,7 @@ static void print_usage(char** argv) { exit(0); } -static void load_css() { +static void load_css(void) { if(access(stylesheet, R_OK) == 0) { FILE* file = fopen(stylesheet, "r"); fseek(file, 0, SEEK_END); diff --git a/src/map.c b/src/map.c index 20a356b..57378ad 100644 --- a/src/map.c +++ b/src/map.c @@ -25,14 +25,14 @@ struct map { struct map* head, *left, *right; }; -struct map* map_init() { +struct map* map_init(void) { struct map* map = calloc(1, sizeof(struct map)); map->head = map; map->mman = true; return map; } -struct map* map_init_void() { +struct map* map_init_void(void) { struct map* map = map_init(); map->mman = false; return map; diff --git a/src/utils.c b/src/utils.c index 0f6138d..fd79cfa 100644 --- a/src/utils.c +++ b/src/utils.c @@ -17,7 +17,7 @@ #include -time_t utils_get_time_millis() { +time_t utils_get_time_millis(void) { struct timeval time; gettimeofday(&time, NULL); return (time.tv_sec * 1000) + (time.tv_usec / 1000); diff --git a/src/wofi.c b/src/wofi.c index 5c0a218..c0fdddc 100644 --- a/src/wofi.c +++ b/src/wofi.c @@ -555,23 +555,23 @@ void wofi_insert_widget(char* mode, char** text, char* search_text, char** actio utils_sleep_millis(1); } -bool wofi_allow_images() { +bool wofi_allow_images(void) { return allow_images; } -bool wofi_allow_markup() { +bool wofi_allow_markup(void) { return allow_markup; } -uint64_t wofi_get_image_size() { +uint64_t wofi_get_image_size(void) { return image_size; } -bool wofi_mod_shift() { +bool wofi_mod_shift(void) { return mod_shift; } -bool wofi_mod_control() { +bool wofi_mod_control(void) { return mod_ctrl; }