Solving some conversion and variable shadow warnings
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sat, 16 Jul 2011 22:36:20 +0000 (19:36 -0300)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Sat, 16 Jul 2011 22:36:20 +0000 (19:36 -0300)
lib/boost-custom/boost/asio/ip/tcp_raw_protocol.hpp
src/tcp/tcpheader.h

index 68fc07c..cd9a137 100644 (file)
@@ -108,8 +108,8 @@ public:
 
 private:
     // Construct with a specific family.
-    explicit tcp_raw_protocol( int family ) :
-        family_( family )
+    explicit tcp_raw_protocol( int fmly ) :
+        family_( fmly )
     {
     }
 
index adf07a0..6062771 100644 (file)
@@ -162,20 +162,22 @@ public:
     uint16_t calculate_tcp_checksum(
             uint32_t src_addr,
             uint32_t dest_addr,
-            char* payload_data,
-            uint16_t payload_size_in_bytes )
+            char* tcp_payload_data,
+            uint16_t tcp_payload_size_in_bytes )
     {
         checksum( 0 );
         uint16_t tcp_header_size_in_bytes = 20;
+        uint16_t tcp_segment_size_in_bytes = static_cast< uint16_t > (
+                tcp_header_size_in_bytes + tcp_payload_size_in_bytes
+        );
 
         PseudoIpv4Header pseudo_header;
         pseudo_header.source_address = htonl(src_addr);
         pseudo_header.destination_address = htonl(dest_addr);
         pseudo_header.zero_byte = 0;
         pseudo_header.protocol = IPPROTO_TCP;
-        pseudo_header.header_length = htons(
-                tcp_header_size_in_bytes + payload_size_in_bytes
-        );
+        pseudo_header.header_length = htons( tcp_segment_size_in_bytes );
+
         int pseudo_header_size_in_bytes = sizeof(PseudoIpv4Header);
 
         uint8_t tcp_buffer[65536];
@@ -185,11 +187,11 @@ public:
         memcpy( tcp_buffer + pseudo_header_size_in_bytes, rep_,
                 tcp_header_size_in_bytes );
         memcpy( tcp_buffer + pseudo_header_size_in_bytes + tcp_header_size_in_bytes,
-                payload_data, payload_size_in_bytes );
+                tcp_payload_data, tcp_payload_size_in_bytes );
 
         uint16_t cksum = calculate_checksum( (uint16_t *)
             tcp_buffer,
-            pseudo_header_size_in_bytes + tcp_header_size_in_bytes + payload_size_in_bytes
+            pseudo_header_size_in_bytes + tcp_header_size_in_bytes + tcp_payload_size_in_bytes
         );
 
         cksum = ntohs( cksum );
@@ -225,7 +227,7 @@ public:
 
     void header_length( uint8_t offset )
     {
-        uint8_t high_nimble = ( offset << 4 ) & 0xF0;
+        uint8_t high_nimble = static_cast<uint8_t>( ( offset << 4 ) & 0xF0 );
         uint8_t lower_nimble = ( rep_[12] & 0x0F );
         rep_[12] = high_nimble | lower_nimble;
     }
@@ -293,7 +295,7 @@ public:
 private:
     uint16_t decode( int a, int b ) const
     {
-        return (rep_[a] << 8) + rep_[b];
+        return static_cast<uint16_t>( (rep_[a] << 8) + rep_[b] );
     }
 
     void encode( int a, int b, uint16_t n )