From: Zbigniew Jędrzejewski-Szmek Date: Fri, 6 Mar 2026 11:56:09 +0000 (+0100) Subject: hostnamectl: call all verb functions verb_* X-Git-Tag: v261-rc1~809^2~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=165e36e32039f858b67c026226bd1ebea188d910;p=thirdparty%2Fsystemd.git hostnamectl: call all verb functions verb_* --- diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c index ae1af414257..c9d83031b92 100644 --- a/src/hostname/hostnamectl.c +++ b/src/hostname/hostnamectl.c @@ -549,7 +549,7 @@ static int get_hostname_based_on_flag(sd_bus *bus) { return get_one_name(bus, attr, NULL); } -static int show_status(int argc, char **argv, void *userdata) { +static int verb_show_status(int argc, char **argv, void *userdata) { sd_bus *bus = userdata; int r; @@ -601,7 +601,7 @@ static int set_simple_string(sd_bus *bus, const char *target, const char *method return set_simple_string_internal(bus, NULL, target, method, value); } -static int set_hostname(int argc, char **argv, void *userdata) { +static int verb_set_hostname(int argc, char **argv, void *userdata) { _cleanup_free_ char *h = NULL; const char *hostname = argv[1]; sd_bus *bus = userdata; @@ -687,27 +687,27 @@ static int set_hostname(int argc, char **argv, void *userdata) { return ret; } -static int get_or_set_hostname(int argc, char **argv, void *userdata) { +static int verb_get_or_set_hostname(int argc, char **argv, void *userdata) { return argc == 1 ? get_hostname_based_on_flag(userdata) : - set_hostname(argc, argv, userdata); + verb_set_hostname(argc, argv, userdata); } -static int get_or_set_icon_name(int argc, char **argv, void *userdata) { +static int verb_get_or_set_icon_name(int argc, char **argv, void *userdata) { return argc == 1 ? get_one_name(userdata, "IconName", NULL) : set_simple_string(userdata, "icon", "SetIconName", argv[1]); } -static int get_or_set_chassis(int argc, char **argv, void *userdata) { +static int verb_get_or_set_chassis(int argc, char **argv, void *userdata) { return argc == 1 ? get_one_name(userdata, "Chassis", NULL) : set_simple_string(userdata, "chassis", "SetChassis", argv[1]); } -static int get_or_set_deployment(int argc, char **argv, void *userdata) { +static int verb_get_or_set_deployment(int argc, char **argv, void *userdata) { return argc == 1 ? get_one_name(userdata, "Deployment", NULL) : set_simple_string(userdata, "deployment", "SetDeployment", argv[1]); } -static int get_or_set_location(int argc, char **argv, void *userdata) { +static int verb_get_or_set_location(int argc, char **argv, void *userdata) { return argc == 1 ? get_one_name(userdata, "Location", NULL) : set_simple_string(userdata, "location", "SetLocation", argv[1]); } @@ -846,18 +846,18 @@ static int parse_argv(int argc, char *argv[]) { static int hostnamectl_main(sd_bus *bus, int argc, char *argv[]) { static const Verb verbs[] = { - { "status", VERB_ANY, 1, VERB_DEFAULT, show_status }, - { "hostname", VERB_ANY, 2, 0, get_or_set_hostname }, - { "set-hostname", 2, 2, 0, get_or_set_hostname }, /* obsolete */ - { "icon-name", VERB_ANY, 2, 0, get_or_set_icon_name }, - { "set-icon-name", 2, 2, 0, get_or_set_icon_name }, /* obsolete */ - { "chassis", VERB_ANY, 2, 0, get_or_set_chassis }, - { "set-chassis", 2, 2, 0, get_or_set_chassis }, /* obsolete */ - { "deployment", VERB_ANY, 2, 0, get_or_set_deployment }, - { "set-deployment", 2, 2, 0, get_or_set_deployment }, /* obsolete */ - { "location", VERB_ANY, 2, 0, get_or_set_location }, - { "set-location", 2, 2, 0, get_or_set_location }, /* obsolete */ - { "help", VERB_ANY, VERB_ANY, 0, verb_help }, /* Not documented, but supported since it is created. */ + { "status", VERB_ANY, 1, VERB_DEFAULT, verb_show_status }, + { "hostname", VERB_ANY, 2, 0, verb_get_or_set_hostname }, + { "set-hostname", 2, 2, 0, verb_get_or_set_hostname }, /* obsolete */ + { "icon-name", VERB_ANY, 2, 0, verb_get_or_set_icon_name }, + { "set-icon-name", 2, 2, 0, verb_get_or_set_icon_name }, /* obsolete */ + { "chassis", VERB_ANY, 2, 0, verb_get_or_set_chassis }, + { "set-chassis", 2, 2, 0, verb_get_or_set_chassis }, /* obsolete */ + { "deployment", VERB_ANY, 2, 0, verb_get_or_set_deployment }, + { "set-deployment", 2, 2, 0, verb_get_or_set_deployment }, /* obsolete */ + { "location", VERB_ANY, 2, 0, verb_get_or_set_location }, + { "set-location", 2, 2, 0, verb_get_or_set_location }, /* obsolete */ + { "help", VERB_ANY, VERB_ANY, 0, verb_help }, /* Not documented, but supported since it is created. */ {} };