mirror of https://github.com/Icinga/icinga2.git
Fix compiler warnings
This commit is contained in:
parent
42744fde5b
commit
3c5af89d5f
|
@ -7,14 +7,17 @@ using System.Text;
|
|||
|
||||
namespace Icinga
|
||||
{
|
||||
static class Program
|
||||
internal static class NativeMethods
|
||||
{
|
||||
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
|
||||
internal static extern int MsiEnumProducts(int iProductIndex, StringBuilder lpProductBuf);
|
||||
|
||||
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
|
||||
internal static extern Int32 MsiGetProductInfo(string product, string property, [Out] StringBuilder valueBuf, ref Int32 len);
|
||||
}
|
||||
|
||||
static class Program
|
||||
{
|
||||
[DllImport("msi.dll", SetLastError = true)]
|
||||
static extern int MsiEnumProducts(int iProductIndex, StringBuilder lpProductBuf);
|
||||
|
||||
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
|
||||
static extern Int32 MsiGetProductInfo(string product, string property, [Out] StringBuilder valueBuf, ref Int32 len);
|
||||
|
||||
public static string Icinga2InstallDir
|
||||
{
|
||||
get
|
||||
|
@ -23,13 +26,13 @@ namespace Icinga
|
|||
|
||||
for (int index = 0; ; index++) {
|
||||
szProduct = new StringBuilder(39);
|
||||
if (MsiEnumProducts(index, szProduct) != 0)
|
||||
if (NativeMethods.MsiEnumProducts(index, szProduct) != 0)
|
||||
break;
|
||||
|
||||
int cbName = 128;
|
||||
StringBuilder szName = new StringBuilder(cbName);
|
||||
|
||||
if (MsiGetProductInfo(szProduct.ToString(), "ProductName", szName, ref cbName) != 0)
|
||||
if (NativeMethods.MsiGetProductInfo(szProduct.ToString(), "ProductName", szName, ref cbName) != 0)
|
||||
continue;
|
||||
|
||||
if (szName.ToString() != "Icinga 2")
|
||||
|
@ -37,7 +40,7 @@ namespace Icinga
|
|||
|
||||
int cbLocation = 1024;
|
||||
StringBuilder szLocation = new StringBuilder(cbLocation);
|
||||
if (MsiGetProductInfo(szProduct.ToString(), "InstallLocation", szLocation, ref cbLocation) == 0)
|
||||
if (NativeMethods.MsiGetProductInfo(szProduct.ToString(), "InstallLocation", szLocation, ref cbLocation) == 0)
|
||||
return szLocation.ToString();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ REGISTER_PRIMITIVE_TYPE(Array, Object, Array::GetPrototype());
|
|||
* @param index The index.
|
||||
* @returns The value.
|
||||
*/
|
||||
Value Array::Get(unsigned int index) const
|
||||
Value Array::Get(SizeType index) const
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
|
@ -49,7 +49,7 @@ Value Array::Get(unsigned int index) const
|
|||
* @param index The index.
|
||||
* @param value The value.
|
||||
*/
|
||||
void Array::Set(unsigned int index, const Value& value)
|
||||
void Array::Set(SizeType index, const Value& value)
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
|
@ -62,7 +62,7 @@ void Array::Set(unsigned int index, const Value& value)
|
|||
* @param index The index.
|
||||
* @param value The value.
|
||||
*/
|
||||
void Array::Set(unsigned int index, Value&& value)
|
||||
void Array::Set(SizeType index, Value&& value)
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
|
@ -124,7 +124,7 @@ bool Array::Contains(const Value& value) const
|
|||
* @param index The index
|
||||
* @param value The value to add
|
||||
*/
|
||||
void Array::Insert(unsigned int index, const Value& value)
|
||||
void Array::Insert(SizeType index, const Value& value)
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
|
@ -138,7 +138,7 @@ void Array::Insert(unsigned int index, const Value& value)
|
|||
*
|
||||
* @param index The index.
|
||||
*/
|
||||
void Array::Remove(unsigned int index)
|
||||
void Array::Remove(SizeType index)
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
|
@ -157,11 +157,11 @@ void Array::Remove(Array::Iterator it)
|
|||
m_Data.erase(it);
|
||||
}
|
||||
|
||||
void Array::Resize(size_t new_size)
|
||||
void Array::Resize(SizeType newSize)
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
m_Data.resize(new_size);
|
||||
m_Data.resize(newSize);
|
||||
}
|
||||
|
||||
void Array::Clear(void)
|
||||
|
@ -171,11 +171,11 @@ void Array::Clear(void)
|
|||
m_Data.clear();
|
||||
}
|
||||
|
||||
void Array::Reserve(size_t new_size)
|
||||
void Array::Reserve(SizeType newSize)
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
m_Data.reserve(new_size);
|
||||
m_Data.reserve(newSize);
|
||||
}
|
||||
|
||||
void Array::CopyTo(const Array::Ptr& dest) const
|
||||
|
|
|
@ -57,9 +57,9 @@ public:
|
|||
inline ~Array(void)
|
||||
{ }
|
||||
|
||||
Value Get(unsigned int index) const;
|
||||
void Set(unsigned int index, const Value& value);
|
||||
void Set(unsigned int index, Value&& value);
|
||||
Value Get(SizeType index) const;
|
||||
void Set(SizeType index, const Value& value);
|
||||
void Set(SizeType index, Value&& value);
|
||||
void Add(const Value& value);
|
||||
void Add(Value&& value);
|
||||
|
||||
|
@ -94,14 +94,14 @@ public:
|
|||
size_t GetLength(void) const;
|
||||
bool Contains(const Value& value) const;
|
||||
|
||||
void Insert(unsigned int index, const Value& value);
|
||||
void Remove(unsigned int index);
|
||||
void Insert(SizeType index, const Value& value);
|
||||
void Remove(SizeType index);
|
||||
void Remove(Iterator it);
|
||||
|
||||
void Resize(size_t new_size);
|
||||
void Resize(SizeType newSize);
|
||||
void Clear(void);
|
||||
|
||||
void Reserve(size_t new_size);
|
||||
void Reserve(SizeType newSize);
|
||||
|
||||
void CopyTo(const Array::Ptr& dest) const;
|
||||
Array::Ptr ShallowClone(void) const;
|
||||
|
|
|
@ -25,15 +25,20 @@
|
|||
namespace icinga
|
||||
{
|
||||
|
||||
#define I2_TOKENPASTE(x, y) x ## y
|
||||
#define I2_TOKENPASTE2(x, y) I2_TOKENPASTE(x, y)
|
||||
|
||||
#define I2_UNIQUE_NAME(prefix) I2_TOKENPASTE2(prefix, __COUNTER__)
|
||||
|
||||
I2_BASE_API bool InitializeOnceHelper(void (*func)(void), int priority = 0);
|
||||
|
||||
#define INITIALIZE_ONCE(func) \
|
||||
namespace { namespace UNIQUE_NAME(io) { \
|
||||
namespace { namespace I2_UNIQUE_NAME(io) { \
|
||||
I2_EXPORT bool l_InitializeOnce(icinga::InitializeOnceHelper(func)); \
|
||||
} }
|
||||
|
||||
#define INITIALIZE_ONCE_WITH_PRIORITY(func, priority) \
|
||||
namespace { namespace UNIQUE_NAME(io) { \
|
||||
namespace { namespace I2_UNIQUE_NAME(io) { \
|
||||
I2_EXPORT bool l_InitializeOnce(icinga::InitializeOnceHelper(func, priority)); \
|
||||
} }
|
||||
}
|
||||
|
|
|
@ -330,29 +330,30 @@ size_t Socket::Read(void *buffer, size_t count)
|
|||
*/
|
||||
Socket::Ptr Socket::Accept(void)
|
||||
{
|
||||
int fd;
|
||||
sockaddr_storage addr;
|
||||
socklen_t addrlen = sizeof(addr);
|
||||
|
||||
fd = accept(GetFD(), (sockaddr *)&addr, &addrlen);
|
||||
SOCKET fd = accept(GetFD(), (sockaddr *)&addr, &addrlen);
|
||||
|
||||
if (fd < 0) {
|
||||
#ifndef _WIN32
|
||||
if (fd < 0) {
|
||||
Log(LogCritical, "Socket")
|
||||
<< "accept() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
|
||||
<< "accept() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
|
||||
|
||||
BOOST_THROW_EXCEPTION(socket_error()
|
||||
<< boost::errinfo_api_function("accept")
|
||||
<< boost::errinfo_errno(errno));
|
||||
#else /* _WIN32 */
|
||||
Log(LogCritical, "Socket")
|
||||
<< "accept() failed with error code " << WSAGetLastError() << ", \"" << Utility::FormatErrorNumber(WSAGetLastError()) << "\"";
|
||||
|
||||
BOOST_THROW_EXCEPTION(socket_error()
|
||||
<< boost::errinfo_api_function("accept")
|
||||
<< errinfo_win32_error(WSAGetLastError()));
|
||||
#endif /* _WIN32 */
|
||||
<< boost::errinfo_api_function("accept")
|
||||
<< boost::errinfo_errno(errno));
|
||||
}
|
||||
#else /* _WIN32 */
|
||||
if (fd == INVALID_SOCKET) {
|
||||
Log(LogCritical, "Socket")
|
||||
<< "accept() failed with error code " << WSAGetLastError() << ", \"" << Utility::FormatErrorNumber(WSAGetLastError()) << "\"";
|
||||
|
||||
BOOST_THROW_EXCEPTION(socket_error()
|
||||
<< boost::errinfo_api_function("accept")
|
||||
<< errinfo_win32_error(WSAGetLastError()));
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
return new Socket(fd);
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ void TcpSocket::Connect(const String& node, const String& service)
|
|||
<< errinfo_getaddrinfo_error(rc));
|
||||
}
|
||||
|
||||
int fd = INVALID_SOCKET;
|
||||
SOCKET fd = INVALID_SOCKET;
|
||||
|
||||
for (addrinfo *info = result; info != NULL; info = info->ai_next) {
|
||||
fd = socket(info->ai_family, info->ai_socktype, info->ai_protocol);
|
||||
|
|
|
@ -29,9 +29,4 @@
|
|||
# define I2_HIDDEN
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#define TOKENPASTE(x, y) x ## y
|
||||
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
|
||||
|
||||
#define UNIQUE_NAME(prefix) TOKENPASTE2(prefix, __COUNTER__)
|
||||
|
||||
#endif /* VISIBILITY_H */
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
int WorkQueue::m_NextID = 1;
|
||||
std::atomic<int> WorkQueue::m_NextID(1);
|
||||
boost::thread_specific_ptr<WorkQueue *> l_ThreadWorkQueue;
|
||||
|
||||
WorkQueue::WorkQueue(size_t maxItems, int threadCount)
|
||||
|
@ -196,7 +196,7 @@ void WorkQueue::StatusTimerHandler(void)
|
|||
|
||||
ASSERT(!m_Name.IsEmpty());
|
||||
|
||||
int pending = m_Tasks.size();
|
||||
size_t pending = m_Tasks.size();
|
||||
|
||||
double now = Utility::GetTime();
|
||||
double gradient = (pending - m_PendingTasks) / (now - m_PendingTasksTimestamp);
|
||||
|
@ -295,7 +295,7 @@ void WorkQueue::IncreaseTaskCount(void)
|
|||
m_TaskStats.InsertValue(now, 1);
|
||||
}
|
||||
|
||||
int WorkQueue::GetTaskCount(RingBuffer::SizeType span)
|
||||
size_t WorkQueue::GetTaskCount(RingBuffer::SizeType span)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_StatsMutex);
|
||||
return m_TaskStats.UpdateAndGetValues(Utility::GetTime(), span);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <boost/exception_ptr.hpp>
|
||||
#include <queue>
|
||||
#include <deque>
|
||||
#include <atomic>
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
@ -93,7 +94,7 @@ public:
|
|||
bool IsWorkerThread(void) const;
|
||||
|
||||
size_t GetLength(void) const;
|
||||
int GetTaskCount(RingBuffer::SizeType span);
|
||||
size_t GetTaskCount(RingBuffer::SizeType span);
|
||||
|
||||
void SetExceptionCallback(const ExceptionCallback& callback);
|
||||
|
||||
|
@ -107,7 +108,7 @@ protected:
|
|||
private:
|
||||
int m_ID;
|
||||
String m_Name;
|
||||
static int m_NextID;
|
||||
static std::atomic<int> m_NextID;
|
||||
int m_ThreadCount;
|
||||
bool m_Spawned;
|
||||
|
||||
|
@ -128,7 +129,7 @@ private:
|
|||
|
||||
mutable boost::mutex m_StatsMutex;
|
||||
RingBuffer m_TaskStats;
|
||||
int m_PendingTasks;
|
||||
size_t m_PendingTasks;
|
||||
double m_PendingTasksTimestamp;
|
||||
|
||||
void WorkerThreadProc(void);
|
||||
|
|
|
@ -294,7 +294,7 @@ void ApiClient::ExecuteScriptHttpCompletionCallback(HttpRequest& request,
|
|||
}
|
||||
|
||||
callback(boost::exception_ptr(), result);
|
||||
} catch (const std::exception& ex) {
|
||||
} catch (const std::exception&) {
|
||||
callback(boost::current_exception(), Empty);
|
||||
}
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ void ApiClient::AutocompleteScript(const String& session, const String& command,
|
|||
req->AddHeader("Authorization", "Basic " + Base64::Encode(m_User + ":" + m_Password));
|
||||
req->AddHeader("Accept", "application/json");
|
||||
m_Connection->SubmitRequest(req, std::bind(AutocompleteScriptHttpCompletionCallback, _1, _2, callback));
|
||||
} catch (const std::exception& ex) {
|
||||
} catch (const std::exception&) {
|
||||
callback(boost::current_exception(), nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ void ApiClient::AutocompleteScriptHttpCompletionCallback(HttpRequest& request,
|
|||
}
|
||||
|
||||
callback(boost::exception_ptr(), suggestions);
|
||||
} catch (const std::exception& ex) {
|
||||
} catch (const std::exception&) {
|
||||
callback(boost::current_exception(), nullptr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -322,18 +322,17 @@ void JsonRpcConnection::TimeoutTimerHandler(void)
|
|||
}
|
||||
}
|
||||
|
||||
int JsonRpcConnection::GetWorkQueueCount(void)
|
||||
size_t JsonRpcConnection::GetWorkQueueCount(void)
|
||||
{
|
||||
return l_JsonRpcConnectionWorkQueueCount;
|
||||
}
|
||||
|
||||
int JsonRpcConnection::GetWorkQueueLength(void)
|
||||
size_t JsonRpcConnection::GetWorkQueueLength(void)
|
||||
{
|
||||
int itemCount = 0;
|
||||
size_t itemCount = 0;
|
||||
|
||||
for (int i = 0; i < GetWorkQueueCount(); i++) {
|
||||
for (size_t i = 0; i < GetWorkQueueCount(); i++)
|
||||
itemCount += l_JsonRpcConnectionWorkQueues[i].GetLength();
|
||||
}
|
||||
|
||||
return itemCount;
|
||||
}
|
||||
|
@ -341,15 +340,14 @@ int JsonRpcConnection::GetWorkQueueLength(void)
|
|||
double JsonRpcConnection::GetWorkQueueRate(void)
|
||||
{
|
||||
double rate = 0.0;
|
||||
int count = GetWorkQueueCount();
|
||||
size_t count = GetWorkQueueCount();
|
||||
|
||||
/* If this is a standalone environment, we don't have any queues. */
|
||||
if (count == 0)
|
||||
return 0.0;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
for (size_t i = 0; i < count; i++)
|
||||
rate += l_JsonRpcConnectionWorkQueues[i].GetTaskCount(60) / 60.0;
|
||||
}
|
||||
|
||||
return rate / count;
|
||||
}
|
||||
|
|
|
@ -71,8 +71,8 @@ public:
|
|||
static void HeartbeatTimerHandler(void);
|
||||
static Value HeartbeatAPIHandler(const intrusive_ptr<MessageOrigin>& origin, const Dictionary::Ptr& params);
|
||||
|
||||
static int GetWorkQueueCount(void);
|
||||
static int GetWorkQueueLength(void);
|
||||
static size_t GetWorkQueueCount(void);
|
||||
static size_t GetWorkQueueLength(void);
|
||||
static double GetWorkQueueRate(void);
|
||||
|
||||
static void SendCertificateRequest(const JsonRpcConnection::Ptr& aclient, const intrusive_ptr<MessageOrigin>& origin, const String& path);
|
||||
|
|
|
@ -186,7 +186,7 @@ static INT parseArguments(INT ac, WCHAR **av, po::variables_map& vm, printInfoSt
|
|||
printInfo.unit = BunitB;
|
||||
}
|
||||
|
||||
printInfo.showUsed = vm.count("show-used");
|
||||
printInfo.showUsed = vm.count("show-used") > 0;
|
||||
|
||||
if (vm.count("debug"))
|
||||
debug = TRUE;
|
||||
|
|
|
@ -129,7 +129,7 @@ std::wstring threshold::pString(CONST DOUBLE max)
|
|||
std::wstring removeZero(DOUBLE val)
|
||||
{
|
||||
std::wstring ret = boost::lexical_cast<std::wstring>(val);
|
||||
INT pos = ret.length();
|
||||
std::wstring::size_type pos = ret.length();
|
||||
if (ret.find_first_of(L".") == std::string::npos)
|
||||
return ret;
|
||||
for (std::wstring::reverse_iterator rit = ret.rbegin(); rit != ret.rend(); ++rit) {
|
||||
|
|
Loading…
Reference in New Issue