From: Guilherme Maciel Ferreira Date: Sat, 24 Dec 2011 13:22:30 +0000 (-0200) Subject: PC-Lint warnings fixed: X-Git-Tag: v1.3~24 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=251ac6d0febbb849bcdb9a5b0e7217a8271db254;p=pingcheck PC-Lint warnings fixed: - Info 737: Loss of sign in promotion from int to unsigned int; - Info 713: Loss of precision (arg. no. 2) (unsigned int to int) in 'is.read( ..., PayloadSizeInBytes )' and 'os.write( ..., PayloadSizeInBytes )'. --- diff --git a/src/host/messagepayload.cpp b/src/host/messagepayload.cpp index ea2f2ea..0ae5155 100644 --- a/src/host/messagepayload.cpp +++ b/src/host/messagepayload.cpp @@ -201,7 +201,7 @@ uint16_t MessagePayload::decode16( BOOST_ASSERT( ( 0 <= left_byte ) && ( left_byte < static_cast(PayloadSizeInBytes) ) ); BOOST_ASSERT( ( 0 <= right_byte ) && ( right_byte < static_cast(PayloadSizeInBytes) ) ); BOOST_ASSERT( left_byte < right_byte ); - BOOST_ASSERT( ( ( right_byte - left_byte ) + 1 ) == sizeof(uint16_t) ); + BOOST_ASSERT( ( static_cast( right_byte - left_byte ) + 1 ) == sizeof(uint16_t) ); uint32_t value = static_cast( Payload[ left_byte ] << 8 ); value += static_cast( Payload[ right_byte ] ); @@ -230,7 +230,7 @@ void MessagePayload::encode16( BOOST_ASSERT( ( 0 <= left_byte ) && ( left_byte < static_cast(PayloadSizeInBytes) ) ); BOOST_ASSERT( ( 0 <= right_byte ) && ( right_byte < static_cast(PayloadSizeInBytes) ) ); BOOST_ASSERT( left_byte < right_byte ); - BOOST_ASSERT( ( ( right_byte - left_byte ) + 1 ) == sizeof(uint16_t) ); + BOOST_ASSERT( ( static_cast( right_byte - left_byte ) + 1 ) == sizeof(uint16_t) ); Payload[ left_byte ] = static_cast( value >> 8 ); Payload[ right_byte ] = static_cast( value & 0xFF ); @@ -253,7 +253,7 @@ uint32_t MessagePayload::decode32( BOOST_ASSERT( ( 0 <= first_byte ) && ( first_byte < static_cast(PayloadSizeInBytes) ) ); BOOST_ASSERT( ( 0 <= last_byte ) && ( last_byte < static_cast(PayloadSizeInBytes) ) ); BOOST_ASSERT( first_byte < last_byte ); - BOOST_ASSERT( ( ( last_byte - first_byte ) + 1 ) == sizeof(uint32_t) ); + BOOST_ASSERT( ( static_cast( last_byte - first_byte ) + 1 ) == sizeof(uint32_t) ); int current_byte = first_byte; @@ -287,7 +287,7 @@ void MessagePayload::encode32( BOOST_ASSERT( ( 0 < first_byte ) && ( first_byte < static_cast(PayloadSizeInBytes) ) ); BOOST_ASSERT( ( 0 < last_byte ) && ( last_byte < static_cast(PayloadSizeInBytes) ) ); BOOST_ASSERT( first_byte < last_byte ); - BOOST_ASSERT( ( ( last_byte - first_byte ) + 1 ) == sizeof(uint32_t) ); + BOOST_ASSERT( ( static_cast( last_byte - first_byte ) + 1 ) == sizeof(uint32_t) ); int current_byte = first_byte; @@ -313,7 +313,7 @@ istream& MessagePayload::read( istream &is ) char *payload_data_array = reinterpret_cast( Payload.get() ); - (void) is.read( payload_data_array, PayloadSizeInBytes ); + (void) is.read( payload_data_array, static_cast( PayloadSizeInBytes ) ); size_t data_received_in_bytes = static_cast( is.gcount() ); if ( data_received_in_bytes != PayloadSizeInBytes ) @@ -339,7 +339,7 @@ ostream& MessagePayload::write( ostream &os ) const const char *data_array = reinterpret_cast( Payload.get() ); - (void) os.write( data_array, PayloadSizeInBytes ); + (void) os.write( data_array, static_cast( PayloadSizeInBytes ) ); return os; }