Fix: suppress the warning about dereferencing type-punned pointer that break strict...
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 21 Feb 2012 03:21:40 +0000 (01:21 -0200)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 21 Feb 2012 03:21:40 +0000 (01:21 -0200)
lib/boost-net-dns/boost/net/network_array.hpp

index 7a0b7ac..198ada7 100755 (executable)
@@ -61,7 +61,7 @@ public:
     nap(0),
     nal(0)
   {
-    data_array.assign((uint8_t)0x00);
+    data_array.assign(static_cast<uint8_t>(0x00));
   }
 
   virtual ~network_array()
@@ -106,7 +106,7 @@ public:
       position(p);
     }
 
-    d = (char)data_array.elems[nap];
+    d = static_cast<char>(data_array.elems[nap]);
     if( incpos ) nap += sizeof(d);
 
     return sizeof(d);
@@ -128,7 +128,7 @@ public:
       position(p);
     }
 
-    data_array.elems[nap] = (uint8_t)d;
+    data_array.elems[nap] = static_cast<uint8_t>(d);
     if( incpos )
     {
       nap += sizeof(d);
@@ -157,7 +157,10 @@ public:
 
     d = data_array.elems[nap];
 
-    if( incpos ) nap += sizeof(d);
+    if( incpos )
+    {
+        nap += sizeof(d);
+    }
     return sizeof(d);
   }
 
@@ -183,7 +186,9 @@ public:
     {
       nap += sizeof(d);
       if( nap > nal )
+      {
         nal += sizeof(d);
+      }
     }
 
     return sizeof(d);
@@ -205,7 +210,8 @@ public:
       position(p);
     }
 
-    d = ntohs( *((uint16_t *)&data_array.elems[nap]) );
+    uint16_t *data = reinterpret_cast<uint16_t *>(&data_array.elems[nap]);
+    d = ntohs( *data );
 
     if( incpos ) nap += sizeof(d);
     return sizeof(d);
@@ -227,7 +233,8 @@ public:
       position(p);
     }
 
-    *((uint16_t *)&data_array.elems[nap]) = htons(d);
+    uint16_t *data = reinterpret_cast<uint16_t *>(&data_array.elems[nap]);
+    *data = htons(d);
 
     if( incpos )
     {
@@ -255,7 +262,8 @@ public:
       position(p);
     }
 
-    d = ntohl( *((uint32_t *)&data_array.elems[nap]) );
+    uint32_t *data = reinterpret_cast<uint32_t *>(&data_array.elems[nap]);
+    d = ntohl( *data );
 
     if( incpos ) nap += sizeof(d);
     return sizeof(d);
@@ -277,7 +285,8 @@ public:
       position(p);
     }
 
-    *((uint32_t *)&data_array.elems[nap]) = htonl(d);
+    uint32_t *data = reinterpret_cast<uint32_t *>(&data_array.elems[nap]);
+    *data = htonl(d);
 
     if( incpos )
     {
@@ -305,7 +314,8 @@ public:
       position(p);
     }
 
-    d = ip::address_v4( ntohl( *((uint32_t *)&data_array.elems[nap]) ) );
+    uint32_t *data = reinterpret_cast<uint32_t *>(&data_array.elems[nap]);
+    d = ip::address_v4( ntohl( *data ) );
 
     if( incpos ) nap += sizeof(uint32_t);
     return sizeof(d);
@@ -327,9 +337,8 @@ public:
       position(p);
     }
 
-    *((uint32_t *)&data_array.elems[nap]) = htonl(
-            static_cast<uint32_t> (d.to_ulong())
-    );
+    uint32_t *data = reinterpret_cast<uint32_t *>(&data_array.elems[nap]);
+    *data = htonl(static_cast<uint32_t> (d.to_ulong()));
 
     if( incpos )
     {
@@ -414,7 +423,7 @@ public:
     }
 
     scoped_array<char> cPtr( new char[len + 1] );
-    strncpy( cPtr.get(), (char*)&data_array.elems[nap], len);
+    strncpy( cPtr.get(), reinterpret_cast<char*>(&data_array.elems[nap]), len);
     cPtr.get()[len] = 0x00;
     d = cPtr.get();