From: Guilherme Maciel Ferreira Date: Tue, 21 Feb 2012 03:21:40 +0000 (-0200) Subject: Fix: suppress the warning about dereferencing type-punned pointer that break strict... X-Git-Tag: v1.3~1 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=aafde4f869c9a119bfb44e54961d7ac93804d995;p=pingcheck Fix: suppress the warning about dereferencing type-punned pointer that break strict-aliasing rules. --- diff --git a/lib/boost-net-dns/boost/net/network_array.hpp b/lib/boost-net-dns/boost/net/network_array.hpp index 7a0b7ac..198ada7 100755 --- a/lib/boost-net-dns/boost/net/network_array.hpp +++ b/lib/boost-net-dns/boost/net/network_array.hpp @@ -61,7 +61,7 @@ public: nap(0), nal(0) { - data_array.assign((uint8_t)0x00); + data_array.assign(static_cast(0x00)); } virtual ~network_array() @@ -106,7 +106,7 @@ public: position(p); } - d = (char)data_array.elems[nap]; + d = static_cast(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(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(&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(&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(&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(&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(&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 (d.to_ulong()) - ); + uint32_t *data = reinterpret_cast(&data_array.elems[nap]); + *data = htonl(static_cast (d.to_ulong())); if( incpos ) { @@ -414,7 +423,7 @@ public: } scoped_array cPtr( new char[len + 1] ); - strncpy( cPtr.get(), (char*)&data_array.elems[nap], len); + strncpy( cPtr.get(), reinterpret_cast(&data_array.elems[nap]), len); cPtr.get()[len] = 0x00; d = cPtr.get();