diff --git a/daemons/lvmpolld/lvmpolld-core.c b/daemons/lvmpolld/lvmpolld-core.c index a75f71e2f..b654c8c9d 100644 --- a/daemons/lvmpolld/lvmpolld-core.c +++ b/daemons/lvmpolld/lvmpolld-core.c @@ -867,14 +867,14 @@ enum action_index { ACTION_MAX /* keep at the end */ }; -static const action_fn_t actions[ACTION_MAX] = { [ACTION_DUMP] = action_dump }; - static int _make_action(enum action_index idx, void *args) { - return idx < ACTION_MAX ? actions[idx](args) : 0; + static const action_fn_t _actions[ACTION_MAX] = { [ACTION_DUMP] = action_dump }; + + return idx < ACTION_MAX ? _actions[idx](args) : 0; } -static int _lvmpolld_client(const char *socket, unsigned action) +static int _lvmpolld_client(const char *socket, enum action_index action) { int r; @@ -892,10 +892,9 @@ static int _lvmpolld_client(const char *socket, unsigned action) return r ? EXIT_SUCCESS : EXIT_FAILURE; } -static int action_idx = ACTION_MAX; -static struct option long_options[] = { +static const struct option _long_options[] = { /* Have actions always at the beginning of the array. */ - {"dump", no_argument, &action_idx, ACTION_DUMP }, /* or an option_index ? */ + {"dump", no_argument, 0, ACTION_DUMP }, /* or an option_index ? */ /* other options */ {"binary", required_argument, 0, 'B' }, @@ -914,7 +913,7 @@ int main(int argc, char *argv[]) int opt; int option_index = 0; int client = 0, server = 0; - unsigned action = ACTION_MAX; + enum action_index action = ACTION_MAX; struct timespec timeout; daemon_idle di = { .ptimeout = &timeout }; struct lvmpolld_state ls = { .log_config = "" }; @@ -930,16 +929,16 @@ int main(int argc, char *argv[]) .socket_path = getenv("LVM_LVMPOLLD_SOCKET") ?: LVMPOLLD_SOCKET, }; - while ((opt = getopt_long(argc, argv, "fhVl:p:s:B:t:", long_options, &option_index)) != -1) { + while ((opt = getopt_long(argc, argv, "fhVl:p:s:B:t:", _long_options, &option_index)) != -1) { switch (opt) { case 0 : - if (action < ACTION_MAX) { + if (action != ACTION_MAX) { fprintf(stderr, "Can't perform more actions. Action already requested: %s\n", - long_options[action].name); + _long_options[action].name); _usage(argv[0], stderr); exit(EXIT_FAILURE); } - action = action_idx; + action = ACTION_DUMP; client = 1; break; case '?':