mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-19 02:30:35 +03:00
Bug fix/clang tidy warnings part2 (#296)
* core.StackAddressEscape * cplusplus.VirtualCall * clang-analyzer-deadcode.DeadStores * clang-analyzer-core.NullDereference * clang-analyzer-core.NonNullParamChecker * change to nolint --------- Co-authored-by: gtsoul-tech <gtsoulkanakis@gmail.com>
This commit is contained in:
@@ -345,9 +345,10 @@ void mmbit_clear(u8 *bits, u32 total_bits) {
|
||||
/** \brief Specialisation of \ref mmbit_set for flat models. */
|
||||
static really_inline
|
||||
char mmbit_set_flat(u8 *bits, u32 total_bits, u32 key) {
|
||||
assert(bits);
|
||||
bits += mmbit_flat_select_byte(key, total_bits);
|
||||
u8 mask = 1U << (key % 8);
|
||||
char was_set = !!(*bits & mask);
|
||||
char was_set = !!(*bits & mask); //NOLINT (clang-analyzer-core.NullDereference)
|
||||
*bits |= mask;
|
||||
return was_set;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
static really_inline
|
||||
void partial_store_u32(void *ptr, u32 value, u32 numBytes) {
|
||||
assert(ptr);
|
||||
assert(numBytes <= 4);
|
||||
switch (numBytes) {
|
||||
case 4:
|
||||
@@ -61,6 +62,7 @@ void partial_store_u32(void *ptr, u32 value, u32 numBytes) {
|
||||
static really_inline
|
||||
u32 partial_load_u32(const void *ptr, u32 numBytes) {
|
||||
u32 value;
|
||||
assert(ptr);
|
||||
assert(numBytes <= 4);
|
||||
switch (numBytes) {
|
||||
case 4:
|
||||
@@ -87,6 +89,7 @@ u32 partial_load_u32(const void *ptr, u32 numBytes) {
|
||||
|
||||
static really_inline
|
||||
void partial_store_u64a(void *ptr, u64a value, u32 numBytes) {
|
||||
assert(ptr);
|
||||
assert(numBytes <= 8);
|
||||
switch (numBytes) {
|
||||
case 8:
|
||||
@@ -132,6 +135,7 @@ void partial_store_u64a(void *ptr, u64a value, u32 numBytes) {
|
||||
static really_inline
|
||||
u64a partial_load_u64a(const void *ptr, u32 numBytes) {
|
||||
u64a value;
|
||||
assert(ptr);
|
||||
assert(numBytes <= 8);
|
||||
switch (numBytes) {
|
||||
case 8:
|
||||
|
||||
@@ -40,36 +40,37 @@
|
||||
/// Perform an unaligned 16-bit load
|
||||
static really_inline
|
||||
u16 unaligned_load_u16(const void *ptr) {
|
||||
assert(ptr);
|
||||
struct unaligned { u16 u; } PACKED__MAY_ALIAS;
|
||||
// cppcheck-suppress cstyleCast
|
||||
const struct unaligned *uptr = (const struct unaligned *)ptr;
|
||||
return uptr->u;
|
||||
return uptr->u; //NOLINT (clang-analyzer-core.NullDereference)
|
||||
}
|
||||
|
||||
/// Perform an unaligned 32-bit load
|
||||
static really_inline
|
||||
u32 unaligned_load_u32(const void *ptr) {
|
||||
assert(ptr);
|
||||
struct unaligned { u32 u; } PACKED__MAY_ALIAS;
|
||||
// cppcheck-suppress cstyleCast
|
||||
const struct unaligned *uptr = (const struct unaligned *)ptr;
|
||||
return uptr->u;
|
||||
return uptr->u; //NOLINT (clang-analyzer-core.NullDereference)
|
||||
}
|
||||
|
||||
/// Perform an unaligned 64-bit load
|
||||
static really_inline
|
||||
u64a unaligned_load_u64a(const void *ptr) {
|
||||
if (ptr == NULL) {
|
||||
return 0; // Return a default value
|
||||
}
|
||||
assert(ptr);
|
||||
struct unaligned { u64a u; } PACKED__MAY_ALIAS;
|
||||
// cppcheck-suppress cstyleCast
|
||||
const struct unaligned *uptr = (const struct unaligned *)ptr;
|
||||
return uptr->u;
|
||||
return uptr->u; //NOLINT (clang-analyzer-core.uninitialized.UndefReturn)
|
||||
}
|
||||
|
||||
/// Perform an unaligned 16-bit store
|
||||
static really_inline
|
||||
void unaligned_store_u16(void *ptr, u16 val) {
|
||||
assert(ptr);
|
||||
struct unaligned { u16 u; } PACKED__MAY_ALIAS;
|
||||
// cppcheck-suppress cstyleCast
|
||||
struct unaligned *uptr = (struct unaligned *)ptr;
|
||||
@@ -79,6 +80,7 @@ void unaligned_store_u16(void *ptr, u16 val) {
|
||||
/// Perform an unaligned 32-bit store
|
||||
static really_inline
|
||||
void unaligned_store_u32(void *ptr, u32 val) {
|
||||
assert(ptr);
|
||||
struct unaligned { u32 u; } PACKED__MAY_ALIAS;
|
||||
// cppcheck-suppress cstyleCast
|
||||
struct unaligned *uptr = (struct unaligned *)ptr;
|
||||
@@ -88,6 +90,7 @@ void unaligned_store_u32(void *ptr, u32 val) {
|
||||
/// Perform an unaligned 64-bit store
|
||||
static really_inline
|
||||
void unaligned_store_u64a(void *ptr, u64a val) {
|
||||
assert(ptr);
|
||||
struct unaligned { u64a u; } PACKED__MAY_ALIAS;
|
||||
// cppcheck-suppress cstyleCast
|
||||
struct unaligned *uptr = (struct unaligned *)ptr;
|
||||
|
||||
Reference in New Issue
Block a user