Fixes after static analyser

This commit is contained in:
Miroslav Crnic
2025-09-23 09:40:10 +00:00
committed by Francesco Mazzoli
parent 1a66e1d2e1
commit 6724f05691
3 changed files with 8 additions and 6 deletions

View File

@@ -157,7 +157,7 @@ std::string removeTemplates(const std::string & s) {
// which needs fixing
size_t begin = 0;
int stack = 0;
for (size_t i=0; i<r.size(); ++i) {
for (size_t i = 0; i < r.size(); ++i) {
if (r[i] == '<') {
if (stack == 0) begin = i;
++stack;
@@ -165,7 +165,7 @@ std::string removeTemplates(const std::string & s) {
if (stack == 0) continue;
--stack;
if (stack == 0) {
r = r.substr(0, begin) + r.substr(i+1);
r.erase(begin, i + 1 - begin);
i = begin;
}
}
@@ -174,7 +174,7 @@ std::string removeTemplates(const std::string & s) {
// Remove any trailing [with args ...] sections
size_t with_args = r.find(" [with args");
if (with_args != std::string::npos && r[r.size()-1] == ']') {
r = r.substr(0, with_args);
r.resize(with_args);
}
return r;

View File

@@ -288,7 +288,7 @@ public:
ROCKS_DB_CHECKED(_sharedDb.db()->Write({}, &batch));
}
void writeLogEntry(const LogsDBLogEntry entry) {
void writeLogEntry(const LogsDBLogEntry& entry) {
_maybeRotate();
auto& partition = _getPartitionForIdx(entry.idx);
@@ -1701,7 +1701,6 @@ public:
}
}
for(auto& req : requests) {
ALWAYS_ASSERT(req.msg.body.kind() == req.msg.body.kind());
switch (req.msg.body.kind()) {
case LogMessageKind::ERROR:
LOG_ERROR(_env, "Bad request %s", req);

View File

@@ -98,7 +98,10 @@ Xmon::Xmon(
throw SYSCALL_EXCEPTION("gethostname");
}
_hostname = buf;
_hostname = _hostname.substr(0, _hostname.find("."));
auto end = _hostname.find(".");
if (end != -1) {
_hostname.resize(end);
}
}
_appInstance = _appInstance + "@" + _hostname;