From 51e237864221f3edb0c0fb28684901f538341cb1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 16 Nov 2018 15:27:21 +0100 Subject: [PATCH] volatile-root: define main through macro --- src/volatile-root/volatile-root.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/volatile-root/volatile-root.c b/src/volatile-root/volatile-root.c index bc786c9..ab7dca3 100644 --- a/src/volatile-root/volatile-root.c +++ b/src/volatile-root/volatile-root.c @@ -76,7 +76,7 @@ finish_rmdir: return r; } -int main(int argc, char *argv[]) { +static int run(int argc, char *argv[]) { VolatileMode m = _VOLATILE_MODE_INVALID; const char *path; int r; @@ -87,22 +87,18 @@ int main(int argc, char *argv[]) { if (argc > 3) { log_error("Too many arguments. Expected directory and mode."); - r = -EINVAL; - goto finish; + return -EINVAL; } r = query_volatile_mode(&m); - if (r < 0) { - log_error_errno(r, "Failed to determine volatile mode from kernel command line."); - goto finish; - } + if (r < 0) + return log_error_errno(r, "Failed to determine volatile mode from kernel command line."); if (r == 0 && argc >= 2) { /* The kernel command line always wins. However if nothing was set there, the argument passed here wins instead. */ m = volatile_mode_from_string(argv[1]); if (m < 0) { log_error("Couldn't parse volatile mode: %s", argv[1]); r = -EINVAL; - goto finish; } } @@ -113,28 +109,22 @@ int main(int argc, char *argv[]) { if (isempty(path)) { log_error("Directory name cannot be empty."); - r = -EINVAL; - goto finish; + return -EINVAL; } if (!path_is_absolute(path)) { log_error("Directory must be specified as absolute path."); - r = -EINVAL; - goto finish; + return -EINVAL; } if (path_equal(path, "/")) { log_error("Directory cannot be the root directory."); - r = -EINVAL; - goto finish; + return -EINVAL; } } - if (m != VOLATILE_YES) { - r = 0; - goto finish; - } - - r = make_volatile(path); + if (m != VOLATILE_YES) + return 0; -finish: - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + return make_volatile(path); } + +DEFINE_MAIN_FUNCTION(run); -- 2.7.4