1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-03 05:18:09 +03:00

udev: several trivial cleanups for builtins (#35612)

This commit is contained in:
Daan De Meyer 2024-12-14 06:48:50 +00:00 committed by GitHub
commit 61ecc410ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 23 deletions

View File

@ -68,11 +68,10 @@ static int builtin_kmod_init(void) {
/* called on udev shutdown and reload request */
static void builtin_kmod_exit(void) {
log_debug("Unload kernel module index.");
if (!ctx)
return;
log_debug("Unload kernel module index.");
ctx = sym_kmod_unref(ctx);
}

View File

@ -9,8 +9,6 @@
#include "strv.h"
#include "udev-builtin.h"
static bool initialized;
static const UdevBuiltin *const builtins[_UDEV_BUILTIN_MAX] = {
#if HAVE_BLKID
[UDEV_BUILTIN_BLKID] = &udev_builtin_blkid,
@ -33,25 +31,15 @@ static const UdevBuiltin *const builtins[_UDEV_BUILTIN_MAX] = {
};
void udev_builtin_init(void) {
if (initialized)
return;
for (UdevBuiltinCommand i = 0; i < _UDEV_BUILTIN_MAX; i++)
if (builtins[i] && builtins[i]->init)
builtins[i]->init();
initialized = true;
FOREACH_ELEMENT(b, builtins)
if (*b && (*b)->init)
(*b)->init();
}
void udev_builtin_exit(void) {
if (!initialized)
return;
for (UdevBuiltinCommand i = 0; i < _UDEV_BUILTIN_MAX; i++)
if (builtins[i] && builtins[i]->exit)
builtins[i]->exit();
initialized = false;
FOREACH_ELEMENT(b, builtins)
if (*b && (*b)->exit)
(*b)->exit();
}
bool udev_builtin_should_reload(void) {
@ -62,9 +50,9 @@ bool udev_builtin_should_reload(void) {
}
void udev_builtin_list(void) {
for (UdevBuiltinCommand i = 0; i < _UDEV_BUILTIN_MAX; i++)
if (builtins[i])
fprintf(stderr, " %-14s %s\n", builtins[i]->name, builtins[i]->help);
FOREACH_ELEMENT(b, builtins)
if (*b)
fprintf(stderr, " %-14s %s\n", (*b)->name, (*b)->help);
}
const char* udev_builtin_name(UdevBuiltinCommand cmd) {