diff --git a/src/shared/dlfcn-util.h b/src/shared/dlfcn-util.h index 7d8cb4c9ab..050f1e2da7 100644 --- a/src/shared/dlfcn-util.h +++ b/src/shared/dlfcn-util.h @@ -5,7 +5,17 @@ #include "macro.h" -DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(void*, dlclose, NULL); +static inline void* safe_dlclose(void *dl) { + if (!dl) + return NULL; + + assert_se(dlclose(dl) == 0); + return NULL; +} + +static inline void dlclosep(void **dlp) { + safe_dlclose(*dlp); +} int dlsym_many_or_warn_sentinel(void *dl, int log_level, ...) _sentinel_; int dlopen_many_sym_or_warn_sentinel(void **dlp, const char *filename, int log_level, ...) _sentinel_; @@ -29,11 +39,3 @@ int dlopen_many_sym_or_warn_sentinel(void **dlp, const char *filename, int log_l /* libbpf is a bit confused about type-safety and API compatibility. Provide a macro that can tape over that mess. Sad. */ #define DLSYM_ARG_FORCE(arg) \ &sym_##arg, STRINGIFY(arg) - -static inline void *safe_dlclose(void *p) { - if (!p) - return NULL; - - assert_se(dlclose(p) == 0); - return NULL; -} diff --git a/src/shared/userdb.c b/src/shared/userdb.c index 540573390c..d262c82d63 100644 --- a/src/shared/userdb.c +++ b/src/shared/userdb.c @@ -1455,7 +1455,7 @@ int userdb_block_nss_systemd(int b) { return 0; } - call = (int (*)(bool b)) dlsym(dl, "_nss_systemd_block"); + call = dlsym(dl, "_nss_systemd_block"); if (!call) /* If the file is installed but lacks the symbol we expect, things are weird, let's complain */ return log_debug_errno(SYNTHETIC_ERRNO(ELIBBAD),