]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/main-func: unify the two macros
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 20 Nov 2018 12:54:12 +0000 (13:54 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 20 Nov 2018 15:48:21 +0000 (16:48 +0100)
No functional change.

src/basic/main-func.h

index caa5885e8b015bc3511401f734d8cd7ea3e965f3..9dfcea9296fdc6bef29bcc2a36c35265d063c85f 100644 (file)
@@ -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)