From: Gunnar Beutner Date: Wed, 8 Aug 2012 06:34:15 +0000 (+0200) Subject: Fixed some more compiler warnings. X-Git-Tag: v0.0.1~151 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0e674a7a7052a5eb8b7fb7a6134e977d6fef80db;p=icinga2 Fixed some more compiler warnings. --- diff --git a/base/component.cpp b/base/component.cpp index fbdc68a69..a22a094c6 100644 --- a/base/component.cpp +++ b/base/component.cpp @@ -59,15 +59,15 @@ Component::Component(const Dictionary::Ptr& properties) CreateComponentFunction pCreateComponent; #ifdef _WIN32 - pCreateComponent = (CreateComponentFunction)GetProcAddress(hModule, - "CreateComponent"); + pCreateComponent = reinterpret_cast(GetProcAddress(hModule, + "CreateComponent")); #else /* _WIN32 */ # ifdef __GNUC__ /* suppress compiler warning for void * cast */ __extension__ # endif - pCreateComponent = (CreateComponentFunction)lt_dlsym(hModule, - "CreateComponent"); + pCreateComponent = reinterpret_cast(lt_dlsym(hModule, + "CreateComponent")); #endif /* _WIN32 */ IComponent::Ptr impl; diff --git a/base/dictionary.cpp b/base/dictionary.cpp index 432609d42..8f42647b1 100644 --- a/base/dictionary.cpp +++ b/base/dictionary.cpp @@ -132,7 +132,7 @@ Dictionary::Iterator Dictionary::End(void) * * @returns Number of elements. */ -long Dictionary::GetLength(void) const +size_t Dictionary::GetLength(void) const { return m_Data.size(); } diff --git a/base/dictionary.h b/base/dictionary.h index 63eb166db..bdfd2af61 100644 --- a/base/dictionary.h +++ b/base/dictionary.h @@ -45,7 +45,7 @@ public: Iterator Begin(void); Iterator End(void); - long GetLength(void) const; + size_t GetLength(void) const; void Remove(const String& key); void Remove(Iterator it); diff --git a/base/dynamicobject.h b/base/dynamicobject.h index 7e9546058..d0a459ca9 100644 --- a/base/dynamicobject.h +++ b/base/dynamicobject.h @@ -156,7 +156,7 @@ public: }; #define REGISTER_CLASS(klass) \ - static RegisterClassHelper g_Register ## klass(#klass, boost::make_shared); + static RegisterClassHelper g_Register ## klass(#klass, boost::make_shared) } diff --git a/base/fifo.cpp b/base/fifo.cpp index e46c9f4d0..755bf1768 100644 --- a/base/fifo.cpp +++ b/base/fifo.cpp @@ -50,7 +50,7 @@ void FIFO::ResizeBuffer(size_t newSize) newSize = (newSize / FIFO::BlockSize + 1) * FIFO::BlockSize; - char *newBuffer = (char *)realloc(m_Buffer, newSize); + char *newBuffer = static_cast(realloc(m_Buffer, newSize)); if (newBuffer == NULL) throw_exception(bad_alloc()); diff --git a/base/netstring.cpp b/base/netstring.cpp index f15c73f36..ff23cd275 100644 --- a/base/netstring.cpp +++ b/base/netstring.cpp @@ -42,7 +42,7 @@ bool NetString::ReadStringFromIOQueue(IOQueue *queue, String *str) if (buffer_length > 16) buffer_length = 16; - char *buffer = (char *)malloc(buffer_length); + char *buffer = static_cast(malloc(buffer_length)); if (buffer == NULL && buffer_length > 0) throw_exception(bad_alloc()); @@ -77,7 +77,7 @@ bool NetString::ReadStringFromIOQueue(IOQueue *queue, String *str) /* limit the number of bytes we're reading to this message */ buffer_length = i + 1 + len + 1; - char *new_buffer = (char *)realloc(buffer, buffer_length); + char *new_buffer = static_cast(realloc(buffer, buffer_length)); if (new_buffer == NULL) { free(buffer); diff --git a/base/object.h b/base/object.h index 59c469161..6398938e2 100644 --- a/base/object.h +++ b/base/object.h @@ -115,7 +115,7 @@ public: */ bool operator()(const weak_ptr& wref) const { - return (wref.lock().get() == (const T *)m_Ref); + return (wref.lock().get() == static_cast(m_Ref)); } }; diff --git a/base/tcpclient.cpp b/base/tcpclient.cpp index 14ac23fa2..317897fd2 100644 --- a/base/tcpclient.cpp +++ b/base/tcpclient.cpp @@ -128,7 +128,7 @@ void TcpClient::HandleWritable(void) m_SendQueue->Peek(data, count); } - rc = send(GetFD(), (const char *)data, count, 0); + rc = send(GetFD(), data, count, 0); if (rc <= 0) throw_exception(SocketException("send() failed", GetError())); diff --git a/base/tcpsocket.cpp b/base/tcpsocket.cpp index 0ceedfa18..2e7bf3d2a 100644 --- a/base/tcpsocket.cpp +++ b/base/tcpsocket.cpp @@ -82,11 +82,11 @@ void TcpSocket::Bind(String node, String service, int family) SetFD(fd); const int optFalse = 0; - setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&optFalse, sizeof(optFalse)); + setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast(&optFalse), sizeof(optFalse)); #ifndef _WIN32 const int optTrue = 1; - setsockopt(GetFD(), SOL_SOCKET, SO_REUSEADDR, (char *)&optTrue, sizeof(optTrue)); + setsockopt(GetFD(), SOL_SOCKET, SO_REUSEADDR, reinterpret_cast(&optTrue), sizeof(optTrue)); #endif /* _WIN32 */ int rc = bind(fd, info->ai_addr, info->ai_addrlen); diff --git a/base/tlsclient.cpp b/base/tlsclient.cpp index 80eb61ca7..d69b3e345 100644 --- a/base/tlsclient.cpp +++ b/base/tlsclient.cpp @@ -48,7 +48,7 @@ void TlsClient::Start(void) throw_exception(logic_error("No X509 client certificate was specified.")); if (!m_SSLIndexInitialized) { - m_SSLIndex = SSL_get_ex_new_index(0, (void *)"TlsClient", NULL, NULL, NULL); + m_SSLIndex = SSL_get_ex_new_index(0, const_cast("TlsClient"), NULL, NULL, NULL); m_SSLIndexInitialized = true; }