diff options
-rw-r--r-- | config/config.h.in | 1 | ||||
-rwxr-xr-x | scripts/pvscheck.sh | 4 | ||||
-rw-r--r-- | src/nvim/assert.h | 20 | ||||
-rw-r--r-- | src/nvim/log.c | 1 | ||||
-rw-r--r-- | src/nvim/log.h | 2 |
5 files changed, 21 insertions, 7 deletions
diff --git a/config/config.h.in b/config/config.h.in index 106013425d..4239506cab 100644 --- a/config/config.h.in +++ b/config/config.h.in @@ -71,5 +71,6 @@ #define ENDIAN_INCLUDE_FILE <@ENDIAN_INCLUDE_FILE@> #cmakedefine HAVE_EXECINFO_BACKTRACE +#cmakedefine HAVE_BUILTIN_ADD_OVERFLOW #endif // AUTO_CONFIG_H diff --git a/scripts/pvscheck.sh b/scripts/pvscheck.sh index e3c6681f7a..fed50dde53 100755 --- a/scripts/pvscheck.sh +++ b/scripts/pvscheck.sh @@ -374,7 +374,7 @@ run_analysis() {( --sourcetree-root . || true rm -rf PVS-studio.{xml,err,tsk,html.d} - local plog_args="PVS-studio.log --srcRoot . --excludedCodes V011 --exclude-path stddef.h --exclude-path stdarg.h" + local plog_args="PVS-studio.log --srcRoot . --excludedCodes V011" plog-converter $plog_args --renderTypes xml --output PVS-studio.xml plog-converter $plog_args --renderTypes errorfile --output PVS-studio.err plog-converter $plog_args --renderTypes tasklist --output PVS-studio.tsk @@ -473,8 +473,6 @@ main() { return 0 fi - # set -x - if test -n "$patch" ; then patch_sources "$tgt" "$only_build" elif test -n "$pvs_install" ; then diff --git a/src/nvim/assert.h b/src/nvim/assert.h index 29195a49dc..db21bed0e2 100644 --- a/src/nvim/assert.h +++ b/src/nvim/assert.h @@ -1,6 +1,8 @@ #ifndef NVIM_ASSERT_H #define NVIM_ASSERT_H +#include "auto/config.h" + // support static asserts (aka compile-time asserts) // some compilers don't properly support short-circuiting apparently, giving @@ -133,9 +135,14 @@ /// /// @param MAX Maximum value of the narrowest type of operand. /// Not used if compiler supports __builtin_add_overflow. -#if HAVE_BUILTIN_ADD_OVERFLOW +#ifdef HAVE_BUILTIN_ADD_OVERFLOW # define STRICT_ADD(a, b, c, t) \ - do { if (__builtin_add_overflow(a, b, c)) { abort(); } } while (0) + do { \ + if (__builtin_add_overflow(a, b, c)) { \ + ELOG("STRICT_ADD overflow"); \ + abort(); \ + } \ + } while (0) #else # define STRICT_ADD(a, b, c, t) \ do { *(c) = (t)(a + b); } while (0) @@ -143,9 +150,14 @@ /// @def STRICT_SUB /// @brief Subtracts (a - b) and stores result in `c`. Aborts on overflow. -#if HAVE_BUILTIN_ADD_OVERFLOW +#ifdef HAVE_BUILTIN_ADD_OVERFLOW # define STRICT_SUB(a, b, c, t) \ - do { if (__builtin_sub_overflow(a, b, c)) { abort(); } } while (0) + do { \ + if (__builtin_sub_overflow(a, b, c)) { \ + ELOG("STRICT_SUB overflow"); \ + abort(); \ + } \ + } while (0) #else # define STRICT_SUB(a, b, c, t) \ do { *(c) = (t)(a - b); } while (0) diff --git a/src/nvim/log.c b/src/nvim/log.c index 4d912c452b..8066b6e828 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -12,6 +12,7 @@ #endif #include <uv.h> +#include "auto/config.h" #include "nvim/log.h" #include "nvim/types.h" #include "nvim/os/os.h" diff --git a/src/nvim/log.h b/src/nvim/log.h index 7d4c033565..17ff095473 100644 --- a/src/nvim/log.h +++ b/src/nvim/log.h @@ -4,6 +4,8 @@ #include <stdio.h> #include <stdbool.h> +#include "auto/config.h" + #define DEBUG_LOG_LEVEL 0 #define INFO_LOG_LEVEL 1 #define WARN_LOG_LEVEL 2 |