From: Guilherme Maciel Ferreira Date: Tue, 20 Dec 2011 09:53:25 +0000 (-0200) Subject: PC-Lint warnings fixed: X-Git-Tag: v1.3~32 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=080ca508299e78d25ea72a1addc8a9046478df2d;p=pingcheck PC-Lint warnings fixed: - Warning 574: Signed-unsigned mix with relational; - Info 737: Loss of sign in promotion from int to unsigned int; - Warning 534: Ignoring return value of function 'IcmpPacket/TcpSegment::write(std::basic_ostream &) const'; - Info 731: Boolean argument to equal/not equal; --- diff --git a/src/icmp/icmppinger.cpp b/src/icmp/icmppinger.cpp index f326385..720959d 100644 --- a/src/icmp/icmppinger.cpp +++ b/src/icmp/icmppinger.cpp @@ -99,7 +99,7 @@ IcmpPinger::~IcmpPinger() */ void IcmpPinger::ping( const string &destination_ip, - const int /*destination_port*/, // the ICMP protocol does not use ports + const uint16_t /*destination_port*/, // the ICMP protocol does not use ports function< void(bool) > ping_done_callback ) { @@ -140,7 +140,10 @@ void IcmpPinger::send_echo_request( const IcmpPacketItem icmp_packet ) { boost::asio::streambuf request_buffer; ostream os( &request_buffer ); - icmp_packet->write( os ); + if ( !icmp_packet->write( os ) ) + { + GlobalLogger.error() << "Error: fail writing ping data." << endl; + } TimeSent = microsec_clock::universal_time(); @@ -188,7 +191,7 @@ void IcmpPinger::handle_ping_done() { // Check ReplyReceived as the timer handler // is also called by Timer.cancel(); - if ( ReplyReceived == false ) + if ( !ReplyReceived ) { GlobalLogger.info() << "Request timed out" << endl; diff --git a/src/tcp/tcppinger.cpp b/src/tcp/tcppinger.cpp index cde82a6..d51defa 100644 --- a/src/tcp/tcppinger.cpp +++ b/src/tcp/tcppinger.cpp @@ -115,12 +115,12 @@ TcpPinger::~TcpPinger() */ void TcpPinger::ping( const string &destination_ip, - const int destination_port, + const uint16_t destination_port, function ping_done_callback ) { BOOST_ASSERT( !destination_ip.empty() ); - BOOST_ASSERT( ( 0 <= destination_port ) && ( destination_port < numeric_limits::max() ) ); + BOOST_ASSERT( ( 0 < destination_port ) && ( destination_port < numeric_limits::max() ) ); PingDoneCallback = ping_done_callback; @@ -157,11 +157,11 @@ uint16_t TcpPinger::get_destination_port() const void TcpPinger::set_destination_endpoint( const string &destination_ip, - const int destination_port + const uint16_t destination_port ) { BOOST_ASSERT( !destination_ip.empty() ); - BOOST_ASSERT( ( 0 <= destination_port ) && ( destination_port <= numeric_limits::max() ) ); + BOOST_ASSERT( ( 0 < destination_port ) && ( destination_port < numeric_limits::max() ) ); BOOST_STATIC_ASSERT( sizeof(uint16_t) <= sizeof(destination_port) ); address destination_address = address::from_string( destination_ip ); @@ -191,7 +191,10 @@ void TcpPinger::send_ack_request( const TcpSegmentItem tcp_segment ) // Encode the request packet. boost::asio::streambuf request_buffer; ostream os( &request_buffer ); - tcp_segment->write( os ); + if ( !tcp_segment->write( os ) ) + { + GlobalLogger.error() << "Error: fail writing ping data." << endl; + } TimeSent = microsec_clock::universal_time(); @@ -242,7 +245,7 @@ void TcpPinger::handle_ping_done() { // Check ReceivedReply as the timer handler // is also called by Timer.cancel(); - if ( ReceivedReply == false ) + if ( !ReceivedReply ) { GlobalLogger.info() << "Request timed out" << endl;