From: Emil Velikov Date: Wed, 9 Oct 2024 15:26:25 +0000 (+0100) Subject: tools/depmod: avoid casting symbol_free() function type X-Git-Tag: v34~241 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ad5ac6e67288e3606704f608cf2c98939392f5b4;p=thirdparty%2Fkmod.git tools/depmod: avoid casting symbol_free() function type With clang 17, -fsanitize=function is enabled alongside any other sanitizers. Which flags undefined behaviour, since the function type (argument type really) is not compatible. Reference: https://reviews.llvm.org/D148827#4422631 Signed-off-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/180 Signed-off-by: Lucas De Marchi --- diff --git a/tools/depmod.c b/tools/depmod.c index d71c31b7..a28666c7 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -960,8 +960,10 @@ static int mod_add_dependency(struct mod *mod, struct symbol *sym) return 0; } -static void symbol_free(struct symbol *sym) +static void symbol_free(void *data) { + struct symbol *sym = data; + DBG("free %p sym=%s, owner=%p %s\n", sym, sym->name, sym->owner, sym->owner != NULL ? sym->owner->path : ""); free(sym); @@ -988,7 +990,7 @@ static int depmod_init(struct depmod *depmod, struct cfg *cfg, struct kmod_ctx * goto modules_by_name_failed; } - depmod->symbols = hash_new(2048, (void (*)(void *))symbol_free); + depmod->symbols = hash_new(2048, symbol_free); if (depmod->symbols == NULL) { err = -errno; goto symbols_failed;