dlfcn-util: invert function naming and add helper that does the whole job

We warn when the operation fails, not when it succeeds. Hence this should be
"<do>_or_<handle failure>", not "<do>_and_<handle failure>". We *could* use
whatever convention we want, but rust and perl are rather consistent in using
the logical convention. We don't care about perl that much, but having a naming
convention inverted wrt. rust would be rather confusing.

Also, pretty much every implementation does similar steps, so add a nice
wrapper which combines opening of the library and loading of the symbols.

Also add missing sentinel attribute in dlopen_or_warn().
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-06-24 10:16:43 +02:00
parent 87501ac0eb
commit fff25ab22e
10 changed files with 64 additions and 36 deletions
+1 -1
View File
@@ -62,7 +62,7 @@ int dlopen_cryptsetup(void) {
return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
"libcryptsetup support is not installed: %s", dlerror());
r = dlsym_many_and_warn(
r = dlsym_many_or_warn(
dl,
LOG_DEBUG,
DLSYM_ARG(crypt_activate_by_passphrase),