diff --git a/CMakeLists.txt b/CMakeLists.txt index c1a838a..88e94e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,10 @@ add_library(hiload SHARED src/logger/sc_log.c ) +target_compile_options(hiload PRIVATE + $<$:-Wall -Wextra> + $<$:-Weverything> +) target_link_libraries(hiload dl) @@ -86,6 +90,11 @@ add_library(auditor-x86_64 SHARED src/auditor/auditor-x86_64.c ) +target_compile_options(hiload PRIVATE + $<$:-Wall -Wextra> + $<$:-Weverything> +) + install(TARGETS auditor-x86_64 EXPORT auditor-x86_64Targets ARCHIVE DESTINATION lib diff --git a/src/files.c b/src/files.c index 9173f49..f067e10 100644 --- a/src/files.c +++ b/src/files.c @@ -4,7 +4,7 @@ #include "logger/logger.h" const char *hi_file_to_str_dyn(const char *filename) { - size_t n = 0; + const char *s = hi_string_from_file_dyn(filename, 0, 0); if (!s) { sc_log_error("Failed to read file: %s\n", filename); diff --git a/src/filewatcher/filewatcher.c b/src/filewatcher/filewatcher.c index a04e1bb..3053520 100644 --- a/src/filewatcher/filewatcher.c +++ b/src/filewatcher/filewatcher.c @@ -9,6 +9,7 @@ #include #include +#include "types.h" #include "array/array.h" #include "common.h" #include "logger/logger.h" @@ -66,14 +67,6 @@ static hiFileEvent create_file_event(const struct inotify_event *event) { return hievent; } -static hiFileEvent copy_file_event(const hiFileEvent *event) { - hiFileEvent cpy = *event; - // Copy the file string, so this can be destroyed without destroying the - // original - cpy.file = strdup(event->file); - return cpy; -} - void hi_file_event_free(hiFileEvent *event) { if (event) { free((void *)event->file); @@ -108,7 +101,7 @@ static HiloadResult file_events_init(hiFileEvents *events) { static void file_events_destroy(hiFileEvents *events) { if (events) { - for (int i = 0; i < sc_array_size(&events->events); ++i) { + for (size_t i = 0; i < sc_array_size(&events->events); ++i) { hi_file_event_free(&sc_array_at(&events->events, i)); } sc_array_term(&events->events); @@ -170,7 +163,7 @@ static HiloadResult watch_path_remove(hiWatchPaths *paths, const char *path) { bool found = false; { - for (int i = 0; i < sc_array_size(&paths->watches); ++i) { + for (size_t i = 0; i < sc_array_size(&paths->watches); ++i) { WatchPath *wp = &sc_array_at(&paths->watches, i); if (strcmp(wp->path, path) == 0) { watch_path_destroy(paths->fd, wp); @@ -196,7 +189,7 @@ static HiloadResult watch_paths_init(hiWatchPaths *paths) { static void watch_paths_destroy(hiWatchPaths *paths) { if (paths) { - for (int i = 0; i < sc_array_size(&paths->watches); i++) { + for (size_t i = 0; i < sc_array_size(&paths->watches); i++) { WatchPath *wp = &sc_array_at(&paths->watches, i); watch_path_destroy(paths->fd, wp); } diff --git a/src/hiload.c b/src/hiload.c index 2d4168b..9af2f3d 100644 --- a/src/hiload.c +++ b/src/hiload.c @@ -10,6 +10,7 @@ #include "types.h" #include +#include #include #include #include @@ -62,7 +63,7 @@ static int gather_module_infos_callback(struct dl_phdr_info *info, size_t size, // Store the module name const char *modname = info->dlpi_name; sc_array_add(&infos->names, strdup(modname)); - for (int i = 0; i < sc_array_size(&context.enabled_modules); i++) { + for (size_t i = 0; i < sc_array_size(&context.enabled_modules); i++) { if (hi_path_has_filename(modname, sc_array_at(&context.enabled_modules, i))) { @@ -225,7 +226,7 @@ void hi_print_module_infos() { sc_log_debug(" address: %p\n", sc_array_at(&modules->addresses, i)); const SymbolInfos *symbols = &sc_array_at(&modules->symbols, i); - for (int j = 0; j < sc_array_size(&symbols->names); j++) { + for (size_t j = 0; j < sc_array_size(&symbols->names); j++) { const void *addr = sc_array_at(&symbols->addresses, j); const char *name = sc_array_at(&symbols->names, j); sc_log_debug(" %p: %s\n", addr, name); @@ -235,7 +236,7 @@ void hi_print_module_infos() { } } -int hi_init(unsigned n, const char *enabled_modules[n]) { +int hi_init(unsigned n, const char **enabled_modules) { assert(!module_infos); if (sc_log_init() != 0) {