diff --git a/lib/base/scriptutils.cpp b/lib/base/scriptutils.cpp index 50659bdc3..0f7b97449 100644 --- a/lib/base/scriptutils.cpp +++ b/lib/base/scriptutils.cpp @@ -151,6 +151,8 @@ Array::Ptr ScriptUtils::Range(const std::vector& arguments) end = arguments[1]; increment = arguments[2]; break; + default: + BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid number of arguments for range()")); } Array::Ptr result = make_shared(); diff --git a/lib/base/threadpool.cpp b/lib/base/threadpool.cpp index ea8b4304c..ba2e5dc9e 100644 --- a/lib/base/threadpool.cpp +++ b/lib/base/threadpool.cpp @@ -33,10 +33,10 @@ using namespace icinga; int ThreadPool::m_NextID = 1; -ThreadPool::ThreadPool(int max_threads) +ThreadPool::ThreadPool(size_t max_threads) : m_ID(m_NextID++), m_MaxThreads(max_threads), m_Stopped(false) { - if (m_MaxThreads != -1 && m_MaxThreads < sizeof(m_Queues) / sizeof(m_Queues[0])) + if (m_MaxThreads != UINT_MAX && m_MaxThreads < sizeof(m_Queues) / sizeof(m_Queues[0])) m_MaxThreads = sizeof(m_Queues) / sizeof(m_Queues[0]); Start(); @@ -242,7 +242,7 @@ void ThreadPool::ManagerThreadProc(void) break; } - for (int i = 0; i < sizeof(m_Queues) / sizeof(m_Queues[0]); i++) { + for (size_t i = 0; i < sizeof(m_Queues) / sizeof(m_Queues[0]); i++) { size_t pending, alive = 0; double avg_latency; double utilization = 0; @@ -287,7 +287,7 @@ void ThreadPool::ManagerThreadProc(void) if (tthreads > 0 && pending > 0) tthreads = 8; - if (m_MaxThreads != -1 && (alive + tthreads) * (sizeof(m_Queues) / sizeof(m_Queues[0])) > m_MaxThreads) + if (m_MaxThreads != UINT_MAX && (alive + tthreads) * (sizeof(m_Queues) / sizeof(m_Queues[0])) > m_MaxThreads) tthreads = m_MaxThreads / (sizeof(m_Queues) / sizeof(m_Queues[0])) - alive; if (tthreads != 0) { @@ -383,7 +383,7 @@ void ThreadPool::WorkerThread::UpdateUtilization(ThreadState state) utilization = 1; break; default: - ASSERT(0); + VERIFY(0); } double now = Utility::GetTime(); diff --git a/lib/base/threadpool.h b/lib/base/threadpool.h index 7460a5d21..3949e70b2 100644 --- a/lib/base/threadpool.h +++ b/lib/base/threadpool.h @@ -40,7 +40,7 @@ class I2_BASE_API ThreadPool public: typedef boost::function WorkFunction; - ThreadPool(int max_threads = -1); + ThreadPool(size_t max_threads = UINT_MAX); ~ThreadPool(void); void Start(void); @@ -110,7 +110,7 @@ private: int m_ID; static int m_NextID; - unsigned int m_MaxThreads; + size_t m_MaxThreads; boost::thread_group m_ThreadGroup; diff --git a/lib/icinga/legacytimeperiod.cpp b/lib/icinga/legacytimeperiod.cpp index 84a4cbfe5..e9256da47 100644 --- a/lib/icinga/legacytimeperiod.cpp +++ b/lib/icinga/legacytimeperiod.cpp @@ -402,7 +402,6 @@ Dictionary::Ptr LegacyTimePeriod::FindNextSegment(const String& daydef, const St iter = begin; tsend = mktime(&end); - tsiter = mktime(&iter); do { if (IsInTimeRange(&begin, &end, stride, &iter)) {