From: Zbigniew Jędrzejewski-Szmek Date: Tue, 20 Nov 2018 12:54:12 +0000 (+0100) Subject: basic/main-func: unify the two macros X-Git-Tag: v240~258^2~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec5e5948315c856077861b06162ffbc4a83c5b79;p=thirdparty%2Fsystemd.git basic/main-func: unify the two macros No functional change. --- diff --git a/src/basic/main-func.h b/src/basic/main-func.h index caa5885e8b0..9dfcea9296f 100644 --- a/src/basic/main-func.h +++ b/src/basic/main-func.h @@ -5,23 +5,21 @@ #include "static-destruct.h" -/* Negative return values from impl are mapped to EXIT_FAILURE, and - * everything else means success! */ -#define DEFINE_MAIN_FUNCTION(impl) \ +#define _DEFINE_MAIN_FUNCTION(impl, ret) \ int main(int argc, char *argv[]) { \ int r; \ r = impl(argc, argv); \ static_destruct(); \ - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; \ + return ret; \ } +/* Negative return values from impl are mapped to EXIT_FAILURE, and + * everything else means success! */ +#define DEFINE_MAIN_FUNCTION(impl) \ + _DEFINE_MAIN_FUNCTION(impl, r < 0 ? EXIT_FAILURE : EXIT_SUCCESS) + /* Zero is mapped to EXIT_SUCCESS, and both negative and positive values * are mapped to EXIT_FAILURE. * Note: this means "true" maps to EXIT_FAILURE. */ #define DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(impl) \ - int main(int argc, char *argv[]) { \ - int r; \ - r = impl(argc, argv); \ - static_destruct(); \ - return r != 0 ? EXIT_FAILURE : EXIT_SUCCESS; \ - } + _DEFINE_MAIN_FUNCTION(impl, r != 0 ? EXIT_FAILURE : EXIT_SUCCESS)