diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000000..eb604220676f --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,30 @@ +--- +Checks: " + bugprone-*, + cert-*, + clang-analyzer-*, + concurrency-*, + misc-*, + modernize-*, + performance-*, + portability-*, + readability-*, + -readability-identifier-length, + -readability-braces-around-statements, + -readability-avoid-const-params-in-decls, + -bugprone-easily-swappable-parameters, +" +WarningsAsErrors: " + bugprone-unsafe-functions, +" +HeaderFileExtensions: + - '' + - 'h' +ImplementationFileExtensions: + - 'c' +FormatStyle: none +CheckOptions: + bugprone-unsafe-functions.ReportDefaultFunctions: 'true' + bugprone-unsafe-functions.ReportMoreUnsafeFunctions: 'true' + bugprone-unsafe-functions.CustomFunctions: '^strtok$,strtok_r;^sprintf$,snprintf;^strcat$,strlcat;^strcpy$,strlcpy;^strncpy$,strlcat;^strncat$,strlcpy;^strndup$,,is OS specific;^strchrnul$;^rand$;^rand_r$;^index$;^rindex$;^bzero$,^memset$' + readability-function-cognitive-complexity.Threshold: 50 diff --git a/configure.ac b/configure.ac index ca964d9039a0..0623de52446c 100644 --- a/configure.ac +++ b/configure.ac @@ -224,6 +224,11 @@ [], [ #include ]) + AC_CHECK_DECL([quick_exit], + AC_DEFINE([HAVE_QUICK_EXIT], [1], [Use quick_exit]), + [], [ + #include + ]) AC_CHECK_HEADERS([malloc.h]) AC_CHECK_DECL([malloc_trim], diff --git a/src/util-debug.h b/src/util-debug.h index cb22e9097389..4fba832ea652 100644 --- a/src/util-debug.h +++ b/src/util-debug.h @@ -499,10 +499,14 @@ void SCLogErr(int x, const char *file, const char *func, const int line, const c #endif /* DEBUG */ +#if !HAVE_QUICK_EXIT +#define quick_exit exit +#endif + #define FatalError(...) \ do { \ SCLogError(__VA_ARGS__); \ - exit(EXIT_FAILURE); \ + quick_exit(EXIT_FAILURE); \ } while (0) /** \brief Fatal error IF we're starting up, and configured to consider @@ -515,7 +519,7 @@ void SCLogErr(int x, const char *file, const char *func, const int line, const c (void)ConfGetBool("engine.init-failure-fatal", &init_errors_fatal); \ if (init_errors_fatal && (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT)) { \ SCLogError(__VA_ARGS__); \ - exit(EXIT_FAILURE); \ + quick_exit(EXIT_FAILURE); \ } \ SCLogWarning(__VA_ARGS__); \ } while (0)