From cdc7df3e5647387f9a7bed166ff9973dc42b869e Mon Sep 17 00:00:00 2001 From: klemek Date: Mon, 11 May 2026 07:53:28 +0200 Subject: [PATCH] refactor: review format and imports --- src/args.c | 3 +-- src/args.h | 2 +- src/arr.h | 2 +- src/config.h | 2 +- src/config_file.c | 3 +-- src/file.c | 2 -- src/file.h | 2 +- src/forge.h | 2 +- src/main.c | 2 +- src/main.h | 2 +- src/midi.c | 2 +- src/midi.h | 2 +- src/project.c | 5 ++--- src/project.h | 2 +- src/rand.c | 4 ++-- src/rand.h | 4 ++-- src/shared.c | 2 +- src/shared.h | 2 +- src/state.h | 2 +- src/string.c | 3 +-- src/string.h | 2 +- src/tempo.c | 2 +- src/tempo.h | 2 +- src/timer.c | 2 +- src/timer.h | 2 +- src/types.h | 1 - src/video.h | 2 +- src/window.c | 2 +- src/window.h | 2 +- 29 files changed, 30 insertions(+), 37 deletions(-) diff --git a/src/args.c b/src/args.c index 45e6ee1..04aa113 100644 --- a/src/args.c +++ b/src/args.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -228,4 +227,4 @@ void args_parse(Parameters *params, int argc, char **argv) { if (params->video_size == 0) { params->video_size = params->internal_size; } -} \ No newline at end of file +} diff --git a/src/args.h b/src/args.h index 6f291cd..f82772e 100644 --- a/src/args.h +++ b/src/args.h @@ -5,4 +5,4 @@ void args_parse(Parameters *params, int argc, char **argv); -#endif /* ARGS_H */ \ No newline at end of file +#endif /* ARGS_H */ diff --git a/src/arr.h b/src/arr.h index c51af5e..b27b1eb 100644 --- a/src/arr.h +++ b/src/arr.h @@ -7,4 +7,4 @@ unsigned int arr_uint_index_of(UintArray array, unsigned int value); unsigned int arr_uint_remap_index(UintArray offsets, unsigned int *index); -#endif /* ARR_H */ \ No newline at end of file +#endif /* ARR_H */ diff --git a/src/config.h b/src/config.h index bdd01c2..5aa076f 100644 --- a/src/config.h +++ b/src/config.h @@ -87,4 +87,4 @@ #define MAX_TAP_VALUES 10 #endif -#endif /* CONFIG_H */ \ No newline at end of file +#endif /* CONFIG_H */ diff --git a/src/config_file.c b/src/config_file.c index 8b64166..fb3dbf9 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -139,4 +138,4 @@ unsigned int config_file_get_int(const ConfigFile *config, const char *key, return (unsigned int)atoi(item->value); } -void config_file_free(const ConfigFile *config) { hashmap_free(config->map); } \ No newline at end of file +void config_file_free(const ConfigFile *config) { hashmap_free(config->map); } diff --git a/src/file.c b/src/file.c index 16c536e..88c3435 100644 --- a/src/file.c +++ b/src/file.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -10,7 +9,6 @@ #include "types.h" #include "file.h" -#include "string.h" static time_t get_file_time(const File *file) { struct stat attr; diff --git a/src/file.h b/src/file.h index 59ddd72..1d333ff 100644 --- a/src/file.h +++ b/src/file.h @@ -15,4 +15,4 @@ void file_dump(const char *path, const char *content); void file_free(const File *file); -#endif /* FILE_H */ \ No newline at end of file +#endif /* FILE_H */ diff --git a/src/forge.h b/src/forge.h index 2472be7..d630f24 100644 --- a/src/forge.h +++ b/src/forge.h @@ -5,4 +5,4 @@ void forge_run(const Parameters *params); -#endif /* FORGE_H */ \ No newline at end of file +#endif /* FORGE_H */ diff --git a/src/main.c b/src/main.c index e025fdd..c277d9a 100644 --- a/src/main.c +++ b/src/main.c @@ -17,7 +17,7 @@ int main(int argc, char **argv) { puts(PACKAGE " " VERSION); - set_seed((unsigned long)time(NULL)); + rand_set_seed((unsigned long)time(NULL)); forge_run(¶ms); diff --git a/src/main.h b/src/main.h index 396a795..ddd6a6f 100644 --- a/src/main.h +++ b/src/main.h @@ -3,4 +3,4 @@ int main(int argc, char **argv); -#endif /* MAIN_H */ \ No newline at end of file +#endif /* MAIN_H */ diff --git a/src/midi.c b/src/midi.c index 35be598..7a49a2c 100644 --- a/src/midi.c +++ b/src/midi.c @@ -1,10 +1,10 @@ #include +#include #include #include "types.h" #include "config.h" -#include "log.h" void midi_open(MidiDevice *device, const char *name) { strlcpy(device->name, name, STR_LEN); diff --git a/src/midi.h b/src/midi.h index 18616c2..fde79d5 100644 --- a/src/midi.h +++ b/src/midi.h @@ -11,4 +11,4 @@ bool midi_background_listen(const MidiDevice *device, void (*event_callback)(unsigned char code, unsigned char value)); -#endif /* MIDI_H */ \ No newline at end of file +#endif /* MIDI_H */ diff --git a/src/project.c b/src/project.c index 7c01790..d46e2f9 100644 --- a/src/project.c +++ b/src/project.c @@ -1,4 +1,4 @@ -#include +#include #include #include "types.h" @@ -6,7 +6,6 @@ #include "config.h" #include "config_file.h" #include "file.h" -#include "log.h" #include "project.h" #include "state.h" #include "string.h" @@ -141,4 +140,4 @@ void project_free(const Project *project) { } config_file_free(&project->config); -} \ No newline at end of file +} diff --git a/src/project.h b/src/project.h index 12fa21b..1170fef 100644 --- a/src/project.h +++ b/src/project.h @@ -10,4 +10,4 @@ void project_reload(Project *project, void (*reload_callback)(unsigned int)); void project_free(const Project *project); -#endif /* PROJECT_H */ \ No newline at end of file +#endif /* PROJECT_H */ diff --git a/src/rand.c b/src/rand.c index b2df3db..ddc555a 100644 --- a/src/rand.c +++ b/src/rand.c @@ -13,11 +13,11 @@ static unsigned long rand(void) { return (unsigned long)(x >> (22 + count)); } -void set_seed(unsigned long long seed) { +void rand_set_seed(unsigned long long seed) { mcg_state = 2 * seed + 1; (void)rand(); } unsigned int rand_uint(const unsigned int max) { return max == 0 ? 0 : (unsigned int)(rand() % max); -} \ No newline at end of file +} diff --git a/src/rand.h b/src/rand.h index 33d1dbb..c0957f3 100644 --- a/src/rand.h +++ b/src/rand.h @@ -1,7 +1,7 @@ #ifndef RAND_H #define RAND_H -void set_seed(unsigned long long seed); +void rand_set_seed(unsigned long long seed); unsigned int rand_uint(unsigned int max); -#endif \ No newline at end of file +#endif diff --git a/src/shared.c b/src/shared.c index 1c3a8c0..8512d56 100644 --- a/src/shared.c +++ b/src/shared.c @@ -32,4 +32,4 @@ SharedContext *shared_init_context(const char *key) { void shared_close_context(SharedContext *shared) { close_shared(shared, sizeof(SharedContext), shared->fd); -} \ No newline at end of file +} diff --git a/src/shared.h b/src/shared.h index ac0065d..f7b353c 100644 --- a/src/shared.h +++ b/src/shared.h @@ -6,4 +6,4 @@ SharedContext *shared_init_context(const char *key); void shared_close_context(SharedContext *shared); -#endif /* SHARED_H */ \ No newline at end of file +#endif /* SHARED_H */ diff --git a/src/state.h b/src/state.h index 1fae705..3cc4fc9 100644 --- a/src/state.h +++ b/src/state.h @@ -22,4 +22,4 @@ void state_init(SharedContext *context, const StateConfig *state_config, void state_save(const SharedContext *context, const StateConfig *state_config); -#endif /* STATE_H */ \ No newline at end of file +#endif /* STATE_H */ diff --git a/src/string.c b/src/string.c index 101cbda..921c80f 100644 --- a/src/string.c +++ b/src/string.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -73,4 +72,4 @@ char *string_replace_at(const char *src, unsigned int from, unsigned int to, strlcpy(dst + from + rpl_len, src + to, src_len - to + 1); return dst; -} \ No newline at end of file +} diff --git a/src/string.h b/src/string.h index df35d19..19226f7 100644 --- a/src/string.h +++ b/src/string.h @@ -10,4 +10,4 @@ bool string_is_number(const char *value); char *string_replace_at(const char *src, unsigned int from, unsigned int to, const char *rpl); -#endif /* STRINGS_H */ \ No newline at end of file +#endif /* STRINGS_H */ diff --git a/src/tempo.c b/src/tempo.c index 2bb979c..a919334 100644 --- a/src/tempo.c +++ b/src/tempo.c @@ -137,4 +137,4 @@ double tempo_total(const Tempo *tempo) { double tempo_progress(const Tempo *tempo, double modulo) { return fmod(tempo_total(tempo), modulo); -} \ No newline at end of file +} diff --git a/src/tempo.h b/src/tempo.h index bc123b4..409c4a7 100644 --- a/src/tempo.h +++ b/src/tempo.h @@ -13,4 +13,4 @@ double tempo_total(const Tempo *tempo); double tempo_progress(const Tempo *tempo, double modulo); -#endif /* TEMPO_H */ \ No newline at end of file +#endif /* TEMPO_H */ diff --git a/src/timer.c b/src/timer.c index 575a083..666ab8c 100644 --- a/src/timer.c +++ b/src/timer.c @@ -31,4 +31,4 @@ double timer_reset(Timer *timer) { timer->counter = 0; return per_secs; -} \ No newline at end of file +} diff --git a/src/timer.h b/src/timer.h index 2882aec..c7d4315 100644 --- a/src/timer.h +++ b/src/timer.h @@ -9,4 +9,4 @@ bool timer_inc(Timer *timer); double timer_reset(Timer *timer); -#endif /* TIMER_H */ \ No newline at end of file +#endif /* TIMER_H */ diff --git a/src/types.h b/src/types.h index e158b57..0f58520 100644 --- a/src/types.h +++ b/src/types.h @@ -8,7 +8,6 @@ #include #include #include -#include #include #include "config.h" diff --git a/src/video.h b/src/video.h index 227e41c..9a01fa9 100644 --- a/src/video.h +++ b/src/video.h @@ -11,4 +11,4 @@ bool video_background_read(VideoCapture *video_capture, SharedContext *context, void video_free(const VideoCapture *video_capture); -#endif /* VIDEO_H */ \ No newline at end of file +#endif /* VIDEO_H */ diff --git a/src/window.c b/src/window.c index 02b423d..6790077 100644 --- a/src/window.c +++ b/src/window.c @@ -165,4 +165,4 @@ unsigned int window_read_key(int key, int action, int mods) { result += 100000; } return result; -} \ No newline at end of file +} diff --git a/src/window.h b/src/window.h index 6c8bb14..6803614 100644 --- a/src/window.h +++ b/src/window.h @@ -29,4 +29,4 @@ bool window_escape_key(int key, int action); unsigned int window_read_key(int key, int action, int mods); -#endif /* WINDOW_H */ \ No newline at end of file +#endif /* WINDOW_H */