From 50106057bf5eefc95707faea96fc5bb3a1cfc657 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Thu, 21 Dec 2017 15:45:11 +0100 Subject: [PATCH] Remove obsolete locks in Livestatus; apply style guide to DB IDO --- lib/db_ido/hostdbobject.cpp | 5 ++--- lib/livestatus/commandstable.cpp | 21 +++------------------ lib/livestatus/contactstable.cpp | 28 ++++------------------------ lib/livestatus/hoststable.cpp | 28 ++++------------------------ lib/livestatus/servicestable.cpp | 28 ++++------------------------ 5 files changed, 17 insertions(+), 93 deletions(-) diff --git a/lib/db_ido/hostdbobject.cpp b/lib/db_ido/hostdbobject.cpp index 0063a3d95..e339b5e70 100644 --- a/lib/db_ido/hostdbobject.cpp +++ b/lib/db_ido/hostdbobject.cpp @@ -51,11 +51,10 @@ Dictionary::Ptr HostDbObject::GetConfigFields() const /* Compatibility fallback. */ String displayName = host->GetDisplayName(); - if (!displayName.IsEmpty()) { + if (!displayName.IsEmpty()) fields->Set("alias", displayName); - } else { + else fields->Set("alias", host->GetName()); - } fields->Set("display_name", displayName); fields->Set("address", host->GetAddress()); diff --git a/lib/livestatus/commandstable.cpp b/lib/livestatus/commandstable.cpp index 8aa5f0998..ae5145fc1 100644 --- a/lib/livestatus/commandstable.cpp +++ b/lib/livestatus/commandstable.cpp @@ -99,12 +99,7 @@ Value CommandsTable::CustomVariableNamesAccessor(const Value& row) if (!command) return Empty; - Dictionary::Ptr vars; - - { - ObjectLock olock(command); - vars = command->GetVars(); - } + Dictionary::Ptr vars = command->GetVars(); Array::Ptr cv = new Array(); @@ -128,12 +123,7 @@ Value CommandsTable::CustomVariableValuesAccessor(const Value& row) if (!command) return Empty; - Dictionary::Ptr vars; - - { - ObjectLock olock(command); - vars = command->GetVars(); - } + Dictionary::Ptr vars = command->GetVars(); Array::Ptr cv = new Array(); @@ -157,12 +147,7 @@ Value CommandsTable::CustomVariablesAccessor(const Value& row) if (!command) return Empty; - Dictionary::Ptr vars; - - { - ObjectLock olock(command); - vars = command->GetVars(); - } + Dictionary::Ptr vars = command->GetVars(); Array::Ptr cv = new Array(); diff --git a/lib/livestatus/contactstable.cpp b/lib/livestatus/contactstable.cpp index 54a613adc..aeca4b04d 100644 --- a/lib/livestatus/contactstable.cpp +++ b/lib/livestatus/contactstable.cpp @@ -203,12 +203,7 @@ Value ContactsTable::CustomVariableNamesAccessor(const Value& row) if (!user) return Empty; - Dictionary::Ptr vars; - - { - ObjectLock olock(user); - vars = user->GetVars(); - } + Dictionary::Ptr vars = user->GetVars(); Array::Ptr cv = new Array(); @@ -230,12 +225,7 @@ Value ContactsTable::CustomVariableValuesAccessor(const Value& row) if (!user) return Empty; - Dictionary::Ptr vars; - - { - ObjectLock olock(user); - vars = user->GetVars(); - } + Dictionary::Ptr vars = user->GetVars(); Array::Ptr cv = new Array(); @@ -260,12 +250,7 @@ Value ContactsTable::CustomVariablesAccessor(const Value& row) if (!user) return Empty; - Dictionary::Ptr vars; - - { - ObjectLock olock(user); - vars = user->GetVars(); - } + Dictionary::Ptr vars = user->GetVars(); Array::Ptr cv = new Array(); @@ -295,12 +280,7 @@ Value ContactsTable::CVIsJsonAccessor(const Value& row) if (!user) return Empty; - Dictionary::Ptr vars; - - { - ObjectLock olock(user); - vars = user->GetVars(); - } + Dictionary::Ptr vars = user->GetVars(); if (!vars) return Empty; diff --git a/lib/livestatus/hoststable.cpp b/lib/livestatus/hoststable.cpp index b4ba38fe8..795f31b8e 100644 --- a/lib/livestatus/hoststable.cpp +++ b/lib/livestatus/hoststable.cpp @@ -1036,12 +1036,7 @@ Value HostsTable::CustomVariableNamesAccessor(const Value& row) if (!host) return Empty; - Dictionary::Ptr vars; - - { - ObjectLock olock(host); - vars = host->GetVars(); - } + Dictionary::Ptr vars = host->GetVars(); Array::Ptr cv = new Array(); @@ -1063,12 +1058,7 @@ Value HostsTable::CustomVariableValuesAccessor(const Value& row) if (!host) return Empty; - Dictionary::Ptr vars; - - { - ObjectLock olock(host); - vars = host->GetVars(); - } + Dictionary::Ptr vars = host->GetVars(); Array::Ptr cv = new Array(); @@ -1093,12 +1083,7 @@ Value HostsTable::CustomVariablesAccessor(const Value& row) if (!host) return Empty; - Dictionary::Ptr vars; - - { - ObjectLock olock(host); - vars = host->GetVars(); - } + Dictionary::Ptr vars = host->GetVars(); Array::Ptr cv = new Array(); @@ -1128,12 +1113,7 @@ Value HostsTable::CVIsJsonAccessor(const Value& row) if (!host) return Empty; - Dictionary::Ptr vars; - - { - ObjectLock olock(host); - vars = host->GetVars(); - } + Dictionary::Ptr vars = host->GetVars(); if (!vars) return Empty; diff --git a/lib/livestatus/servicestable.cpp b/lib/livestatus/servicestable.cpp index 2dcd9db9a..3abffb423 100644 --- a/lib/livestatus/servicestable.cpp +++ b/lib/livestatus/servicestable.cpp @@ -1058,12 +1058,7 @@ Value ServicesTable::CustomVariableNamesAccessor(const Value& row) if (!service) return Empty; - Dictionary::Ptr vars; - - { - ObjectLock olock(service); - vars = service->GetVars(); - } + Dictionary::Ptr vars = service->GetVars(); Array::Ptr cv = new Array(); @@ -1085,12 +1080,7 @@ Value ServicesTable::CustomVariableValuesAccessor(const Value& row) if (!service) return Empty; - Dictionary::Ptr vars; - - { - ObjectLock olock(service); - vars = service->GetVars(); - } + Dictionary::Ptr vars = service->GetVars(); Array::Ptr cv = new Array(); @@ -1115,12 +1105,7 @@ Value ServicesTable::CustomVariablesAccessor(const Value& row) if (!service) return Empty; - Dictionary::Ptr vars; - - { - ObjectLock olock(service); - vars = service->GetVars(); - } + Dictionary::Ptr vars = service->GetVars(); Array::Ptr cv = new Array(); @@ -1150,12 +1135,7 @@ Value ServicesTable::CVIsJsonAccessor(const Value& row) if (!service) return Empty; - Dictionary::Ptr vars; - - { - ObjectLock olock(service); - vars = service->GetVars(); - } + Dictionary::Ptr vars = service->GetVars(); if (!vars) return Empty;