all: minor clang-tidy cleanups

This commit is contained in:
Markus F.X.J. Oberhumer 2024-05-12 08:35:04 +02:00
parent 07a3b75b3e
commit 33f4f3a5a1
3 changed files with 9 additions and 3 deletions

View File

@ -23,7 +23,6 @@ Checks: >
clang-analyzer-*, clang-analyzer-*,
-clang-analyzer-optin.performance.Padding, -clang-analyzer-optin.performance.Padding,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
-clang-analyzer-security.insecureAPI.rand,
-clang-analyzer-security.insecureAPI.strcpy, -clang-analyzer-security.insecureAPI.strcpy,
clang-diagnostic-*, clang-diagnostic-*,
performance-*, performance-*,

View File

@ -313,7 +313,6 @@ struct CheckSignedness {
static inline void checkU(void) noexcept { static inline void checkU(void) noexcept {
COMPILE_TIME_ASSERT(sizeof(U) == sizeof(T)); COMPILE_TIME_ASSERT(sizeof(U) == sizeof(T));
COMPILE_TIME_ASSERT(alignof(U) == alignof(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)); constexpr U all_bits = (U) (U(0) - U(1));
COMPILE_TIME_ASSERT(U_is_signed ? (all_bits < 0) : (all_bits > 0)); COMPILE_TIME_ASSERT(U_is_signed ? (all_bits < 0) : (all_bits > 0));
} }
@ -520,8 +519,14 @@ void upx_compiler_sanity_check(void) noexcept {
CheckIntegral<size_t>::check(); CheckIntegral<size_t>::check();
CheckIntegral<upx_off_t>::check(); CheckIntegral<upx_off_t>::check();
CheckIntegral<upx_ptraddr_t>::check(); CheckIntegral<upx_ptraddr_t>::check();
CheckIntegral<upx_sptraddr_t>::check();
CheckIntegral<upx_uintptr_t>::check(); CheckIntegral<upx_uintptr_t>::check();
CheckSignedness<char, false>::check(); // -funsigned-char
CheckSignedness<signed char, true>::check();
CheckSignedness<unsigned char, false>::check();
CheckSignedness<short, true>::check();
CheckSignedness<unsigned short, false>::check();
CheckSignedness<long long, true>::check(); CheckSignedness<long long, true>::check();
CheckSignedness<ptrdiff_t, true>::check(); CheckSignedness<ptrdiff_t, true>::check();
CheckSignedness<intptr_t, true>::check(); CheckSignedness<intptr_t, true>::check();

View File

@ -260,7 +260,9 @@ const char *upx_getenv(const char *envvar) noexcept {
} }
// random value from libc; quality is not important for UPX // 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 { void upx_rand_init(void) noexcept {
unsigned seed = 0; unsigned seed = 0;