From ba310c6917c7dd03fcbffa3de9ea28828601ee5a Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Wed, 21 Dec 2011 07:56:43 -0200 Subject: [PATCH] PC-Lint warnings fixed: - Info 766: Header file 'limits' not used in module; - Warning 534: Ignoring return value of functions 'MessagePayload::read(...)' and 'std::basic_istream::read(char *, int)'; - Info 737: Loss of sign in promotion from int to unsigned int; - Info 713: Loss of precision (initialization) (unsigned int to int); - Info 732: Loss of sign (arg. no. 2) (int to unsigned int) in 'header.Payload.append( options_data.get(), options_length )'. --- src/ip/ipv4header.cpp | 20 ++++++++++++-------- 1 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/ip/ipv4header.cpp b/src/ip/ipv4header.cpp index e8e2cbf..7c13490 100644 --- a/src/ip/ipv4header.cpp +++ b/src/ip/ipv4header.cpp @@ -6,13 +6,14 @@ // http://www.boost.org/LICENSE_1_0.txt) #include "ip/ipv4header.h" -#include - #include +#include + using namespace std; using boost::asio::ip::address_v4; using boost::scoped_array; +using I2n::Logger::GlobalLogger; //----------------------------------------------------------------------------- // Ipv4Header @@ -214,29 +215,32 @@ istream &operator>>( { // read the first 20 bytes (mandatory for IP header) from the input stream // and stores in the buffer object - header.Payload.read( is ); + (void) header.Payload.read( is ); if ( header.get_version() != 4 ) { + GlobalLogger.error() << "Error: invalid IP header version." << endl; is.setstate( ios::failbit ); } // read the consecutive N bytes (for options field) from the input stream // and stores in the buffer object - streamsize options_length = (streamsize) header.get_header_length() - - Ipv4HeaderSizeInBytes; + streamsize options_length = static_cast( header.get_header_length() ) - + static_cast( Ipv4HeaderSizeInBytes ); if ( ( options_length < 0 ) || ( 40 < options_length ) ) { + GlobalLogger.error() << "Error: invalid IP options length value." << endl; is.setstate( ios::failbit ); } else { - scoped_array options_data(new uint8_t[options_length]); + size_t options_size = static_cast( options_length ); + scoped_array options_data( new uint8_t[options_size] ); char *options_data_array = reinterpret_cast( options_data.get() ); - is.read( options_data_array, options_length ); + (void) is.read( options_data_array, options_length ); - header.Payload.append( options_data.get(), options_length ); + header.Payload.append( options_data.get(), options_size ); } return is; -- 1.7.1