ac-power: define main through macro

I decided to use a separate definition for this because it's too easy to return
positive from functions which don't need this distinction and only return
negative on error and success otherwise.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2018-11-17 09:13:35 +01:00
parent a974a6569e
commit 9a5cedc319
2 changed files with 17 additions and 8 deletions
+10
View File
@@ -515,4 +515,14 @@ static inline int __coverity_check__(int condition) {
return 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); \
return r != 0 ? EXIT_FAILURE : EXIT_SUCCESS; \
}
#include "log.h"