mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +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:
parent
4113a1f150
commit
8fc1a7efff
@ -677,7 +677,7 @@ constructNFA(const NGHolder &h_in, const ReportManager *rm,
|
|||||||
|
|
||||||
if (has_managed_reports(*h)) {
|
if (has_managed_reports(*h)) {
|
||||||
assert(rm);
|
assert(rm);
|
||||||
remapReportsToPrograms(*h, *rm);
|
remapReportsToPrograms(*h, *rm); //NOLINT (clang-analyzer-core.NonNullParamChecker)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cc.streaming || !cc.grey.compressNFAState) {
|
if (!cc.streaming || !cc.grey.compressNFAState) {
|
||||||
|
@ -158,7 +158,7 @@ GlushkovBuildStateImpl::GlushkovBuildStateImpl(NFABuilder &b,
|
|||||||
lasts.emplace_back(startState);
|
lasts.emplace_back(startState);
|
||||||
lasts.emplace_back(startDotstarState);
|
lasts.emplace_back(startDotstarState);
|
||||||
firsts.emplace_back(startDotstarState);
|
firsts.emplace_back(startDotstarState);
|
||||||
connectRegions(lasts, firsts);
|
connectRegions(lasts, firsts); //NOLINT (cplusplus.VirtualCall)
|
||||||
|
|
||||||
// accept to acceptEod edges already wired
|
// accept to acceptEod edges already wired
|
||||||
|
|
||||||
@ -341,7 +341,7 @@ void GlushkovBuildStateImpl::connectSuccessors(const PositionInfo &from,
|
|||||||
Position fakedot = builder.makePositions(1);
|
Position fakedot = builder.makePositions(1);
|
||||||
builder.addCharReach(fakedot, CharReach(0x00, 0xff));
|
builder.addCharReach(fakedot, CharReach(0x00, 0xff));
|
||||||
builder.setNodeReportID(fakedot, -1);
|
builder.setNodeReportID(fakedot, -1);
|
||||||
addSuccessor(fakedot, acceptState);
|
addSuccessor(fakedot, acceptState); //NOLINT (cplusplus.VirtualCall)
|
||||||
*accept = fakedot;
|
*accept = fakedot;
|
||||||
} else {
|
} else {
|
||||||
// We might lead to accept via an assertion vertex, so we add the
|
// 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));
|
assert(ISALIGNED_CL(current));
|
||||||
s->fullState = (char *)current;
|
s->fullState = (char *)current;
|
||||||
s->fullStateSize = fullStateSize;
|
s->fullStateSize = fullStateSize;
|
||||||
current += fullStateSize;
|
current += fullStateSize; //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||||
|
|
||||||
*scratch = s;
|
*scratch = s;
|
||||||
|
|
||||||
|
@ -345,9 +345,10 @@ void mmbit_clear(u8 *bits, u32 total_bits) {
|
|||||||
/** \brief Specialisation of \ref mmbit_set for flat models. */
|
/** \brief Specialisation of \ref mmbit_set for flat models. */
|
||||||
static really_inline
|
static really_inline
|
||||||
char mmbit_set_flat(u8 *bits, u32 total_bits, u32 key) {
|
char mmbit_set_flat(u8 *bits, u32 total_bits, u32 key) {
|
||||||
|
assert(bits);
|
||||||
bits += mmbit_flat_select_byte(key, total_bits);
|
bits += mmbit_flat_select_byte(key, total_bits);
|
||||||
u8 mask = 1U << (key % 8);
|
u8 mask = 1U << (key % 8);
|
||||||
char was_set = !!(*bits & mask);
|
char was_set = !!(*bits & mask); //NOLINT (clang-analyzer-core.NullDereference)
|
||||||
*bits |= mask;
|
*bits |= mask;
|
||||||
return was_set;
|
return was_set;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
static really_inline
|
static really_inline
|
||||||
void partial_store_u32(void *ptr, u32 value, u32 numBytes) {
|
void partial_store_u32(void *ptr, u32 value, u32 numBytes) {
|
||||||
|
assert(ptr);
|
||||||
assert(numBytes <= 4);
|
assert(numBytes <= 4);
|
||||||
switch (numBytes) {
|
switch (numBytes) {
|
||||||
case 4:
|
case 4:
|
||||||
@ -61,6 +62,7 @@ void partial_store_u32(void *ptr, u32 value, u32 numBytes) {
|
|||||||
static really_inline
|
static really_inline
|
||||||
u32 partial_load_u32(const void *ptr, u32 numBytes) {
|
u32 partial_load_u32(const void *ptr, u32 numBytes) {
|
||||||
u32 value;
|
u32 value;
|
||||||
|
assert(ptr);
|
||||||
assert(numBytes <= 4);
|
assert(numBytes <= 4);
|
||||||
switch (numBytes) {
|
switch (numBytes) {
|
||||||
case 4:
|
case 4:
|
||||||
@ -87,6 +89,7 @@ u32 partial_load_u32(const void *ptr, u32 numBytes) {
|
|||||||
|
|
||||||
static really_inline
|
static really_inline
|
||||||
void partial_store_u64a(void *ptr, u64a value, u32 numBytes) {
|
void partial_store_u64a(void *ptr, u64a value, u32 numBytes) {
|
||||||
|
assert(ptr);
|
||||||
assert(numBytes <= 8);
|
assert(numBytes <= 8);
|
||||||
switch (numBytes) {
|
switch (numBytes) {
|
||||||
case 8:
|
case 8:
|
||||||
@ -132,6 +135,7 @@ void partial_store_u64a(void *ptr, u64a value, u32 numBytes) {
|
|||||||
static really_inline
|
static really_inline
|
||||||
u64a partial_load_u64a(const void *ptr, u32 numBytes) {
|
u64a partial_load_u64a(const void *ptr, u32 numBytes) {
|
||||||
u64a value;
|
u64a value;
|
||||||
|
assert(ptr);
|
||||||
assert(numBytes <= 8);
|
assert(numBytes <= 8);
|
||||||
switch (numBytes) {
|
switch (numBytes) {
|
||||||
case 8:
|
case 8:
|
||||||
|
@ -40,36 +40,37 @@
|
|||||||
/// Perform an unaligned 16-bit load
|
/// Perform an unaligned 16-bit load
|
||||||
static really_inline
|
static really_inline
|
||||||
u16 unaligned_load_u16(const void *ptr) {
|
u16 unaligned_load_u16(const void *ptr) {
|
||||||
|
assert(ptr);
|
||||||
struct unaligned { u16 u; } PACKED__MAY_ALIAS;
|
struct unaligned { u16 u; } PACKED__MAY_ALIAS;
|
||||||
// cppcheck-suppress cstyleCast
|
// cppcheck-suppress cstyleCast
|
||||||
const struct unaligned *uptr = (const struct unaligned *)ptr;
|
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
|
/// Perform an unaligned 32-bit load
|
||||||
static really_inline
|
static really_inline
|
||||||
u32 unaligned_load_u32(const void *ptr) {
|
u32 unaligned_load_u32(const void *ptr) {
|
||||||
|
assert(ptr);
|
||||||
struct unaligned { u32 u; } PACKED__MAY_ALIAS;
|
struct unaligned { u32 u; } PACKED__MAY_ALIAS;
|
||||||
// cppcheck-suppress cstyleCast
|
// cppcheck-suppress cstyleCast
|
||||||
const struct unaligned *uptr = (const struct unaligned *)ptr;
|
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
|
/// Perform an unaligned 64-bit load
|
||||||
static really_inline
|
static really_inline
|
||||||
u64a unaligned_load_u64a(const void *ptr) {
|
u64a unaligned_load_u64a(const void *ptr) {
|
||||||
if (ptr == NULL) {
|
assert(ptr);
|
||||||
return 0; // Return a default value
|
|
||||||
}
|
|
||||||
struct unaligned { u64a u; } PACKED__MAY_ALIAS;
|
struct unaligned { u64a u; } PACKED__MAY_ALIAS;
|
||||||
// cppcheck-suppress cstyleCast
|
// cppcheck-suppress cstyleCast
|
||||||
const struct unaligned *uptr = (const struct unaligned *)ptr;
|
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
|
/// Perform an unaligned 16-bit store
|
||||||
static really_inline
|
static really_inline
|
||||||
void unaligned_store_u16(void *ptr, u16 val) {
|
void unaligned_store_u16(void *ptr, u16 val) {
|
||||||
|
assert(ptr);
|
||||||
struct unaligned { u16 u; } PACKED__MAY_ALIAS;
|
struct unaligned { u16 u; } PACKED__MAY_ALIAS;
|
||||||
// cppcheck-suppress cstyleCast
|
// cppcheck-suppress cstyleCast
|
||||||
struct unaligned *uptr = (struct unaligned *)ptr;
|
struct unaligned *uptr = (struct unaligned *)ptr;
|
||||||
@ -79,6 +80,7 @@ void unaligned_store_u16(void *ptr, u16 val) {
|
|||||||
/// Perform an unaligned 32-bit store
|
/// Perform an unaligned 32-bit store
|
||||||
static really_inline
|
static really_inline
|
||||||
void unaligned_store_u32(void *ptr, u32 val) {
|
void unaligned_store_u32(void *ptr, u32 val) {
|
||||||
|
assert(ptr);
|
||||||
struct unaligned { u32 u; } PACKED__MAY_ALIAS;
|
struct unaligned { u32 u; } PACKED__MAY_ALIAS;
|
||||||
// cppcheck-suppress cstyleCast
|
// cppcheck-suppress cstyleCast
|
||||||
struct unaligned *uptr = (struct unaligned *)ptr;
|
struct unaligned *uptr = (struct unaligned *)ptr;
|
||||||
@ -88,6 +90,7 @@ void unaligned_store_u32(void *ptr, u32 val) {
|
|||||||
/// Perform an unaligned 64-bit store
|
/// Perform an unaligned 64-bit store
|
||||||
static really_inline
|
static really_inline
|
||||||
void unaligned_store_u64a(void *ptr, u64a val) {
|
void unaligned_store_u64a(void *ptr, u64a val) {
|
||||||
|
assert(ptr);
|
||||||
struct unaligned { u64a u; } PACKED__MAY_ALIAS;
|
struct unaligned { u64a u; } PACKED__MAY_ALIAS;
|
||||||
// cppcheck-suppress cstyleCast
|
// cppcheck-suppress cstyleCast
|
||||||
struct unaligned *uptr = (struct unaligned *)ptr;
|
struct unaligned *uptr = (struct unaligned *)ptr;
|
||||||
|
@ -78,7 +78,7 @@ vector<DataBlock> readCorpus(const string &filename) {
|
|||||||
ostringstream err;
|
ostringstream err;
|
||||||
err << "Unable to open database '" << filename << "': "
|
err << "Unable to open database '" << filename << "': "
|
||||||
<< sqlite3_errmsg(db);
|
<< sqlite3_errmsg(db);
|
||||||
status = sqlite3_close(db);
|
status = sqlite3_close(db); //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||||
assert(status == SQLITE_OK);
|
assert(status == SQLITE_OK);
|
||||||
throw DataCorpusError(err.str());
|
throw DataCorpusError(err.str());
|
||||||
}
|
}
|
||||||
@ -91,9 +91,9 @@ vector<DataBlock> readCorpus(const string &filename) {
|
|||||||
status = sqlite3_prepare_v2(db, query.c_str(), query.size(), &statement,
|
status = sqlite3_prepare_v2(db, query.c_str(), query.size(), &statement,
|
||||||
nullptr);
|
nullptr);
|
||||||
if (status != SQLITE_OK) {
|
if (status != SQLITE_OK) {
|
||||||
status = sqlite3_finalize(statement);
|
status = sqlite3_finalize(statement); //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||||
assert(status == SQLITE_OK);
|
assert(status == SQLITE_OK);
|
||||||
status = sqlite3_close(db);
|
status = sqlite3_close(db); //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||||
assert(status == SQLITE_OK);
|
assert(status == SQLITE_OK);
|
||||||
|
|
||||||
ostringstream oss;
|
ostringstream oss;
|
||||||
@ -115,17 +115,17 @@ vector<DataBlock> readCorpus(const string &filename) {
|
|||||||
oss << "Error retrieving blocks from corpus: "
|
oss << "Error retrieving blocks from corpus: "
|
||||||
<< sqlite3_errmsg(db);
|
<< sqlite3_errmsg(db);
|
||||||
|
|
||||||
status = sqlite3_finalize(statement);
|
status = sqlite3_finalize(statement); //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||||
assert(status == SQLITE_OK);
|
assert(status == SQLITE_OK);
|
||||||
status = sqlite3_close(db);
|
status = sqlite3_close(db); //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||||
assert(status == SQLITE_OK);
|
assert(status == SQLITE_OK);
|
||||||
|
|
||||||
throw DataCorpusError(oss.str());
|
throw DataCorpusError(oss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
status = sqlite3_finalize(statement);
|
status = sqlite3_finalize(statement); //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||||
assert(status == SQLITE_OK);
|
assert(status == SQLITE_OK);
|
||||||
status = sqlite3_close(db);
|
status = sqlite3_close(db); //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||||
assert(status == SQLITE_OK);
|
assert(status == SQLITE_OK);
|
||||||
|
|
||||||
if (blocks.empty()) {
|
if (blocks.empty()) {
|
||||||
|
@ -234,13 +234,13 @@ void processArgs(int argc, char *argv[], vector<BenchmarkSigs> &sigSets,
|
|||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
int in_sigfile = 0;
|
int in_sigfile = 0;
|
||||||
int do_per_scan = 0;
|
static int do_per_scan = 0;
|
||||||
int do_compress = 0;
|
static int do_compress = 0;
|
||||||
int do_compress_size = 0;
|
int do_compress_size = 0;
|
||||||
int do_echo_matches = 0;
|
static int do_echo_matches = 0;
|
||||||
int do_sql_output = 0;
|
static int do_sql_output = 0;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
int literalFlag = 0;
|
static int literalFlag = 0;
|
||||||
vector<string> sigFiles;
|
vector<string> sigFiles;
|
||||||
|
|
||||||
static struct option longopts[] = {
|
static struct option longopts[] = {
|
||||||
|
@ -56,7 +56,7 @@ sqlite3 *initDB(const string &filename) {
|
|||||||
ostringstream oss;
|
ostringstream oss;
|
||||||
oss << "Unable to open database '" << filename
|
oss << "Unable to open database '" << filename
|
||||||
<< "': " << sqlite3_errmsg(db);
|
<< "': " << sqlite3_errmsg(db);
|
||||||
status = sqlite3_close(db);
|
status = sqlite3_close(db); //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||||
assert(status == SQLITE_OK);
|
assert(status == SQLITE_OK);
|
||||||
throw SqlFailure(oss.str());
|
throw SqlFailure(oss.str());
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ sqlite3 *initDB(const string &filename) {
|
|||||||
fail:
|
fail:
|
||||||
ostringstream oss;
|
ostringstream oss;
|
||||||
oss << "Unable to create tables: " << sqlite3_errmsg(db);
|
oss << "Unable to create tables: " << sqlite3_errmsg(db);
|
||||||
status = sqlite3_close(db);
|
status = sqlite3_close(db); //NOLINT (clang-analyzer-deadcode.DeadStores)
|
||||||
assert(status == SQLITE_OK);
|
assert(status == SQLITE_OK);
|
||||||
throw SqlFailure(oss.str());
|
throw SqlFailure(oss.str());
|
||||||
}
|
}
|
||||||
|
@ -494,7 +494,7 @@ static
|
|||||||
void processArgs(int argc, char *argv[], UNUSED const unique_ptr<Grey> &grey) {
|
void processArgs(int argc, char *argv[], UNUSED const unique_ptr<Grey> &grey) {
|
||||||
const char options[] = "e:E:s:z:hHLNV8G:T:BC";
|
const char options[] = "e:E:s:z:hHLNV8G:T:BC";
|
||||||
bool signatureSet = false;
|
bool signatureSet = false;
|
||||||
int literalFlag = 0;
|
static int literalFlag = 0;
|
||||||
|
|
||||||
static struct option longopts[] = {
|
static struct option longopts[] = {
|
||||||
{"literal-on", no_argument, &literalFlag, 1},
|
{"literal-on", no_argument, &literalFlag, 1},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user