]> granicus.if.org Git - icinga2/commitdiff
Fixed some more compiler warnings.
authorGunnar Beutner <gunnar@beutner.name>
Wed, 8 Aug 2012 06:34:15 +0000 (08:34 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Wed, 8 Aug 2012 06:34:15 +0000 (08:34 +0200)
base/component.cpp
base/dictionary.cpp
base/dictionary.h
base/dynamicobject.h
base/fifo.cpp
base/netstring.cpp
base/object.h
base/tcpclient.cpp
base/tcpsocket.cpp
base/tlsclient.cpp

index fbdc68a69385ed7950a9a18ad58a24de7a99cf90..a22a094c6ebacbc92486f1ee062537477c12d1ef 100644 (file)
@@ -59,15 +59,15 @@ Component::Component(const Dictionary::Ptr& properties)
        CreateComponentFunction pCreateComponent;
 
 #ifdef _WIN32
-       pCreateComponent = (CreateComponentFunction)GetProcAddress(hModule,
-           "CreateComponent");
+       pCreateComponent = reinterpret_cast<CreateComponentFunction>(GetProcAddress(hModule,
+           "CreateComponent"));
 #else /* _WIN32 */
 #      ifdef __GNUC__
        /* suppress compiler warning for void * cast */
        __extension__
 #      endif
-       pCreateComponent = (CreateComponentFunction)lt_dlsym(hModule,
-           "CreateComponent");
+       pCreateComponent = reinterpret_cast<CreateComponentFunction>(lt_dlsym(hModule,
+           "CreateComponent"));
 #endif /* _WIN32 */
 
        IComponent::Ptr impl;
index 432609d42a0f1cb72952bdffbac521294d75c4bd..8f42647b1f5d12da5f362cb935c4343a188f47ce 100644 (file)
@@ -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();
 }
index 63eb166dbf90033374ec5de6ba2066df0d98147c..bdfd2af61ad5fcb8ce264fa0b911b1ccd9e33aea 100644 (file)
@@ -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);
index 7e9546058441a5c85f85215bce217a5063c30b23..d0a459ca92a7a9fca8538be86205b963392312f2 100644 (file)
@@ -156,7 +156,7 @@ public:
 };
 
 #define REGISTER_CLASS(klass) \
-       static RegisterClassHelper g_Register ## klass(#klass, boost::make_shared<klass, const Dictionary::Ptr&>);
+       static RegisterClassHelper g_Register ## klass(#klass, boost::make_shared<klass, const Dictionary::Ptr&>)
 
 }
 
index e46c9f4d053f17c4b69d71542496725610e7c004..755bf1768c4ffbaa3ac1830a2672209b01a1b2cd 100644 (file)
@@ -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<char *>(realloc(m_Buffer, newSize));
 
        if (newBuffer == NULL)
                throw_exception(bad_alloc());
index f15c73f36ebb6f43334457e3c63a24dab68849c1..ff23cd275a143e386e058ca0d5b97da256e809d4 100644 (file)
@@ -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<char *>(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<char *>(realloc(buffer, buffer_length));
 
        if (new_buffer == NULL) {
                free(buffer);
index 59c469161bfb72bf4580726762008d02e6de68b2..6398938e25e03a8508f836a51fcd2c9717d563a5 100644 (file)
@@ -115,7 +115,7 @@ public:
         */
        bool operator()(const weak_ptr<T>& wref) const
        {
-               return (wref.lock().get() == (const T *)m_Ref);
+               return (wref.lock().get() == static_cast<const T *>(m_Ref));
        }
 };
 
index 14ac23fa22c4d40b02d93bd6092ab8ed857d2f1b..317897fd2b0e52ef69dbb9b18075e8f02b6ab8c8 100644 (file)
@@ -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()));
index 0ceedfa18a1d0a3bc5e8b65995f4b79e62beefb6..2e7bf3d2a34ef791c8f744b114a0b7f4ade13d01 100644 (file)
@@ -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<const char *>(&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<const char *>(&optTrue), sizeof(optTrue));
 #endif /* _WIN32 */
 
                int rc = bind(fd, info->ai_addr, info->ai_addrlen);
index 80eb61ca7e8b1fc5f87572ce6fae19dd290aa97f..d69b3e34504b0ab7f3625f35f8882a24bd6043a8 100644 (file)
@@ -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<char *>("TlsClient"), NULL, NULL, NULL);
                m_SSLIndexInitialized = true;
        }