From e2416b5b54f0e0f243ed548d5dc167c61865e3f7 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 7 Mar 2013 16:00:10 +0100 Subject: [PATCH] Check return values of SymGetLineFromAddr64 and SymFromAddr. --- components/compat/compatcomponent.cpp | 2 +- components/delegation/delegationcomponent.cpp | 2 +- icinga-app/icinga.cpp | 2 +- icinga2.sln | 3 ++ lib/base/application.cpp | 12 +++---- lib/base/asynctask.h | 16 ++++----- lib/base/attribute.cpp | 2 +- lib/base/dictionary.cpp | 26 +++++++------- lib/base/dynamicobject.cpp | 36 +++++++++---------- lib/base/dynamictype.cpp | 2 +- lib/base/fifo.cpp | 4 +-- lib/base/object.h | 2 +- lib/base/objectlock.cpp | 4 +-- lib/base/process-unix.cpp | 6 ++-- lib/base/socket.cpp | 4 +-- lib/base/stacktrace.cpp | 17 +++++++-- lib/base/stream.cpp | 4 +-- lib/base/sysloglogger.cpp | 2 +- lib/base/timer.cpp | 14 ++++---- lib/base/tlsstream.cpp | 2 +- lib/base/utility.h | 6 ++++ lib/config/config_parser.cc | 2 +- lib/config/config_parser.yy | 2 +- lib/config/configcompilercontext.cpp | 4 +-- lib/config/configitem.cpp | 8 ++--- lib/config/typerule.cpp | 2 +- lib/icinga/host.cpp | 16 ++++----- lib/icinga/hostgroup.cpp | 2 +- lib/icinga/icingaapplication.cpp | 2 +- lib/icinga/macroprocessor.cpp | 2 +- lib/icinga/notification.cpp | 8 ++--- lib/icinga/service-check.cpp | 6 ++-- lib/icinga/service.cpp | 10 +++--- lib/icinga/servicegroup.cpp | 2 +- lib/icinga/user.cpp | 2 +- lib/icinga/usergroup.cpp | 2 +- lib/remoting/endpoint.cpp | 2 +- 37 files changed, 130 insertions(+), 110 deletions(-) diff --git a/components/compat/compatcomponent.cpp b/components/compat/compatcomponent.cpp index 61e0ded39..139dbfae8 100644 --- a/components/compat/compatcomponent.cpp +++ b/components/compat/compatcomponent.cpp @@ -328,7 +328,7 @@ void CompatComponent::DumpHostObject(ostream& fp, const Host::Ptr& host) void CompatComponent::DumpServiceStatusAttrs(ostream& fp, const Service::Ptr& service, CompatObjectType type) { - assert(service->OwnsLock()); + ASSERT(service->OwnsLock()); String output; String perfdata; diff --git a/components/delegation/delegationcomponent.cpp b/components/delegation/delegationcomponent.cpp index eb37f7474..1b5fd1792 100644 --- a/components/delegation/delegationcomponent.cpp +++ b/components/delegation/delegationcomponent.cpp @@ -195,7 +195,7 @@ void DelegationComponent::DelegationTimerHandler(void) continue; } - assert(!service->GetCurrentChecker().IsEmpty()); + ASSERT(!service->GetCurrentChecker().IsEmpty()); } Endpoint::Ptr endpoint; diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index 3445c762e..d5cd5abb4 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -97,7 +97,7 @@ static void ReloadConfigTimerHandler(void) static void SigHupHandler(int signum) { - assert(signum == SIGHUP); + ASSERT(signum == SIGHUP); g_ReloadConfig = true; } diff --git a/icinga2.sln b/icinga2.sln index b62e3419b..6bc2e55d8 100644 --- a/icinga2.sln +++ b/icinga2.sln @@ -77,6 +77,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "remoting", "lib\remoting\re EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", "{5163C576-6AA1-4769-8396-9639C45BE124}" + ProjectSection(ProjectDependencies) = postProject + {BE412865-FEBA-4259-AD41-58950D1F5432} = {BE412865-FEBA-4259-AD41-58950D1F5432} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/lib/base/application.cpp b/lib/base/application.cpp index ecd6c33d7..e5b2f19c7 100644 --- a/lib/base/application.cpp +++ b/lib/base/application.cpp @@ -54,7 +54,7 @@ Application::Application(const Dictionary::Ptr& serializedUpdate) m_Debugging = true; #endif /* _WIN32 */ - assert(m_Instance == NULL); + ASSERT(m_Instance == NULL); m_Instance = this; } @@ -284,7 +284,7 @@ void Application::DisplayBugMessage(void) */ void Application::SigIntHandler(int signum) { - assert(signum == SIGINT); + ASSERT(signum == SIGINT); struct sigaction sa; memset(&sa, 0, sizeof(sa)); @@ -300,13 +300,13 @@ void Application::SigIntHandler(int signum) } /** - * Signal handler for SIGABRT. Helps with debugging assert()s. + * Signal handler for SIGABRT. Helps with debugging ASSERT()s. * * @param signum The signal number. */ void Application::SigAbrtHandler(int signum) { - assert(signum == SIGABRT); + ASSERT(signum == SIGABRT); #ifndef _WIN32 struct sigaction sa; @@ -435,7 +435,7 @@ int Application::Run(void) */ void Application::UpdatePidFile(const String& filename) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); if (m_PidFile != NULL) @@ -469,7 +469,7 @@ void Application::UpdatePidFile(const String& filename) */ void Application::ClosePidFile(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); if (m_PidFile != NULL) diff --git a/lib/base/asynctask.h b/lib/base/asynctask.h index ecaf6efc6..2b74d05dc 100644 --- a/lib/base/asynctask.h +++ b/lib/base/asynctask.h @@ -53,9 +53,9 @@ public: ~AsyncTask(void) { if (!m_Finished) - assert(!"Contract violation: AsyncTask was destroyed before its completion callback was invoked."); + ASSERT(!"Contract violation: AsyncTask was destroyed before its completion callback was invoked."); else if (!m_ResultRetrieved) - assert(!"Contract violation: AsyncTask was destroyed before its result was retrieved."); + ASSERT(!"Contract violation: AsyncTask was destroyed before its result was retrieved."); } @@ -67,7 +67,7 @@ public: */ void Start(const CompletionCallback& completionCallback = CompletionCallback()) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); boost::mutex::scoped_lock lock(m_Mutex); m_CompletionCallback = completionCallback; @@ -81,7 +81,7 @@ public: */ bool IsFinished(void) const { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); boost::mutex::scoped_lock lock(m_Mutex); return m_Finished; } @@ -95,7 +95,7 @@ public: */ TResult GetResult(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); boost::mutex::scoped_lock lock(m_Mutex); while (!m_Finished) @@ -122,7 +122,7 @@ public: */ void FinishException(const boost::exception_ptr& ex) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); boost::mutex::scoped_lock lock(m_Mutex); m_Exception = ex; @@ -137,7 +137,7 @@ public: */ void FinishResult(const TResult& result) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); boost::mutex::scoped_lock lock(m_Mutex); m_Result = result; @@ -161,7 +161,7 @@ private: */ void FinishInternal(void) { - assert(!m_Finished); + ASSERT(!m_Finished); m_Finished = true; m_CV.notify_all(); diff --git a/lib/base/attribute.cpp b/lib/base/attribute.cpp index b38089ea0..c1deadc27 100644 --- a/lib/base/attribute.cpp +++ b/lib/base/attribute.cpp @@ -113,7 +113,7 @@ AttributeHolder::~AttributeHolder(void) void AttributeHolder::Bind(AttributeBase *boundAttribute) { - assert(m_OwnsAttribute); + ASSERT(m_OwnsAttribute); boundAttribute->Set(m_Attribute->Get()); m_Attribute = boundAttribute; m_OwnsAttribute = false; diff --git a/lib/base/dictionary.cpp b/lib/base/dictionary.cpp index eb1b52a6b..1e8a7e241 100644 --- a/lib/base/dictionary.cpp +++ b/lib/base/dictionary.cpp @@ -70,7 +70,7 @@ Dictionary::Dictionary(void) */ Value Dictionary::Get(const char *key) const { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); map::const_iterator it; @@ -109,10 +109,10 @@ void Dictionary::Set(const String& key, const Value& value) return; } - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); - assert(!m_Sealed); + ASSERT(!m_Sealed); pair::iterator, bool> ret; ret = m_Data.insert(make_pair(key, value)); @@ -129,7 +129,7 @@ void Dictionary::Set(const String& key, const Value& value) */ String Dictionary::Add(const Value& value) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); Dictionary::Iterator it; @@ -159,7 +159,7 @@ String Dictionary::Add(const Value& value) */ Dictionary::Iterator Dictionary::Begin(void) { - assert(OwnsLock()); + ASSERT(OwnsLock()); return m_Data.begin(); } @@ -171,7 +171,7 @@ Dictionary::Iterator Dictionary::Begin(void) */ Dictionary::Iterator Dictionary::End(void) { - assert(OwnsLock()); + ASSERT(OwnsLock()); return m_Data.end(); } @@ -184,7 +184,7 @@ Dictionary::Iterator Dictionary::End(void) */ size_t Dictionary::GetLength(void) const { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); return m_Data.size(); @@ -199,7 +199,7 @@ size_t Dictionary::GetLength(void) const */ bool Dictionary::Contains(const String& key) const { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); return (m_Data.find(key) != m_Data.end()); @@ -213,7 +213,7 @@ bool Dictionary::Contains(const String& key) const */ void Dictionary::Remove(const String& key) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); Dictionary::Iterator it; @@ -232,7 +232,7 @@ void Dictionary::Remove(const String& key) */ void Dictionary::Remove(Dictionary::Iterator it) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); String key = it->first; @@ -245,7 +245,7 @@ void Dictionary::Remove(Dictionary::Iterator it) */ void Dictionary::Seal(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); m_Sealed = true; @@ -258,7 +258,7 @@ void Dictionary::Seal(void) */ bool Dictionary::IsSealed(void) const { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); return m_Sealed; @@ -272,7 +272,7 @@ bool Dictionary::IsSealed(void) const */ Dictionary::Ptr Dictionary::ShallowClone(void) const { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); Dictionary::Ptr clone = boost::make_shared(); diff --git a/lib/base/dynamicobject.cpp b/lib/base/dynamicobject.cpp index 7cf332d10..f3c0e4cce 100644 --- a/lib/base/dynamicobject.cpp +++ b/lib/base/dynamicobject.cpp @@ -121,7 +121,7 @@ void DynamicObject::ApplyUpdate(const Dictionary::Ptr& serializedUpdate, { ObjectLock olock(this); - assert(serializedUpdate->IsSealed()); + ASSERT(serializedUpdate->IsSealed()); Value configTxValue = serializedUpdate->Get("configTx"); @@ -143,7 +143,7 @@ void DynamicObject::ApplyUpdate(const Dictionary::Ptr& serializedUpdate, Dictionary::Ptr attrs = serializedUpdate->Get("attrs"); - assert(attrs->IsSealed()); + ASSERT(attrs->IsSealed()); { ObjectLock alock(attrs); @@ -155,7 +155,7 @@ void DynamicObject::ApplyUpdate(const Dictionary::Ptr& serializedUpdate, Dictionary::Ptr attr = it->second; - assert(attr->IsSealed()); + ASSERT(attr->IsSealed()); int type = attr->Get("type"); @@ -179,7 +179,7 @@ void DynamicObject::ApplyUpdate(const Dictionary::Ptr& serializedUpdate, void DynamicObject::RegisterAttribute(const String& name, AttributeType type, AttributeBase *boundAttribute) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); boost::mutex::scoped_lock lock(m_AttributeMutex); @@ -193,7 +193,7 @@ void DynamicObject::RegisterAttribute(const String& name, void DynamicObject::InternalRegisterAttribute(const String& name, AttributeType type, AttributeBase *boundAttribute) { - assert(OwnsLock()); + ASSERT(OwnsLock()); AttributeHolder attr(type, boundAttribute); @@ -213,7 +213,7 @@ void DynamicObject::InternalRegisterAttribute(const String& name, */ void DynamicObject::Set(const String& name, const Value& data) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); boost::mutex::scoped_lock lock(m_AttributeMutex); @@ -226,7 +226,7 @@ void DynamicObject::Set(const String& name, const Value& data) */ void DynamicObject::Touch(const String& name) { - assert(OwnsLock()); + ASSERT(OwnsLock()); boost::mutex::scoped_lock lock(m_AttributeMutex); @@ -250,7 +250,7 @@ void DynamicObject::Touch(const String& name) */ Value DynamicObject::Get(const String& name) const { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); boost::mutex::scoped_lock lock(m_AttributeMutex); @@ -264,7 +264,7 @@ Value DynamicObject::Get(const String& name) const void DynamicObject::InternalSetAttribute(const String& name, const Value& data, double tx, bool allowEditConfig) { - assert(OwnsLock()); + ASSERT(OwnsLock()); DynamicObject::AttributeIterator it; it = m_Attributes.find(name); @@ -304,7 +304,7 @@ void DynamicObject::InternalSetAttribute(const String& name, const Value& data, */ Value DynamicObject::InternalGetAttribute(const String& name) const { - assert(OwnsLock()); + ASSERT(OwnsLock()); DynamicObject::AttributeConstIterator it; it = m_Attributes.find(name); @@ -375,7 +375,7 @@ String DynamicObject::GetSource(void) const void DynamicObject::Register(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); /* Add this new object to the list of modified objects. * We're doing this here because we can't construct @@ -391,7 +391,7 @@ void DynamicObject::Register(void) void DynamicObject::OnRegistrationCompleted(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); Start(); @@ -400,21 +400,21 @@ void DynamicObject::OnRegistrationCompleted(void) void DynamicObject::OnUnregistrationCompleted(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); OnUnregistered(GetSelf()); } void DynamicObject::Start(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); /* Nothing to do here. */ } void DynamicObject::Unregister(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); DynamicType::Ptr dtype = GetType(); @@ -524,7 +524,7 @@ void DynamicObject::RestoreObjects(const String& filename) while (NetString::ReadStringFromStream(sfp, &message)) { Dictionary::Ptr persistentObject = Value::Deserialize(message); - assert(persistentObject->IsSealed()); + ASSERT(persistentObject->IsSealed()); String type = persistentObject->Get("type"); String name = persistentObject->Get("name"); @@ -624,7 +624,7 @@ void DynamicObject::NewTx(void) void DynamicObject::OnAttributeChanged(const String&) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); } /* @@ -638,7 +638,7 @@ DynamicObject::Ptr DynamicObject::GetObject(const String& type, const String& na const DynamicObject::AttributeMap& DynamicObject::GetAttributes(void) const { - assert(OwnsLock()); + ASSERT(OwnsLock()); return m_Attributes; } diff --git a/lib/base/dynamictype.cpp b/lib/base/dynamictype.cpp index 29f08caec..7efbb2102 100644 --- a/lib/base/dynamictype.cpp +++ b/lib/base/dynamictype.cpp @@ -152,7 +152,7 @@ void DynamicType::RegisterType(const DynamicType::Ptr& type) DynamicObject::Ptr DynamicType::CreateObject(const Dictionary::Ptr& serializedUpdate) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectFactory factory; diff --git a/lib/base/fifo.cpp b/lib/base/fifo.cpp index 33701d323..6c5bc236c 100644 --- a/lib/base/fifo.cpp +++ b/lib/base/fifo.cpp @@ -118,7 +118,7 @@ size_t FIFO::GetAvailableBytes(void) const */ size_t FIFO::Peek(void *buffer, size_t count) { - assert(IsConnected()); + ASSERT(IsConnected()); if (count > m_DataSize) count = m_DataSize; @@ -149,7 +149,7 @@ size_t FIFO::Read(void *buffer, size_t count) */ void FIFO::Write(const void *buffer, size_t count) { - assert(IsConnected()); + ASSERT(IsConnected()); ResizeBuffer(m_Offset + m_DataSize + count); memcpy(m_Buffer + m_Offset + m_DataSize, buffer, count); diff --git a/lib/base/object.h b/lib/base/object.h index 4acba266f..b9d1ad104 100644 --- a/lib/base/object.h +++ b/lib/base/object.h @@ -66,7 +66,7 @@ public: { #ifdef _DEBUG shared_ptr other = dynamic_pointer_cast(m_Object); - assert(other); + ASSERT(other); #else /* _DEBUG */ shared_ptr other = static_pointer_cast(m_Object); #endif /* _DEBUG */ diff --git a/lib/base/objectlock.cpp b/lib/base/objectlock.cpp index f5b4f7b3f..7aacc67aa 100644 --- a/lib/base/objectlock.cpp +++ b/lib/base/objectlock.cpp @@ -46,8 +46,8 @@ ObjectLock::ObjectLock(const Object *object) void ObjectLock::Lock(void) { - assert(!m_Lock.owns_lock() && m_Object != NULL); - assert(!m_Object->OwnsLock()); + ASSERT(!m_Lock.owns_lock() && m_Object != NULL); + ASSERT(!m_Object->OwnsLock()); m_Lock = Object::MutexType::scoped_lock(m_Object->m_Mutex); diff --git a/lib/base/process-unix.cpp b/lib/base/process-unix.cpp index 6ccb8d693..f390e6632 100644 --- a/lib/base/process-unix.cpp +++ b/lib/base/process-unix.cpp @@ -128,7 +128,7 @@ void Process::WorkerThreadProc(int taskFd) /* Read one byte for every task we take from the pending tasks list. */ char buffer[MaxTasksPerThread]; - assert(want <= sizeof(buffer)); + ASSERT(want <= sizeof(buffer)); int have = read(taskFd, &buffer, want); @@ -140,7 +140,7 @@ void Process::WorkerThreadProc(int taskFd) } while (have > 0) { - assert(!m_Tasks.empty()); + ASSERT(!m_Tasks.empty()); Process::Ptr task = m_Tasks.front(); m_Tasks.pop_front(); @@ -209,7 +209,7 @@ void Process::InitTask(void) { m_Result.ExecutionStart = Utility::GetTime(); - assert(m_FD == -1); + ASSERT(m_FD == -1); int fds[2]; diff --git a/lib/base/socket.cpp b/lib/base/socket.cpp index 6e6c92950..196cb2bed 100644 --- a/lib/base/socket.cpp +++ b/lib/base/socket.cpp @@ -50,8 +50,8 @@ void Socket::Start(void) { ObjectLock olock(this); - assert(!m_ReadThread.joinable() && !m_WriteThread.joinable()); - assert(GetFD() != INVALID_SOCKET); + ASSERT(!m_ReadThread.joinable() && !m_WriteThread.joinable()); + ASSERT(GetFD() != INVALID_SOCKET); // TODO: figure out why we're not using "this" here m_ReadThread = thread(boost::bind(&Socket::ReadThreadProc, static_cast(GetSelf()))); diff --git a/lib/base/stacktrace.cpp b/lib/base/stacktrace.cpp index 4ed919c4e..28c3ab147 100644 --- a/lib/base/stacktrace.cpp +++ b/lib/base/stacktrace.cpp @@ -152,10 +152,21 @@ void StackTrace::Print(ostream& fp, int ignoreFrames) IMAGEHLP_LINE64 line; line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); - (void) SymGetLineFromAddr64(GetCurrentProcess(), dwAddress, &dwDisplacement, &line); - (void) SymFromAddr(GetCurrentProcess(), dwAddress, &dwDisplacement64, pSymbol); + fp << "\t(" << i - ignoreFrames - 1 << ") "; + + if (SymGetLineFromAddr64(GetCurrentProcess(), dwAddress, &dwDisplacement, &line)) + fp << line.FileName << ":" << line.LineNumber; + else + fp << "(unknown file/line)"; - fp << "\t(" << i - ignoreFrames - 1 << ") " << line.FileName << ":" << line.LineNumber << ": " << pSymbol->Name << "+" << dwDisplacement64 << std::endl; + fp << ": "; + + if (SymFromAddr(GetCurrentProcess(), dwAddress, &dwDisplacement64, pSymbol)) + fp << pSymbol->Name << "+" << dwDisplacement64; + else + fp << "(unknown function)"; + + fp << std::endl; } #endif /* _WIN32 */ } diff --git a/lib/base/stream.cpp b/lib/base/stream.cpp index f2155c0ad..235bd8bf2 100644 --- a/lib/base/stream.cpp +++ b/lib/base/stream.cpp @@ -27,7 +27,7 @@ Stream::Stream(void) Stream::~Stream(void) { - assert(!m_Running); + ASSERT(!m_Running); } /** @@ -106,7 +106,7 @@ void Stream::Close(void) { ObjectLock olock(this); - assert(m_Running); + ASSERT(m_Running); m_Running = false; } diff --git a/lib/base/sysloglogger.cpp b/lib/base/sysloglogger.cpp index 57d674fb3..f6d4a5c10 100644 --- a/lib/base/sysloglogger.cpp +++ b/lib/base/sysloglogger.cpp @@ -45,7 +45,7 @@ void SyslogLogger::ProcessLogEntry(const LogEntry& entry) severity = LOG_CRIT; break; default: - assert(!"Invalid severity specified."); + ASSERT(!"Invalid severity specified."); } syslog(severity | LOG_USER, "%s", entry.Message.CStr()); diff --git a/lib/base/timer.cpp b/lib/base/timer.cpp index fc5871ddb..ccc4136f5 100644 --- a/lib/base/timer.cpp +++ b/lib/base/timer.cpp @@ -88,7 +88,7 @@ void Timer::Uninitialize(void) */ void Timer::Call(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); Timer::Ptr self = GetSelf(); @@ -105,7 +105,7 @@ void Timer::Call(void) */ void Timer::SetInterval(double interval) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); boost::mutex::scoped_lock lock(m_Mutex); m_Interval = interval; @@ -119,7 +119,7 @@ void Timer::SetInterval(double interval) */ double Timer::GetInterval(void) const { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); boost::mutex::scoped_lock lock(m_Mutex); return m_Interval; @@ -132,7 +132,7 @@ double Timer::GetInterval(void) const */ void Timer::Start(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); { boost::mutex::scoped_lock lock(m_Mutex); @@ -149,7 +149,7 @@ void Timer::Start(void) */ void Timer::Stop(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); boost::mutex::scoped_lock lock(m_Mutex); @@ -169,7 +169,7 @@ void Timer::Stop(void) */ void Timer::Reschedule(double next) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); boost::mutex::scoped_lock lock(m_Mutex); @@ -196,7 +196,7 @@ void Timer::Reschedule(double next) */ double Timer::GetNext(void) const { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); boost::mutex::scoped_lock lock(m_Mutex); return m_Next; diff --git a/lib/base/tlsstream.cpp b/lib/base/tlsstream.cpp index 29e81586c..3babd20db 100644 --- a/lib/base/tlsstream.cpp +++ b/lib/base/tlsstream.cpp @@ -131,7 +131,7 @@ void TlsStream::ClosedHandler(void) */ void TlsStream::HandleIO(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); char data[16 * 1024]; diff --git a/lib/base/utility.h b/lib/base/utility.h index 9035f2945..b352346bb 100644 --- a/lib/base/utility.h +++ b/lib/base/utility.h @@ -86,4 +86,10 @@ private: } +#ifdef _DEBUG +# define ASSERT(expr) ASSERT(expr) +#else /* _DEBUG */ +# define ASSERT(expr) +#endif /* _DEBUG */ + #endif /* UTILITY_H */ diff --git a/lib/config/config_parser.cc b/lib/config/config_parser.cc index aa63238f3..c43670e55 100644 --- a/lib/config/config_parser.cc +++ b/lib/config/config_parser.cc @@ -257,7 +257,7 @@ static ConfigType::Ptr m_Type; void ConfigCompiler::Compile(void) { - assert(ConfigCompilerContext::GetContext() != NULL); + ASSERT(ConfigCompilerContext::GetContext() != NULL); try { yyparse(this); diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index 58c5f5717..05b69c93b 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -104,7 +104,7 @@ static ConfigType::Ptr m_Type; void ConfigCompiler::Compile(void) { - assert(ConfigCompilerContext::GetContext() != NULL); + ASSERT(ConfigCompilerContext::GetContext() != NULL); try { yyparse(this); diff --git a/lib/config/configcompilercontext.cpp b/lib/config/configcompilercontext.cpp index e31433cbb..854079512 100644 --- a/lib/config/configcompilercontext.cpp +++ b/lib/config/configcompilercontext.cpp @@ -91,7 +91,7 @@ int ConfigCompilerContext::GetFlags(void) const void ConfigCompilerContext::SetContext(ConfigCompilerContext *context) { - assert(m_Context == NULL || context == NULL); + ASSERT(m_Context == NULL || context == NULL); m_Context = context; } @@ -131,7 +131,7 @@ void ConfigCompilerContext::Validate(void) void ConfigCompilerContext::ActivateItems(void) { - assert(m_Context == NULL); + ASSERT(m_Context == NULL); Logger::Write(LogInformation, "config", "Activating config items in compilation unit '" + m_Unit + "'"); BOOST_FOREACH(const ConfigItem::Ptr& item, m_Items) { diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp index c0d1dd23f..90e67a9cd 100644 --- a/lib/config/configitem.cpp +++ b/lib/config/configitem.cpp @@ -155,7 +155,7 @@ void ConfigItem::InternalLink(const Dictionary::Ptr& dictionary) const */ DynamicObject::Ptr ConfigItem::Commit(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); String type, name; @@ -290,7 +290,7 @@ DynamicObject::Ptr ConfigItem::Commit(void) */ void ConfigItem::Unregister(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); DynamicObject::Ptr dobj = m_DynamicObject.lock(); @@ -314,7 +314,7 @@ void ConfigItem::Unregister(void) void ConfigItem::UnregisterFromParents(void) { - assert(OwnsLock()); + ASSERT(OwnsLock()); BOOST_FOREACH(const String& parentName, m_Parents) { ConfigItem::Ptr parent = GetObject(GetType(), parentName); @@ -329,7 +329,7 @@ void ConfigItem::UnregisterFromParents(void) */ void ConfigItem::OnParentCommitted(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ConfigItem::Ptr self = GetSelf(); diff --git a/lib/config/typerule.cpp b/lib/config/typerule.cpp index bba23557c..33ce4b77a 100644 --- a/lib/config/typerule.cpp +++ b/lib/config/typerule.cpp @@ -63,7 +63,7 @@ bool TypeRule::MatchValue(const Value& value) const return value.IsObjectType(); default: - assert(!"Type rule has invalid type specifier."); + ASSERT(!"Type rule has invalid type specifier."); return false; } diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp index f3776473a..da51602a7 100644 --- a/lib/icinga/host.cpp +++ b/lib/icinga/host.cpp @@ -56,7 +56,7 @@ Host::~Host(void) void Host::OnRegistrationCompleted(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); DynamicObject::OnRegistrationCompleted(); @@ -109,7 +109,7 @@ String Host::GetHostCheck(void) const bool Host::IsReachable(void) const { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); set parentServices = GetParentServices(); @@ -204,7 +204,7 @@ static void CopyServiceAttributes(TDict serviceDesc, const ConfigItemBuilder::Pt void Host::UpdateSlaveServices(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ConfigItem::Ptr item = ConfigItem::GetObject("Host", GetName()); @@ -289,7 +289,7 @@ void Host::UpdateSlaveServices(void) void Host::OnAttributeChanged(const String& name) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); if (name == "hostgroups") HostGroup::InvalidateMembersCache(); @@ -434,7 +434,7 @@ Service::Ptr Host::GetServiceByShortName(const Value& name) const if (it != services.end()) { Service::Ptr service = it->second.lock(); - assert(service); + ASSERT(service); return service; } } @@ -444,7 +444,7 @@ Service::Ptr Host::GetServiceByShortName(const Value& name) const Dictionary::Ptr dict = name; String short_name; - assert(dict->IsSealed()); + ASSERT(dict->IsSealed()); return Service::GetByNamePair(dict->Get("host"), dict->Get("service")); } else { @@ -537,7 +537,7 @@ StateType Host::GetStateType(void) const HostState Host::GetLastState(void) const { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); if (!IsReachable()) return HostUnreachable; @@ -582,7 +582,7 @@ String Host::HostStateToString(HostState state) Dictionary::Ptr Host::CalculateDynamicMacros(void) const { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); Dictionary::Ptr macros = boost::make_shared(); diff --git a/lib/icinga/hostgroup.cpp b/lib/icinga/hostgroup.cpp index fdcc06b22..07efe9f2b 100644 --- a/lib/icinga/hostgroup.cpp +++ b/lib/icinga/hostgroup.cpp @@ -46,7 +46,7 @@ HostGroup::~HostGroup(void) */ void HostGroup::OnRegistrationCompleted(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); InvalidateMembersCache(); } diff --git a/lib/icinga/icingaapplication.cpp b/lib/icinga/icingaapplication.cpp index 9827f3a00..ae504f6a7 100644 --- a/lib/icinga/icingaapplication.cpp +++ b/lib/icinga/icingaapplication.cpp @@ -90,7 +90,7 @@ int IcingaApplication::Main(void) */ void IcingaApplication::OnShutdown(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); { ObjectLock olock(this); diff --git a/lib/icinga/macroprocessor.cpp b/lib/icinga/macroprocessor.cpp index dd6dcec4a..ec9514982 100644 --- a/lib/icinga/macroprocessor.cpp +++ b/lib/icinga/macroprocessor.cpp @@ -28,7 +28,7 @@ Value MacroProcessor::ResolveMacros(const Value& cmd, const Dictionary::Ptr& mac { Value result; - assert(macros->IsSealed()); + ASSERT(macros->IsSealed()); if (cmd.IsScalar()) { result = InternalResolveMacros(cmd, macros); diff --git a/lib/icinga/notification.cpp b/lib/icinga/notification.cpp index e9f6c9d99..11d92ef3c 100644 --- a/lib/icinga/notification.cpp +++ b/lib/icinga/notification.cpp @@ -163,7 +163,7 @@ String Notification::NotificationTypeToString(NotificationType type) */ void Notification::BeginExecuteNotification(NotificationType type, const Dictionary::Ptr& cr) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); Dictionary::Ptr macros = cr->Get("macros"); @@ -193,7 +193,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const Diction */ void Notification::BeginExecuteNotificationHelper(const Dictionary::Ptr& notificationMacros, NotificationType type, const User::Ptr& user) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); vector macroDicts; @@ -237,7 +237,7 @@ void Notification::BeginExecuteNotificationHelper(const Dictionary::Ptr& notific */ void Notification::NotificationCompletedHandler(const ScriptTask::Ptr& task) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); { ObjectLock olock(this); @@ -264,7 +264,7 @@ void Notification::NotificationCompletedHandler(const ScriptTask::Ptr& task) */ void Notification::OnAttributeChanged(const String& name) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); if (name == "host_name" || name == "service") Service::InvalidateNotificationsCache(); diff --git a/lib/icinga/service-check.cpp b/lib/icinga/service-check.cpp index 1f6d40567..1b2c5e0d4 100644 --- a/lib/icinga/service-check.cpp +++ b/lib/icinga/service-check.cpp @@ -373,7 +373,7 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr) { bool reachable = IsReachable(); - assert(!OwnsLock()); + ASSERT(!OwnsLock()); ObjectLock olock(this); ServiceState old_state = GetState(); @@ -571,7 +571,7 @@ bool Service::IsAllowedChecker(const String& checker) const */ void Service::BeginExecuteCheck(const function& callback) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); { ObjectLock olock(this); @@ -619,7 +619,7 @@ void Service::BeginExecuteCheck(const function& callback) void Service::CheckCompletedHandler(const Dictionary::Ptr& checkInfo, const ScriptTask::Ptr& task, const function& callback) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); checkInfo->Set("execution_end", Utility::GetTime()); checkInfo->Set("schedule_end", Utility::GetTime()); diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index b289cf5ae..5a94b96db 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -83,7 +83,7 @@ Service::~Service(void) */ void Service::OnRegistrationCompleted(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); DynamicObject::OnRegistrationCompleted(); @@ -192,7 +192,7 @@ String Service::GetShortName(void) const */ bool Service::IsReachable(void) const { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); BOOST_FOREACH(const Service::Ptr& service, GetParentServices()) { /* ignore ourselves */ @@ -249,7 +249,7 @@ bool Service::IsReachable(void) const */ AcknowledgementType Service::GetAcknowledgement(void) { - assert(OwnsLock()); + ASSERT(OwnsLock()); if (m_Acknowledgement.IsEmpty()) return AcknowledgementNone; @@ -336,7 +336,7 @@ void Service::ClearAcknowledgement(void) */ void Service::OnAttributeChanged(const String& name) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); Service::Ptr self = GetSelf(); @@ -454,7 +454,7 @@ Dictionary::Ptr Service::CalculateDynamicMacros(void) const } if (cr) { - assert(cr->IsSealed()); + ASSERT(cr->IsSealed()); macros->Set("SERVICELATENCY", Service::CalculateLatency(cr)); macros->Set("SERVICEEXECUTIONTIME", Service::CalculateExecutionTime(cr)); diff --git a/lib/icinga/servicegroup.cpp b/lib/icinga/servicegroup.cpp index 2d52c08f0..dfb9bf9c5 100644 --- a/lib/icinga/servicegroup.cpp +++ b/lib/icinga/servicegroup.cpp @@ -46,7 +46,7 @@ ServiceGroup::~ServiceGroup(void) */ void ServiceGroup::OnRegistrationCompleted(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); InvalidateMembersCache(); } diff --git a/lib/icinga/user.cpp b/lib/icinga/user.cpp index 07ddf9e78..f85f1c382 100644 --- a/lib/icinga/user.cpp +++ b/lib/icinga/user.cpp @@ -41,7 +41,7 @@ User::~User(void) */ void User::OnAttributeChanged(const String& name) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); if (name == "groups") UserGroup::InvalidateMembersCache(); diff --git a/lib/icinga/usergroup.cpp b/lib/icinga/usergroup.cpp index 15c6f151d..99ff78661 100644 --- a/lib/icinga/usergroup.cpp +++ b/lib/icinga/usergroup.cpp @@ -44,7 +44,7 @@ UserGroup::~UserGroup(void) */ void UserGroup::OnRegistrationCompleted(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); InvalidateMembersCache(); } diff --git a/lib/remoting/endpoint.cpp b/lib/remoting/endpoint.cpp index 2bf26e951..4d5518867 100644 --- a/lib/remoting/endpoint.cpp +++ b/lib/remoting/endpoint.cpp @@ -294,7 +294,7 @@ void Endpoint::NewMessageHandler(const MessagePart& message) void Endpoint::ClientClosedHandler(void) { - assert(!OwnsLock()); + ASSERT(!OwnsLock()); /*try { GetClient()->CheckException(); -- 2.40.0