diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-16 12:25:43 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-17 09:13:35 +0100 |
commit | 5272ae42ce4b970e710882660ef54ba06335ca51 (patch) | |
tree | 8da5fa2e538136576f461f7a33a42f3cd01b0758 /src/import | |
parent | 3c79f0b3ced903bbaaa41ad7feb698e3955e1f12 (diff) | |
download | systemd-5272ae42ce4b970e710882660ef54ba06335ca51.tar.gz |
import: define mains through macro
Diffstat (limited to 'src/import')
-rw-r--r-- | src/import/export.c | 12 | ||||
-rw-r--r-- | src/import/import.c | 12 | ||||
-rw-r--r-- | src/import/importd.c | 24 | ||||
-rw-r--r-- | src/import/pull.c | 12 |
4 files changed, 25 insertions, 35 deletions
diff --git a/src/import/export.c b/src/import/export.c index 03eb3e40b2..317ac1bba7 100644 --- a/src/import/export.c +++ b/src/import/export.c @@ -269,7 +269,6 @@ static int parse_argv(int argc, char *argv[]) { } static int export_main(int argc, char *argv[]) { - static const Verb verbs[] = { { "help", VERB_ANY, VERB_ANY, 0, help }, { "tar", 2, 3, 0, export_tar }, @@ -280,7 +279,7 @@ static int export_main(int argc, char *argv[]) { return dispatch_verb(argc, argv, verbs, NULL); } -int main(int argc, char *argv[]) { +static int run(int argc, char *argv[]) { int r; setlocale(LC_ALL, ""); @@ -289,12 +288,11 @@ int main(int argc, char *argv[]) { r = parse_argv(argc, argv); if (r <= 0) - goto finish; + return r; (void) ignore_signals(SIGPIPE, -1); - r = export_main(argc, argv); - -finish: - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + return export_main(argc, argv); } + +DEFINE_MAIN_FUNCTION(run); diff --git a/src/import/import.c b/src/import/import.c index 35c8e6d630..69fe8a8a37 100644 --- a/src/import/import.c +++ b/src/import/import.c @@ -292,7 +292,6 @@ static int parse_argv(int argc, char *argv[]) { } static int import_main(int argc, char *argv[]) { - static const Verb verbs[] = { { "help", VERB_ANY, VERB_ANY, 0, help }, { "tar", 2, 3, 0, import_tar }, @@ -303,7 +302,7 @@ static int import_main(int argc, char *argv[]) { return dispatch_verb(argc, argv, verbs, NULL); } -int main(int argc, char *argv[]) { +static int run(int argc, char *argv[]) { int r; setlocale(LC_ALL, ""); @@ -312,12 +311,11 @@ int main(int argc, char *argv[]) { r = parse_argv(argc, argv); if (r <= 0) - goto finish; + return 0; (void) ignore_signals(SIGPIPE, -1); - r = import_main(argc, argv); - -finish: - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + return import_main(argc, argv); } + +DEFINE_MAIN_FUNCTION(run); diff --git a/src/import/importd.c b/src/import/importd.c index 57190e5de5..b5265a7ed3 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -1113,7 +1113,7 @@ static int manager_run(Manager *m) { m); } -int main(int argc, char *argv[]) { +static int run(int argc, char *argv[]) { _cleanup_(manager_unrefp) Manager *m = NULL; int r; @@ -1125,28 +1125,24 @@ int main(int argc, char *argv[]) { if (argc != 1) { log_error("This program takes no arguments."); - r = -EINVAL; - goto finish; + return -EINVAL; } assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, -1) >= 0); r = manager_new(&m); - if (r < 0) { - log_error_errno(r, "Failed to allocate manager object: %m"); - goto finish; - } + if (r < 0) + return log_error_errno(r, "Failed to allocate manager object: %m"); r = manager_add_bus_objects(m); if (r < 0) - goto finish; + return r; r = manager_run(m); - if (r < 0) { - log_error_errno(r, "Failed to run event loop: %m"); - goto finish; - } + if (r < 0) + return log_error_errno(r, "Failed to run event loop: %m"); -finish: - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + return 0; } + +DEFINE_MAIN_FUNCTION(run); diff --git a/src/import/pull.c b/src/import/pull.c index ef495de068..821c9772e4 100644 --- a/src/import/pull.c +++ b/src/import/pull.c @@ -304,7 +304,6 @@ static int parse_argv(int argc, char *argv[]) { } static int pull_main(int argc, char *argv[]) { - static const Verb verbs[] = { { "help", VERB_ANY, VERB_ANY, 0, help }, { "tar", 2, 3, 0, pull_tar }, @@ -315,7 +314,7 @@ static int pull_main(int argc, char *argv[]) { return dispatch_verb(argc, argv, verbs, NULL); } -int main(int argc, char *argv[]) { +static int run(int argc, char *argv[]) { int r; setlocale(LC_ALL, ""); @@ -324,12 +323,11 @@ int main(int argc, char *argv[]) { r = parse_argv(argc, argv); if (r <= 0) - goto finish; + return r; (void) ignore_signals(SIGPIPE, -1); - r = pull_main(argc, argv); - -finish: - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + return pull_main(argc, argv); } + +DEFINE_MAIN_FUNCTION(run); |