From 33f4f3a5a1a62e9173a0435f09f59e5b3c06a24e Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Sun, 12 May 2024 08:35:04 +0200 Subject: [PATCH] all: minor clang-tidy cleanups --- .clang-tidy | 1 - src/check/dt_check.cpp | 7 ++++++- src/util/util.cpp | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index ec0a863e..e6f5f359 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -23,7 +23,6 @@ Checks: > clang-analyzer-*, -clang-analyzer-optin.performance.Padding, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, - -clang-analyzer-security.insecureAPI.rand, -clang-analyzer-security.insecureAPI.strcpy, clang-diagnostic-*, performance-*, diff --git a/src/check/dt_check.cpp b/src/check/dt_check.cpp index d44eee55..bf93a22f 100644 --- a/src/check/dt_check.cpp +++ b/src/check/dt_check.cpp @@ -313,7 +313,6 @@ struct CheckSignedness { static inline void checkU(void) noexcept { COMPILE_TIME_ASSERT(sizeof(U) == sizeof(T)); COMPILE_TIME_ASSERT(alignof(U) == alignof(T)); - COMPILE_TIME_ASSERT(U_is_signed ? ((U) 0 - 1 < 0) : ((U) 0 - 1 > 0)); constexpr U all_bits = (U) (U(0) - U(1)); COMPILE_TIME_ASSERT(U_is_signed ? (all_bits < 0) : (all_bits > 0)); } @@ -520,8 +519,14 @@ void upx_compiler_sanity_check(void) noexcept { CheckIntegral::check(); CheckIntegral::check(); CheckIntegral::check(); + CheckIntegral::check(); CheckIntegral::check(); + CheckSignedness::check(); // -funsigned-char + CheckSignedness::check(); + CheckSignedness::check(); + CheckSignedness::check(); + CheckSignedness::check(); CheckSignedness::check(); CheckSignedness::check(); CheckSignedness::check(); diff --git a/src/util/util.cpp b/src/util/util.cpp index 70f44dc3..52e79140 100644 --- a/src/util/util.cpp +++ b/src/util/util.cpp @@ -260,7 +260,9 @@ const char *upx_getenv(const char *envvar) noexcept { } // random value from libc; quality is not important for UPX -int upx_rand(void) noexcept { return ::rand(); } +int upx_rand(void) noexcept { + return ::rand(); // NOLINT(clang-analyzer-security.insecureAPI.rand) +} void upx_rand_init(void) noexcept { unsigned seed = 0;