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:
@@ -55,7 +55,7 @@ unique_ptr<hs_platform_info> xcompileReadMode(const char *s) {
|
||||
assert(!err);
|
||||
|
||||
string str(s);
|
||||
string opt = str.substr(str.find(":")+1, str.npos);
|
||||
string opt = str.substr(str.find(':')+1, str.npos);
|
||||
bool found_mode = false;
|
||||
|
||||
if (!opt.empty()) {
|
||||
|
@@ -96,7 +96,7 @@ hs_database_t * loadDatabase(const char *filename, bool verbose) {
|
||||
|
||||
bytes = reinterpret_cast<char *>(mmap(nullptr, len, PROT_READ, MAP_SHARED, fd, 0));
|
||||
if (bytes == MAP_FAILED) {
|
||||
cout << "mmap failed" << endl;
|
||||
cout << "mmap failed\n";
|
||||
close(fd);
|
||||
return nullptr;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ hs_database_t * loadDatabase(const char *filename, bool verbose) {
|
||||
is.seekg(0, ios::end);
|
||||
size_t len = is.tellg();
|
||||
if (verbose) {
|
||||
cout << "Reading " << len << " bytes" << endl;
|
||||
cout << "Reading " << len << " bytes\n";
|
||||
}
|
||||
is.seekg(0, ios::beg);
|
||||
bytes = new char[len];
|
||||
@@ -130,7 +130,7 @@ hs_database_t * loadDatabase(const char *filename, bool verbose) {
|
||||
cout << "Serialized database info: " << info << endl;
|
||||
std::free(info);
|
||||
} else {
|
||||
cout << "Unable to decode serialized database info." << endl;
|
||||
cout << "Unable to decode serialized database info.\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -53,7 +53,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);
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ void loadExpressions(const string &inPath, ExpressionMap &exprMap) {
|
||||
// Is our input path a file or a directory?
|
||||
struct stat st;
|
||||
if (stat(inPath.c_str(), &st) != 0) {
|
||||
cerr << "Can't stat path: '" << inPath << "'" << endl;
|
||||
cerr << "Can't stat path: '" << inPath << "'\n";
|
||||
exit(1);
|
||||
}
|
||||
if (S_ISREG(st.st_mode)) {
|
||||
@@ -145,13 +145,13 @@ void loadExpressions(const string &inPath, ExpressionMap &exprMap) {
|
||||
try {
|
||||
loadExpressionsFromFile(inPath, exprMap);
|
||||
} catch (runtime_error &e) {
|
||||
cerr << e.what() << ": '" << inPath << "'" << endl;
|
||||
cerr << e.what() << ": '" << inPath << "'\n";
|
||||
exit(1);
|
||||
}
|
||||
} else if (S_ISDIR(st.st_mode)) {
|
||||
DIR *d = opendir(inPath.c_str());
|
||||
if (d == nullptr) {
|
||||
cerr << "Can't open directory: '" << inPath << "'" << endl;
|
||||
cerr << "Can't open directory: '" << inPath << "'\n";
|
||||
exit(1);
|
||||
}
|
||||
for (struct dirent *ent = readdir(d); ent; ent = readdir(d)) {
|
||||
@@ -174,7 +174,7 @@ void loadExpressions(const string &inPath, ExpressionMap &exprMap) {
|
||||
try {
|
||||
loadExpressionsFromFile(fname, exprMap);
|
||||
} catch (runtime_error &e) {
|
||||
cerr << e.what() << ": '" << fname << "'" << endl;
|
||||
cerr << e.what() << ": '" << fname << "'\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -182,7 +182,7 @@ void loadExpressions(const string &inPath, ExpressionMap &exprMap) {
|
||||
} else {
|
||||
cerr << "Unsupported file type "
|
||||
<< hex << showbase << (st.st_mode & S_IFMT)
|
||||
<< " for path: '" << inPath << "'" << endl;
|
||||
<< " for path: '" << inPath << "'\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ void HS_CDECL loadSignatureList(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);
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ ExpressionMap limitToSignatures(const ExpressionMap &exprMap,
|
||||
auto match = exprMap.find(id);
|
||||
if (match == exprMap.end()) {
|
||||
cerr << "Unable to find signature " << id
|
||||
<< " in expression set!" << endl;
|
||||
<< " in expression set!\n";
|
||||
exit(1);
|
||||
}
|
||||
keepers.insert(*match);
|
||||
|
@@ -48,7 +48,7 @@ class NGHolder;
|
||||
|
||||
struct CorpusGenerationFailure {
|
||||
explicit CorpusGenerationFailure(const std::string& s) :
|
||||
message(std::move(s)) {}
|
||||
message(s) {}
|
||||
std::string message;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user