diff --git a/src/shared/main-func.h b/src/shared/main-func.h index 67537555a12ea..e55655108e9d0 100644 --- a/src/shared/main-func.h +++ b/src/shared/main-func.h @@ -20,6 +20,7 @@ #define _DEFINE_MAIN_FUNCTION(intro, impl, result_to_exit_status, result_to_return_value) \ int main(int argc, char *argv[]) { \ + errno = 0; \ int r; \ assert_se(argc > 0 && !isempty(argv[0])); \ save_argc_argv(argc, argv); \ diff --git a/src/shared/tests.h b/src/shared/tests.h index 141bfe4f22d87..e3040c6cde7fa 100644 --- a/src/shared/tests.h +++ b/src/shared/tests.h @@ -184,6 +184,7 @@ static inline int run_test_table(void) { #define DEFINE_TEST_MAIN_FULL(log_level, intro, outro) \ int main(int argc, char *argv[]) { \ + errno = 0; \ int (*_intro)(void) = intro; \ int (*_outro)(void) = outro; \ int _r, _q; \