summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-11-16 14:44:14 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-11-17 09:13:35 +0100
commit9b58b5ad346e5f5ac8f6ae6f4ebce08487e56ef6 (patch)
treeeef193829e20a1d98a5992e7257875457fe32a39
parentcc639ee79d839055be463e929542c48a29a222f3 (diff)
downloadsystemd-9b58b5ad346e5f5ac8f6ae6f4ebce08487e56ef6.tar.gz
machined: define main through macro
-rw-r--r--src/machine/machined.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/machine/machined.c b/src/machine/machined.c
index a6f0d847d5..24850af5bc 100644
--- a/src/machine/machined.c
+++ b/src/machine/machined.c
@@ -345,7 +345,7 @@ static int manager_run(Manager *m) {
check_idle, m);
}
-int main(int argc, char *argv[]) {
+static int run(int argc, char *argv[]) {
_cleanup_(manager_unrefp) Manager *m = NULL;
int r;
@@ -358,8 +358,7 @@ int main(int argc, char *argv[]) {
if (argc != 1) {
log_error("This program takes no arguments.");
- r = -EINVAL;
- goto finish;
+ return -EINVAL;
}
/* Always create the directories people can create inotify watches in. Note that some applications might check
@@ -370,19 +369,14 @@ int main(int argc, char *argv[]) {
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, SIGTERM, SIGINT, -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_startup(m);
- if (r < 0) {
- log_error_errno(r, "Failed to fully start up daemon: %m");
- goto finish;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to fully start up daemon: %m");
log_debug("systemd-machined running as pid "PID_FMT, getpid_cached());
-
(void) sd_notify(false,
"READY=1\n"
"STATUS=Processing requests...");
@@ -390,11 +384,11 @@ int main(int argc, char *argv[]) {
r = manager_run(m);
log_debug("systemd-machined stopped as pid "PID_FMT, getpid_cached());
-
(void) sd_notify(false,
"STOPPING=1\n"
"STATUS=Shutting down...");
-finish:
- return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+ return r;
}
+
+DEFINE_MAIN_FUNCTION(run);