Fix another couple of compiler warnings.

Refs #5823
This commit is contained in:
Gunnar Beutner 2014-05-11 08:27:42 +02:00
parent 12c8814bd8
commit 6a8db4035d
4 changed files with 9 additions and 8 deletions

View File

@ -151,6 +151,8 @@ Array::Ptr ScriptUtils::Range(const std::vector<Value>& arguments)
end = arguments[1]; end = arguments[1];
increment = arguments[2]; increment = arguments[2];
break; break;
default:
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid number of arguments for range()"));
} }
Array::Ptr result = make_shared<Array>(); Array::Ptr result = make_shared<Array>();

View File

@ -33,10 +33,10 @@ using namespace icinga;
int ThreadPool::m_NextID = 1; 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) : 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]); m_MaxThreads = sizeof(m_Queues) / sizeof(m_Queues[0]);
Start(); Start();
@ -242,7 +242,7 @@ void ThreadPool::ManagerThreadProc(void)
break; 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; size_t pending, alive = 0;
double avg_latency; double avg_latency;
double utilization = 0; double utilization = 0;
@ -287,7 +287,7 @@ void ThreadPool::ManagerThreadProc(void)
if (tthreads > 0 && pending > 0) if (tthreads > 0 && pending > 0)
tthreads = 8; 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; tthreads = m_MaxThreads / (sizeof(m_Queues) / sizeof(m_Queues[0])) - alive;
if (tthreads != 0) { if (tthreads != 0) {
@ -383,7 +383,7 @@ void ThreadPool::WorkerThread::UpdateUtilization(ThreadState state)
utilization = 1; utilization = 1;
break; break;
default: default:
ASSERT(0); VERIFY(0);
} }
double now = Utility::GetTime(); double now = Utility::GetTime();

View File

@ -40,7 +40,7 @@ class I2_BASE_API ThreadPool
public: public:
typedef boost::function<void ()> WorkFunction; typedef boost::function<void ()> WorkFunction;
ThreadPool(int max_threads = -1); ThreadPool(size_t max_threads = UINT_MAX);
~ThreadPool(void); ~ThreadPool(void);
void Start(void); void Start(void);
@ -110,7 +110,7 @@ private:
int m_ID; int m_ID;
static int m_NextID; static int m_NextID;
unsigned int m_MaxThreads; size_t m_MaxThreads;
boost::thread_group m_ThreadGroup; boost::thread_group m_ThreadGroup;

View File

@ -402,7 +402,6 @@ Dictionary::Ptr LegacyTimePeriod::FindNextSegment(const String& daydef, const St
iter = begin; iter = begin;
tsend = mktime(&end); tsend = mktime(&end);
tsiter = mktime(&iter);
do { do {
if (IsInTimeRange(&begin, &end, stride, &iter)) { if (IsInTimeRange(&begin, &end, stride, &iter)) {