mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-29 19:24:25 +03:00
Bug fix/clang-tidy-performance (#300)
Various clang-tidy-performance fixes: * noexcept * performance-noexcept-swap * performance * performance-move-const-arg * performance-unnecessary-value-param * performance-inefficient-vector-operation * performance-no-int-to-ptr * add performance * performance-inefficient-string-concatenation * clang-analyzer-deadcode.DeadStores * performance-inefficient-vector-operation * clang-analyzer-core.NullDereference * clang-analyzer-core.UndefinedBinaryOperatorResult * clang-analyzer-core.CallAndMessage --------- Co-authored-by: gtsoul-tech <gtsoulkanakis@gmail.com>
This commit is contained in:
@@ -90,7 +90,7 @@ hs_database_t *get_huge(hs_database_t *db) {
|
||||
}
|
||||
|
||||
shmaddr = shmat(hsdb_shmid, nullptr, SHM_RND);
|
||||
if (shmaddr == (char *)-1) {
|
||||
if (shmaddr == (char *)-1) { //NOLINT (performance-no-int-to-ptr)
|
||||
perror("Shared memory attach failure");
|
||||
goto fini;
|
||||
}
|
||||
|
@@ -98,7 +98,7 @@ unsigned int countFailures = 0;
|
||||
class ParsedExpr {
|
||||
public:
|
||||
ParsedExpr(string regex_in, unsigned int flags_in, const hs_expr_ext& ext_in)
|
||||
: regex(regex_in), flags(flags_in), ext(ext_in) {}
|
||||
: regex(std::move(regex_in)), flags(flags_in), ext(ext_in) {}
|
||||
~ParsedExpr() {}
|
||||
string regex;
|
||||
unsigned int flags;
|
||||
@@ -308,7 +308,7 @@ void checkExpression(UNUSED void *threadarg) {
|
||||
ch_free_compile_error(ch_compile_err);
|
||||
}
|
||||
#else
|
||||
cerr << "Hybrid mode not available in this build." << endl;
|
||||
cerr << "Hybrid mode not available in this build.\n";
|
||||
exit(1);
|
||||
#endif // HS_HYBRID
|
||||
} else {
|
||||
@@ -468,26 +468,25 @@ void checkLogicalExpression(UNUSED void *threadarg) {
|
||||
static
|
||||
void usage() {
|
||||
cout << "Usage: hscheck [OPTIONS...]" << endl << endl
|
||||
<< " -e PATH Path to expression directory." << endl
|
||||
<< " -s FILE Signature file to use." << endl
|
||||
<< " -z NUM Signature ID to use." << endl
|
||||
<< " -E DISTANCE Force edit distance to DISTANCE for all patterns." << endl
|
||||
<< " -e PATH Path to expression directory.\n"
|
||||
<< " -s FILE Signature file to use.\n"
|
||||
<< " -z NUM Signature ID to use.\n"
|
||||
<< " -E DISTANCE Force edit distance to DISTANCE for all patterns.\n"
|
||||
#ifndef RELEASE_BUILD
|
||||
<< " -G OVERRIDES Overrides for the grey." << endl
|
||||
<< " -G OVERRIDES Overrides for the grey.\n"
|
||||
#endif
|
||||
<< " -V Operate in vectored mode." << endl
|
||||
<< " -N Operate in block mode (default: streaming)." << endl
|
||||
<< " -V Operate in vectored mode.\n"
|
||||
<< " -N Operate in block mode (default: streaming).\n"
|
||||
#ifdef HS_HYBRID
|
||||
<< " -H Operate in hybrid mode." << endl
|
||||
<< " -H Operate in hybrid mode.\n"
|
||||
#endif
|
||||
<< " -L Pass HS_FLAG_SOM_LEFTMOST for all expressions (default: off)." << endl
|
||||
<< " -8 Force UTF8 mode on all patterns." << endl
|
||||
<< " -T NUM Run with NUM threads." << endl
|
||||
<< " -h Display this help." << endl
|
||||
<< " -B Build signature set." << endl
|
||||
<< " -C Check logical combinations (default: off)." << endl
|
||||
<< " --literal-on Processing pure literals, no need to check." << endl
|
||||
<< endl;
|
||||
<< " -L Pass HS_FLAG_SOM_LEFTMOST for all expressions (default: off).\n"
|
||||
<< " -8 Force UTF8 mode on all patterns.\n"
|
||||
<< " -T NUM Run with NUM threads.\n"
|
||||
<< " -h Display this help.\n"
|
||||
<< " -B Build signature set.\n"
|
||||
<< " -C Check logical combinations (default: off).\n"
|
||||
<< " --literal-on Processing pure literals, no need to check.\n\n";
|
||||
}
|
||||
|
||||
static
|
||||
@@ -599,7 +598,7 @@ void failLine(unsigned lineNum, const string &file,
|
||||
const string &line, const string &error) {
|
||||
cerr << "Parse error in file " << file
|
||||
<< " on line " << lineNum << ": " << error
|
||||
<< endl << "Line is: '" << line << "'" << endl;
|
||||
<< endl << "Line is: '" << line << "'\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -612,7 +611,7 @@ void loadSignatureBuildSigs(const string &inFile,
|
||||
SignatureSet &signatures) {
|
||||
ifstream f(inFile.c_str());
|
||||
if (!f.good()) {
|
||||
cerr << "Can't open file: '" << inFile << "'" << endl;
|
||||
cerr << "Can't open file: '" << inFile << "'\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -665,7 +664,7 @@ int HS_CDECL main(int argc, char **argv) {
|
||||
processArgs(argc, argv, g_grey);
|
||||
|
||||
if (num_of_threads == 0) {
|
||||
cout << "Error: Must have at least one thread." << endl;
|
||||
cout << "Error: Must have at least one thread.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -687,7 +686,7 @@ int HS_CDECL main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
if (g_exprMap.empty()) {
|
||||
cout << "Warning: no signatures to scan. Exiting." << endl;
|
||||
cout << "Warning: no signatures to scan. Exiting.\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -717,7 +716,7 @@ int HS_CDECL main(int argc, char **argv) {
|
||||
|
||||
if (!g_exprMap.empty() && !build_sigs) {
|
||||
cout << "SUMMARY: " << countFailures << " of "
|
||||
<< g_exprMap.size() << " failed." << endl;
|
||||
<< g_exprMap.size() << " failed.\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@@ -337,7 +337,9 @@ void clearDir(const string &path) {
|
||||
if (name == "." || name == "..") {
|
||||
continue;
|
||||
}
|
||||
string f = path + '/' + name;
|
||||
string f = path;
|
||||
f += '/';
|
||||
f += name;
|
||||
if (unlink(f.c_str()) < 0) {
|
||||
printf("ERROR: couldn't remove file %s: %s\n", f.c_str(),
|
||||
strerror(errno));
|
||||
|
Reference in New Issue
Block a user