mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-15 17:02:14 +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:
@@ -677,7 +677,7 @@ constructNFA(const NGHolder &h_in, const ReportManager *rm,
|
||||
|
||||
if (has_managed_reports(*h)) {
|
||||
assert(rm);
|
||||
remapReportsToPrograms(*h, *rm);
|
||||
remapReportsToPrograms(*h, *rm); //NOLINT (clang-analyzer-core.NonNullParamChecker)
|
||||
}
|
||||
|
||||
if (!cc.streaming || !cc.grey.compressNFAState) {
|
||||
|
||||
@@ -158,7 +158,7 @@ GlushkovBuildStateImpl::GlushkovBuildStateImpl(NFABuilder &b,
|
||||
lasts.emplace_back(startState);
|
||||
lasts.emplace_back(startDotstarState);
|
||||
firsts.emplace_back(startDotstarState);
|
||||
connectRegions(lasts, firsts);
|
||||
connectRegions(lasts, firsts); //NOLINT (cplusplus.VirtualCall)
|
||||
|
||||
// accept to acceptEod edges already wired
|
||||
|
||||
@@ -341,7 +341,7 @@ void GlushkovBuildStateImpl::connectSuccessors(const PositionInfo &from,
|
||||
Position fakedot = builder.makePositions(1);
|
||||
builder.addCharReach(fakedot, CharReach(0x00, 0xff));
|
||||
builder.setNodeReportID(fakedot, -1);
|
||||
addSuccessor(fakedot, acceptState);
|
||||
addSuccessor(fakedot, acceptState); //NOLINT (cplusplus.VirtualCall)
|
||||
*accept = fakedot;
|
||||
} else {
|
||||
// We might lead to accept via an assertion vertex, so we add the
|
||||
|
||||
@@ -225,7 +225,7 @@ hs_error_t alloc_scratch(const hs_scratch_t *proto, hs_scratch_t **scratch) {
|
||||
assert(ISALIGNED_CL(current));
|
||||
s->fullState = (char *)current;
|
||||
s->fullStateSize = fullStateSize;
|
||||
current += fullStateSize;
|
||||
current += fullStateSize; //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||
|
||||
*scratch = s;
|
||||
|
||||
|
||||
@@ -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