PC-Lint warnings fixed:
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 20 Dec 2011 09:53:25 +0000 (07:53 -0200)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 20 Dec 2011 09:53:25 +0000 (07:53 -0200)
- 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<char> &) const';
- Info 731: Boolean argument to equal/not equal;

src/icmp/icmppinger.cpp
src/tcp/tcppinger.cpp

index f326385..720959d 100644 (file)
@@ -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;
 
index cde82a6..d51defa 100644 (file)
@@ -115,12 +115,12 @@ TcpPinger::~TcpPinger()
  */
 void TcpPinger::ping(
         const string &destination_ip,
-        const int destination_port,
+        const uint16_t destination_port,
         function<void(bool)> ping_done_callback
 )
 {
     BOOST_ASSERT( !destination_ip.empty() );
-    BOOST_ASSERT( ( 0 <= destination_port ) && ( destination_port < numeric_limits<uint16_t>::max() ) );
+    BOOST_ASSERT( ( 0 < destination_port ) && ( destination_port < numeric_limits<uint16_t>::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<uint16_t>::max() ) );
+    BOOST_ASSERT( ( 0 < destination_port ) && ( destination_port < numeric_limits<uint16_t>::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;