Fix compiler warnings by (copy-)constructing loop variables explicitly

for (const T& needle : haystack) creates the illusion that haystack is a
container of T and we're just borrowing needle. In these cases that's not true.
This commit is contained in:
Alexander A. Klimov 2023-03-31 12:36:37 +02:00
parent 9abf482708
commit c2ddd20ef3
36 changed files with 66 additions and 66 deletions

View File

@ -401,7 +401,7 @@ static int Main()
#endif /* _WIN32 */ #endif /* _WIN32 */
if (vm.count("define")) { if (vm.count("define")) {
for (const String& define : vm["define"].as<std::vector<std::string> >()) { for (String define : vm["define"].as<std::vector<std::string>>()) {
String key, value; String key, value;
size_t pos = define.FindFirstOf('='); size_t pos = define.FindFirstOf('=');
if (pos != String::NPos) { if (pos != String::NPos) {
@ -460,7 +460,7 @@ static int Main()
ConfigCompiler::AddIncludeSearchDir(Configuration::IncludeConfDir); ConfigCompiler::AddIncludeSearchDir(Configuration::IncludeConfDir);
if (!autocomplete && vm.count("include")) { if (!autocomplete && vm.count("include")) {
for (const String& includePath : vm["include"].as<std::vector<std::string> >()) { for (String includePath : vm["include"].as<std::vector<std::string>>()) {
ConfigCompiler::AddIncludeSearchDir(includePath); ConfigCompiler::AddIncludeSearchDir(includePath);
} }
} }

View File

@ -124,7 +124,7 @@ bool ScriptUtils::Regex(const std::vector<Value>& args)
if (texts->GetLength() == 0) if (texts->GetLength() == 0)
return false; return false;
for (const String& text : texts) { for (String text : texts) {
bool res = false; bool res = false;
try { try {
boost::smatch what; boost::smatch what;
@ -177,7 +177,7 @@ bool ScriptUtils::Match(const std::vector<Value>& args)
if (texts->GetLength() == 0) if (texts->GetLength() == 0)
return false; return false;
for (const String& text : texts) { for (String text : texts) {
bool res = Utility::Match(pattern, text); bool res = Utility::Match(pattern, text);
if (mode == MatchAny && res) if (mode == MatchAny && res)
@ -223,7 +223,7 @@ bool ScriptUtils::CidrMatch(const std::vector<Value>& args)
if (ips->GetLength() == 0) if (ips->GetLength() == 0)
return false; return false;
for (const String& ip : ips) { for (String ip : ips) {
bool res = Utility::CidrMatch(pattern, ip); bool res = Utility::CidrMatch(pattern, ip);
if (mode == MatchAny && res) if (mode == MatchAny && res)

View File

@ -121,7 +121,7 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
ConfigCompilerContext::GetInstance()->OpenObjectsFile(objectsFile); ConfigCompilerContext::GetInstance()->OpenObjectsFile(objectsFile);
if (!configs.empty()) { if (!configs.empty()) {
for (const String& configPath : configs) { for (String configPath : configs) {
try { try {
std::unique_ptr<Expression> expression = ConfigCompiler::CompileFile(configPath, String(), "_etc"); std::unique_ptr<Expression> expression = ConfigCompiler::CompileFile(configPath, String(), "_etc");
success = ExecuteExpression(&*expression); success = ExecuteExpression(&*expression);

View File

@ -47,7 +47,7 @@ int NodeUtility::GenerateNodeIcingaConfig(const String& endpointName, const Stri
Array::Ptr myParentZoneMembers = new Array(); Array::Ptr myParentZoneMembers = new Array();
for (const String& endpoint : endpoints) { for (String endpoint : endpoints) {
/* extract all --endpoint arguments and store host,port info */ /* extract all --endpoint arguments and store host,port info */
std::vector<String> tokens = endpoint.Split(","); std::vector<String> tokens = endpoint.Split(",");
@ -170,7 +170,7 @@ bool NodeUtility::WriteNodeConfigObjects(const String& filename, const Array::Pt
fp << " */\n\n"; fp << " */\n\n";
ObjectLock olock(objects); ObjectLock olock(objects);
for (const Dictionary::Ptr& object : objects) { for (Dictionary::Ptr object : objects) {
SerializeObject(fp, object); SerializeObject(fp, object);
} }

View File

@ -242,7 +242,7 @@ wizard_endpoint_loop_start:
/* Extract parent node information. */ /* Extract parent node information. */
String parentHost, parentPort; String parentHost, parentPort;
for (const String& endpoint : endpoints) { for (String endpoint : endpoints) {
std::vector<String> tokens = endpoint.Split(","); std::vector<String> tokens = endpoint.Split(",");
if (tokens.size() > 1) if (tokens.size() > 1)

View File

@ -161,7 +161,7 @@ void HostDbObject::OnConfigUpdateHeavy()
if (groups) { if (groups) {
ObjectLock olock(groups); ObjectLock olock(groups);
for (const String& groupName : groups) { for (String groupName : groups) {
HostGroup::Ptr group = HostGroup::GetByName(groupName); HostGroup::Ptr group = HostGroup::GetByName(groupName);
DbQuery query2; DbQuery query2;

View File

@ -159,7 +159,7 @@ void ServiceDbObject::OnConfigUpdateHeavy()
if (groups) { if (groups) {
ObjectLock olock(groups); ObjectLock olock(groups);
for (const String& groupName : groups) { for (String groupName : groups) {
ServiceGroup::Ptr group = ServiceGroup::GetByName(groupName); ServiceGroup::Ptr group = ServiceGroup::GetByName(groupName);
DbQuery query2; DbQuery query2;

View File

@ -79,7 +79,7 @@ void UserDbObject::OnConfigUpdateHeavy()
if (groups) { if (groups) {
ObjectLock olock(groups); ObjectLock olock(groups);
for (const String& groupName : groups) { for (String groupName : groups) {
UserGroup::Ptr group = UserGroup::GetByName(groupName); UserGroup::Ptr group = UserGroup::GetByName(groupName);
DbQuery query2; DbQuery query2;

View File

@ -1358,7 +1358,7 @@ Value ClusterEvents::NotificationSentToAllUsersAPIHandler(const MessageOrigin::P
{ {
ObjectLock olock(ausers); ObjectLock olock(ausers);
for (const String& auser : ausers) { for (String auser : ausers) {
User::Ptr user = User::GetByName(auser); User::Ptr user = User::GetByName(auser);
if (!user) if (!user)

View File

@ -169,7 +169,7 @@ String Comment::AddComment(const Checkable::Ptr& checkable, CommentType entryTyp
if (!ConfigObjectUtility::CreateObject(Comment::TypeInstance, fullName, config, errors, nullptr)) { if (!ConfigObjectUtility::CreateObject(Comment::TypeInstance, fullName, config, errors, nullptr)) {
ObjectLock olock(errors); ObjectLock olock(errors);
for (const String& error : errors) { for (String error : errors) {
Log(LogCritical, "Comment", error); Log(LogCritical, "Comment", error);
} }
@ -206,7 +206,7 @@ void Comment::RemoveComment(const String& id, bool removedManually, const String
if (!ConfigObjectUtility::DeleteObject(comment, false, errors, nullptr)) { if (!ConfigObjectUtility::DeleteObject(comment, false, errors, nullptr)) {
ObjectLock olock(errors); ObjectLock olock(errors);
for (const String& error : errors) { for (String error : errors) {
Log(LogCritical, "Comment", error); Log(LogCritical, "Comment", error);
} }

View File

@ -25,7 +25,7 @@ String CompatUtility::GetCommandLine(const Command::Ptr& command)
Array::Ptr args = commandLine; Array::Ptr args = commandLine;
ObjectLock olock(args); ObjectLock olock(args);
for (const String& arg : args) { for (String arg : args) {
// This is obviously incorrect for non-trivial cases. // This is obviously incorrect for non-trivial cases.
result += " \"" + EscapeString(arg) + "\""; result += " \"" + EscapeString(arg) + "\"";
} }

View File

@ -330,7 +330,7 @@ Downtime::Ptr Downtime::AddDowntime(const Checkable::Ptr& checkable, const Strin
if (!ConfigObjectUtility::CreateObject(Downtime::TypeInstance, fullName, config, errors, nullptr)) { if (!ConfigObjectUtility::CreateObject(Downtime::TypeInstance, fullName, config, errors, nullptr)) {
ObjectLock olock(errors); ObjectLock olock(errors);
for (const String& error : errors) { for (String error : errors) {
Log(LogCritical, "Downtime", error); Log(LogCritical, "Downtime", error);
} }
@ -388,7 +388,7 @@ void Downtime::RemoveDowntime(const String& id, bool includeChildren, DowntimeRe
if (!ConfigObjectUtility::DeleteObject(downtime, false, errors, nullptr)) { if (!ConfigObjectUtility::DeleteObject(downtime, false, errors, nullptr)) {
ObjectLock olock(errors); ObjectLock olock(errors);
for (const String& error : errors) { for (String error : errors) {
Log(LogCritical, "Downtime", error); Log(LogCritical, "Downtime", error);
} }
@ -505,7 +505,7 @@ void Downtime::TriggerDowntime(double triggerTime)
{ {
ObjectLock olock(triggers); ObjectLock olock(triggers);
for (const String& triggerName : triggers) { for (String triggerName : triggers) {
Downtime::Ptr downtime = Downtime::GetByName(triggerName); Downtime::Ptr downtime = Downtime::GetByName(triggerName);
if (!downtime) if (!downtime)

View File

@ -38,7 +38,7 @@ void Host::OnAllConfigLoaded()
ObjectLock olock(groups); ObjectLock olock(groups);
for (const String& name : groups) { for (String name : groups) {
HostGroup::Ptr hg = HostGroup::GetByName(name); HostGroup::Ptr hg = HostGroup::GetByName(name);
if (hg) if (hg)
@ -71,7 +71,7 @@ void Host::Stop(bool runtimeRemoved)
if (groups) { if (groups) {
ObjectLock olock(groups); ObjectLock olock(groups);
for (const String& name : groups) { for (String name : groups) {
HostGroup::Ptr hg = HostGroup::GetByName(name); HostGroup::Ptr hg = HostGroup::GetByName(name);
if (hg) if (hg)

View File

@ -91,7 +91,7 @@ bool HostGroup::ResolveGroupMembership(const Host::Ptr& host, bool add, int rsta
if (groups && groups->GetLength() > 0) { if (groups && groups->GetLength() > 0) {
ObjectLock olock(groups); ObjectLock olock(groups);
for (const String& name : groups) { for (String name : groups) {
HostGroup::Ptr group = HostGroup::GetByName(name); HostGroup::Ptr group = HostGroup::GetByName(name);
if (group && !group->ResolveGroupMembership(host, add, rstack + 1)) if (group && !group->ResolveGroupMembership(host, add, rstack + 1))

View File

@ -497,7 +497,7 @@ Dictionary::Ptr LegacyTimePeriod::FindRunningSegment(const String& daydef, const
double bestEnd = 0.0; double bestEnd = 0.0;
ObjectLock olock(segments); ObjectLock olock(segments);
for (const Dictionary::Ptr& segment : segments) { for (Dictionary::Ptr segment : segments) {
double begin = segment->Get("begin"); double begin = segment->Get("begin");
double end = segment->Get("end"); double end = segment->Get("end");
@ -555,7 +555,7 @@ Dictionary::Ptr LegacyTimePeriod::FindNextSegment(const String& daydef, const St
double bestBegin; double bestBegin;
ObjectLock olock(segments); ObjectLock olock(segments);
for (const Dictionary::Ptr& segment : segments) { for (Dictionary::Ptr segment : segments) {
double begin = segment->Get("begin"); double begin = segment->Get("begin");
if (begin < tsref) if (begin < tsref)

View File

@ -173,7 +173,7 @@ std::set<User::Ptr> Notification::GetUsers() const
if (users) { if (users) {
ObjectLock olock(users); ObjectLock olock(users);
for (const String& name : users) { for (String name : users) {
User::Ptr user = User::GetByName(name); User::Ptr user = User::GetByName(name);
if (!user) if (!user)
@ -195,7 +195,7 @@ std::set<UserGroup::Ptr> Notification::GetUserGroups() const
if (groups) { if (groups) {
ObjectLock olock(groups); ObjectLock olock(groups);
for (const String& name : groups) { for (String name : groups) {
UserGroup::Ptr ug = UserGroup::GetByName(name); UserGroup::Ptr ug = UserGroup::GetByName(name);
if (!ug) if (!ug)

View File

@ -65,7 +65,7 @@ void Service::OnAllConfigLoaded()
ObjectLock olock(groups); ObjectLock olock(groups);
for (const String& name : groups) { for (String name : groups) {
ServiceGroup::Ptr sg = ServiceGroup::GetByName(name); ServiceGroup::Ptr sg = ServiceGroup::GetByName(name);
if (sg) if (sg)

View File

@ -94,7 +94,7 @@ bool ServiceGroup::ResolveGroupMembership(const Service::Ptr& service, bool add,
if (groups && groups->GetLength() > 0) { if (groups && groups->GetLength() > 0) {
ObjectLock olock(groups); ObjectLock olock(groups);
for (const String& name : groups) { for (String name : groups) {
ServiceGroup::Ptr group = ServiceGroup::GetByName(name); ServiceGroup::Ptr group = ServiceGroup::GetByName(name);
if (group && !group->ResolveGroupMembership(service, add, rstack + 1)) if (group && !group->ResolveGroupMembership(service, add, rstack + 1))

View File

@ -57,7 +57,7 @@ void TimePeriod::AddSegment(double begin, double end)
if (segments) { if (segments) {
/* Try to merge the new segment into an existing segment. */ /* Try to merge the new segment into an existing segment. */
ObjectLock dlock(segments); ObjectLock dlock(segments);
for (const Dictionary::Ptr& segment : segments) { for (Dictionary::Ptr segment : segments) {
if (segment->Get("begin") <= begin && segment->Get("end") >= end) if (segment->Get("begin") <= begin && segment->Get("end") >= end)
return; /* New segment is fully contained in this segment. */ return; /* New segment is fully contained in this segment. */
@ -122,7 +122,7 @@ void TimePeriod::RemoveSegment(double begin, double end)
/* Try to split or adjust an existing segment. */ /* Try to split or adjust an existing segment. */
ObjectLock dlock(segments); ObjectLock dlock(segments);
for (const Dictionary::Ptr& segment : segments) { for (Dictionary::Ptr segment : segments) {
/* Fully contained in the specified range? */ /* Fully contained in the specified range? */
if (segment->Get("begin") >= begin && segment->Get("end") <= end) if (segment->Get("begin") >= begin && segment->Get("end") <= end)
// Don't add the old segment, because the segment is fully contained into our range // Don't add the old segment, because the segment is fully contained into our range
@ -193,7 +193,7 @@ void TimePeriod::PurgeSegments(double end)
/* Remove old segments. */ /* Remove old segments. */
ObjectLock dlock(segments); ObjectLock dlock(segments);
for (const Dictionary::Ptr& segment : segments) { for (Dictionary::Ptr segment : segments) {
if (segment->Get("end") >= end) if (segment->Get("end") >= end)
newSegments->Add(segment); newSegments->Add(segment);
} }
@ -212,7 +212,7 @@ void TimePeriod::Merge(const TimePeriod::Ptr& timeperiod, bool include)
if (segments) { if (segments) {
ObjectLock dlock(segments); ObjectLock dlock(segments);
ObjectLock ilock(this); ObjectLock ilock(this);
for (const Dictionary::Ptr& segment : segments) { for (Dictionary::Ptr segment : segments) {
include ? AddSegment(segment) : RemoveSegment(segment); include ? AddSegment(segment) : RemoveSegment(segment);
} }
} }
@ -239,7 +239,7 @@ void TimePeriod::UpdateRegion(double begin, double end, bool clearExisting)
if (segments) { if (segments) {
ObjectLock dlock(segments); ObjectLock dlock(segments);
for (const Dictionary::Ptr& segment : segments) { for (Dictionary::Ptr segment : segments) {
AddSegment(segment); AddSegment(segment);
} }
} }
@ -252,7 +252,7 @@ void TimePeriod::UpdateRegion(double begin, double end, bool clearExisting)
if (timeranges) { if (timeranges) {
ObjectLock olock(timeranges); ObjectLock olock(timeranges);
for (const String& name : timeranges) { for (String name : timeranges) {
const TimePeriod::Ptr timeperiod = TimePeriod::GetByName(name); const TimePeriod::Ptr timeperiod = TimePeriod::GetByName(name);
if (timeperiod) if (timeperiod)
@ -265,7 +265,7 @@ void TimePeriod::UpdateRegion(double begin, double end, bool clearExisting)
if (timeranges) { if (timeranges) {
ObjectLock olock(timeranges); ObjectLock olock(timeranges);
for (const String& name : timeranges) { for (String name : timeranges) {
const TimePeriod::Ptr timeperiod = TimePeriod::GetByName(name); const TimePeriod::Ptr timeperiod = TimePeriod::GetByName(name);
if (timeperiod) if (timeperiod)
@ -290,7 +290,7 @@ bool TimePeriod::IsInside(double ts) const
if (segments) { if (segments) {
ObjectLock dlock(segments); ObjectLock dlock(segments);
for (const Dictionary::Ptr& segment : segments) { for (Dictionary::Ptr segment : segments) {
if (ts >= segment->Get("begin") && ts < segment->Get("end")) if (ts >= segment->Get("begin") && ts < segment->Get("end"))
return true; return true;
} }
@ -309,7 +309,7 @@ double TimePeriod::FindNextTransition(double begin)
if (segments) { if (segments) {
ObjectLock dlock(segments); ObjectLock dlock(segments);
for (const Dictionary::Ptr& segment : segments) { for (Dictionary::Ptr segment : segments) {
if (segment->Get("begin") > begin && (segment->Get("begin") < closestTransition || closestTransition == -1)) if (segment->Get("begin") > begin && (segment->Get("begin") < closestTransition || closestTransition == -1))
closestTransition = segment->Get("begin"); closestTransition = segment->Get("begin");
@ -360,7 +360,7 @@ void TimePeriod::Dump()
if (segments) { if (segments) {
ObjectLock dlock(segments); ObjectLock dlock(segments);
for (const Dictionary::Ptr& segment : segments) { for (Dictionary::Ptr segment : segments) {
Log(LogDebug, "TimePeriod") Log(LogDebug, "TimePeriod")
<< "Segment: " << Utility::FormatDateTime("%c", segment->Get("begin")) << " <-> " << "Segment: " << Utility::FormatDateTime("%c", segment->Get("begin")) << " <-> "
<< Utility::FormatDateTime("%c", segment->Get("end")); << Utility::FormatDateTime("%c", segment->Get("end"));

View File

@ -33,7 +33,7 @@ void User::OnAllConfigLoaded()
ObjectLock olock(groups); ObjectLock olock(groups);
for (const String& name : groups) { for (String name : groups) {
UserGroup::Ptr ug = UserGroup::GetByName(name); UserGroup::Ptr ug = UserGroup::GetByName(name);
if (ug) if (ug)
@ -51,7 +51,7 @@ void User::Stop(bool runtimeRemoved)
if (groups) { if (groups) {
ObjectLock olock(groups); ObjectLock olock(groups);
for (const String& name : groups) { for (String name : groups) {
UserGroup::Ptr ug = UserGroup::GetByName(name); UserGroup::Ptr ug = UserGroup::GetByName(name);
if (ug) if (ug)

View File

@ -110,7 +110,7 @@ bool UserGroup::ResolveGroupMembership(const User::Ptr& user, bool add, int rsta
if (groups && groups->GetLength() > 0) { if (groups && groups->GetLength() > 0) {
ObjectLock olock(groups); ObjectLock olock(groups);
for (const String& name : groups) { for (String name : groups) {
UserGroup::Ptr group = UserGroup::GetByName(name); UserGroup::Ptr group = UserGroup::GetByName(name);
if (group && !group->ResolveGroupMembership(user, add, rstack + 1)) if (group && !group->ResolveGroupMembership(user, add, rstack + 1))

View File

@ -27,7 +27,7 @@ bool AttributeFilter::Apply(const Table::Ptr& table, const Value& row)
bool negate = (m_Operator == "<"); bool negate = (m_Operator == "<");
ObjectLock olock(array); ObjectLock olock(array);
for (const String& item : array) { for (String item : array) {
if (item == m_Operand) if (item == m_Operand)
return !negate; /* Item found in list. */ return !negate; /* Item found in list. */
} }

View File

@ -252,7 +252,7 @@ void StateHistTable::FetchRows(const AddRowFunction& addRowFn)
Checkable::Ptr checkable; Checkable::Ptr checkable;
for (const auto& kv : m_CheckablesCache) { for (const auto& kv : m_CheckablesCache) {
for (const Dictionary::Ptr& state_hist_bag : kv.second) { for (Dictionary::Ptr state_hist_bag : kv.second) {
/* pass a dictionary from state history array */ /* pass a dictionary from state history array */
if (!addRowFn(state_hist_bag, LivestatusGroupByNone, Empty)) if (!addRowFn(state_hist_bag, LivestatusGroupByNone, Empty))
return; return;

View File

@ -88,7 +88,7 @@ bool ActionsHandler::HandleRequest(
if (params) if (params)
verbose = HttpUtility::GetLastParameter(params, "verbose"); verbose = HttpUtility::GetLastParameter(params, "verbose");
for (const ConfigObject::Ptr& obj : objs) { for (ConfigObject::Ptr obj : objs) {
try { try {
results.emplace_back(action->Invoke(obj, params)); results.emplace_back(action->Invoke(obj, params));
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
@ -108,7 +108,7 @@ bool ActionsHandler::HandleRequest(
int statusCode = 500; int statusCode = 500;
std::set<int> okStatusCodes, nonOkStatusCodes; std::set<int> okStatusCodes, nonOkStatusCodes;
for (const Dictionary::Ptr& res : results) { for (Dictionary::Ptr res : results) {
if (!res->Contains("code")) { if (!res->Contains("code")) {
continue; continue;
} }

View File

@ -78,7 +78,7 @@ bool DeleteObjectHandler::HandleRequest(
bool success = true; bool success = true;
for (const ConfigObject::Ptr& obj : objs) { for (ConfigObject::Ptr obj : objs) {
int code; int code;
String status; String status;
Array::Ptr errors = new Array(); Array::Ptr errors = new Array();

View File

@ -73,7 +73,7 @@ bool EventsHandler::HandleRequest(
{ {
ObjectLock olock(types); ObjectLock olock(types);
for (const String& type : types) { for (String type : types) {
FilterUtility::CheckPermission(user, "events/" + type); FilterUtility::CheckPermission(user, "events/" + type);
} }
} }
@ -89,7 +89,7 @@ bool EventsHandler::HandleRequest(
{ {
ObjectLock olock(types); ObjectLock olock(types);
for (const String& type : types) { for (String type : types) {
auto typeId (l_EventTypes.find(type)); auto typeId (l_EventTypes.find(type));
if (typeId != l_EventTypes.end()) { if (typeId != l_EventTypes.end()) {

View File

@ -241,7 +241,7 @@ std::vector<Value> FilterUtility::GetFilterTargets(const QueryDescription& qd, c
Array::Ptr names = query->Get(attr); Array::Ptr names = query->Get(attr);
if (names) { if (names) {
ObjectLock olock(names); ObjectLock olock(names);
for (const String& name : names) { for (String name : names) {
Object::Ptr target = provider->GetTargetByName(type, name); Object::Ptr target = provider->GetTargetByName(type, name);
if (!FilterUtility::EvaluateFilter(permissionFrame, permissionFilter.get(), target, variableName)) if (!FilterUtility::EvaluateFilter(permissionFrame, permissionFilter.get(), target, variableName))

View File

@ -66,7 +66,7 @@ void HttpHandler::ProcessRequest(
if (current_handlers) { if (current_handlers) {
ObjectLock olock(current_handlers); ObjectLock olock(current_handlers);
for (const HttpHandler::Ptr& current_handler : current_handlers) { for (HttpHandler::Ptr current_handler : current_handlers) {
handlers.push_back(current_handler); handlers.push_back(current_handler);
} }
} }

View File

@ -104,7 +104,7 @@ bool ModifyObjectHandler::HandleRequest(
ArrayData results; ArrayData results;
for (const ConfigObject::Ptr& obj : objs) { for (ConfigObject::Ptr obj : objs) {
Dictionary::Ptr result1 = new Dictionary(); Dictionary::Ptr result1 = new Dictionary();
result1->Set("type", type->GetName()); result1->Set("type", type->GetName());

View File

@ -23,7 +23,7 @@ Dictionary::Ptr ObjectQueryHandler::SerializeObjectAttrs(const Object::Ptr& obje
if (isJoin && attrs) { if (isJoin && attrs) {
ObjectLock olock(attrs); ObjectLock olock(attrs);
for (const String& attr : attrs) { for (String attr : attrs) {
if (attr == attrPrefix) { if (attr == attrPrefix) {
allAttrs = true; allAttrs = true;
break; break;
@ -40,7 +40,7 @@ Dictionary::Ptr ObjectQueryHandler::SerializeObjectAttrs(const Object::Ptr& obje
} }
} else if (attrs) { } else if (attrs) {
ObjectLock olock(attrs); ObjectLock olock(attrs);
for (const String& attr : attrs) { for (String attr : attrs) {
String userAttr; String userAttr;
if (isJoin) { if (isJoin) {
@ -173,7 +173,7 @@ bool ObjectQueryHandler::HandleRequest(
if (ujoins) { if (ujoins) {
ObjectLock olock(ujoins); ObjectLock olock(ujoins);
for (const String& ujoin : ujoins) { for (String ujoin : ujoins) {
userJoinAttrs.insert(ujoin.SubStr(0, ujoin.FindFirstOf("."))); userJoinAttrs.insert(ujoin.SubStr(0, ujoin.FindFirstOf(".")));
} }
} }
@ -193,7 +193,7 @@ bool ObjectQueryHandler::HandleRequest(
std::unordered_map<Type*, std::pair<bool, std::unique_ptr<Expression>>> typePermissions; std::unordered_map<Type*, std::pair<bool, std::unique_ptr<Expression>>> typePermissions;
std::unordered_map<Object*, bool> objectAccessAllowed; std::unordered_map<Object*, bool> objectAccessAllowed;
for (const ConfigObject::Ptr& obj : objs) { for (ConfigObject::Ptr obj : objs) {
DictionaryData result1{ DictionaryData result1{
{ "name", obj->GetName() }, { "name", obj->GetName() },
{ "type", obj->GetReflectionType()->GetName() } { "type", obj->GetReflectionType()->GetName() }
@ -203,7 +203,7 @@ bool ObjectQueryHandler::HandleRequest(
if (umetas) { if (umetas) {
ObjectLock olock(umetas); ObjectLock olock(umetas);
for (const String& meta : umetas) { for (String meta : umetas) {
if (meta == "used_by") { if (meta == "used_by") {
Array::Ptr used_by = new Array(); Array::Ptr used_by = new Array();
metaAttrs.emplace_back("used_by", used_by); metaAttrs.emplace_back("used_by", used_by);

View File

@ -91,7 +91,7 @@ bool TypeQueryHandler::HandleRequest(
ArrayData results; ArrayData results;
for (const Type::Ptr& obj : objs) { for (Type::Ptr obj : objs) {
Dictionary::Ptr result1 = new Dictionary(); Dictionary::Ptr result1 = new Dictionary();
results.push_back(result1); results.push_back(result1);

View File

@ -290,7 +290,7 @@ bool Url::ParsePath(const String& path)
boost::char_separator<char> sep("/"); boost::char_separator<char> sep("/");
boost::tokenizer<boost::char_separator<char> > tokens(pathStr, sep); boost::tokenizer<boost::char_separator<char> > tokens(pathStr, sep);
for (const String& token : tokens) { for (String token : tokens) {
if (token.IsEmpty()) if (token.IsEmpty())
continue; continue;
@ -310,7 +310,7 @@ bool Url::ParseQuery(const String& query)
boost::char_separator<char> sep("&"); boost::char_separator<char> sep("&");
boost::tokenizer<boost::char_separator<char> > tokens(queryStr, sep); boost::tokenizer<boost::char_separator<char> > tokens(queryStr, sep);
for (const String& token : tokens) { for (String token : tokens) {
size_t pHelper = token.Find("="); size_t pHelper = token.Find("=");
if (pHelper == 0) if (pHelper == 0)

View File

@ -98,7 +98,7 @@ bool VariableQueryHandler::HandleRequest(
ArrayData results; ArrayData results;
for (const Dictionary::Ptr& var : objs) { for (Dictionary::Ptr var : objs) {
if (var->Get("name") == "TicketSalt") if (var->Get("name") == "TicketSalt")
continue; continue;

View File

@ -27,7 +27,7 @@ void Zone::OnAllConfigLoaded()
if (endpoints) { if (endpoints) {
ObjectLock olock(endpoints); ObjectLock olock(endpoints);
for (const String& endpoint : endpoints) { for (String endpoint : endpoints) {
Endpoint::Ptr ep = Endpoint::GetByName(endpoint); Endpoint::Ptr ep = Endpoint::GetByName(endpoint);
if (ep) if (ep)
@ -60,7 +60,7 @@ std::set<Endpoint::Ptr> Zone::GetEndpoints() const
if (endpoints) { if (endpoints) {
ObjectLock olock(endpoints); ObjectLock olock(endpoints);
for (const String& name : endpoints) { for (String name : endpoints) {
Endpoint::Ptr endpoint = Endpoint::GetByName(name); Endpoint::Ptr endpoint = Endpoint::GetByName(name);
if (!endpoint) if (!endpoint)

View File

@ -119,7 +119,7 @@ static int FormatOutput(const Dictionary::Ptr& result)
ObjectLock olock(perfs); ObjectLock olock(perfs);
for (const Dictionary::Ptr& perf : perfs) { for (Dictionary::Ptr perf : perfs) {
ssout << "'" << perf->Get("alias") << "'="; ssout << "'" << perf->Get("alias") << "'=";
Dictionary::Ptr values = perf->Get("float_value"); Dictionary::Ptr values = perf->Get("float_value");
@ -483,7 +483,7 @@ int main(int argc, char **argv)
endpoint += '/'; endpoint += '/';
else { else {
endpoint += '?'; endpoint += '?';
for (const String& argument : vm["arguments"].as<std::vector<std::string>>()) { for (String argument : vm["arguments"].as<std::vector<std::string>>()) {
String::SizeType pos = argument.FindFirstOf("="); String::SizeType pos = argument.FindFirstOf("=");
if (pos == String::NPos) if (pos == String::NPos)
endpoint += Utility::EscapeString(argument, ACQUERY_ENCODE, false); endpoint += Utility::EscapeString(argument, ACQUERY_ENCODE, false);

View File

@ -574,7 +574,7 @@ BOOST_AUTO_TEST_CASE(dst)
std::vector<TestData> tests; std::vector<TestData> tests;
// 2021-03-14: 01:59:59 PST (UTC-8) -> 03:00:00 PDT (UTC-7) // 2021-03-14: 01:59:59 PST (UTC-8) -> 03:00:00 PDT (UTC-7)
for (const std::string& day : {"2021-03-14", "sunday", "sunday 2", "sunday -3"}) { for (std::string day : {"2021-03-14", "sunday", "sunday 2", "sunday -3"}) {
// range before DST change // range before DST change
tests.push_back(TestData{ tests.push_back(TestData{
day, "00:30-01:30", day, "00:30-01:30",
@ -648,7 +648,7 @@ BOOST_AUTO_TEST_CASE(dst)
} }
// 2021-11-07: 01:59:59 PDT (UTC-7) -> 01:00:00 PST (UTC-8) // 2021-11-07: 01:59:59 PDT (UTC-7) -> 01:00:00 PST (UTC-8)
for (const std::string& day : {"2021-11-07", "sunday", "sunday 1", "sunday -4"}) { for (std::string day : {"2021-11-07", "sunday", "sunday 1", "sunday -4"}) {
// range before DST change // range before DST change
tests.push_back(TestData{ tests.push_back(TestData{
day, "00:15-00:45", day, "00:15-00:45",