PC-Lint warnings fixed:
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 20 Dec 2011 09:38:53 +0000 (07:38 -0200)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 20 Dec 2011 09:38:53 +0000 (07:38 -0200)
- Warning 574: Signed-unsigned mix with relational;
- Info 737: Loss of sign in promotion from int to unsigned int;

src/host/pinger.h
src/host/pingscheduler.cpp
src/host/pingscheduler.h
src/icmp/icmppinger.h
src/main.cpp
src/tcp/tcppinger.h

index c530ef6..c697449 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef PINGER_H
 #define PINGER_H
 
+#include <stdint.h>
+
 #include <string>
 
 #include <boost/function.hpp>
@@ -37,15 +39,16 @@ class Pinger
 public:
     virtual void ping(
             const std::string &destination_ip,
-            const int destination_port,
+            const uint16_t destination_port,
             boost::function<void(bool)> ping_done_callback
     ) = 0;
 
 protected:
     Pinger();
-    Pinger( const Pinger &other );
     virtual ~Pinger();
 
+private:
+    Pinger( const Pinger &other );
     Pinger& operator=( const Pinger &other );
 
 };
index 9f52a98..0182f08 100644 (file)
@@ -48,7 +48,7 @@ using I2n::Logger::GlobalLogger;
 PingScheduler::PingScheduler(
         const string &network_interface,
         const string &destination_address,
-        const int destination_port,
+        const uint16_t destination_port,
         const PingProtocol ping_protocol,
         const long ping_interval_in_sec,
         const int ping_fail_percentage_limit,
@@ -149,11 +149,11 @@ bool PingScheduler::resolve_ping_address()
 
 void PingScheduler::ping(
         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() ) );
 
     Ping->ping(
             destination_ip,
index 5a325f5..dddd903 100644 (file)
@@ -20,6 +20,8 @@ on this file might be covered by the GNU General Public License.
 #ifndef PINGSCHEDULER_H
 #define PINGSCHEDULER_H
 
+#include <stdint.h>
+
 #include <string>
 #include <vector>
 
@@ -51,7 +53,7 @@ public:
     PingScheduler(
             const std::string &network_interface,
             const std::string &destination_address,
-            const int destination_port,
+            const uint16_t destination_port,
             const PingProtocol ping_protocol,
             const long ping_interval_in_sec,
             const int ping_fail_percentage_limit,
@@ -71,7 +73,7 @@ private:
     bool resolve_ping_address();
     void ping(
             const std::string &destination_ip,
-            const int destination_port
+            const uint16_t destination_port
     );
     void ping_done_handler(bool ping_success);
 
@@ -96,7 +98,7 @@ private:
     /// The list of IPs which are aliases to the host DNS
     DnsResolver IpList;
     /// The port to ping at destination host
-    int DestinationPort;
+    uint16_t DestinationPort;
     /// Object responsible to evaluate the status of the host
     HostStatusAnalyzer HostAnalyzer;
     /// Internal boost pinger object
index bb0f17f..f92b33b 100644 (file)
@@ -7,6 +7,8 @@
 #ifndef ICMP_PINGER_H
 #define ICMP_PINGER_H
 
+#include <stdint.h>
+
 #include <string>
 
 #include <boost/asio.hpp>
@@ -38,7 +40,7 @@ public:
 
     virtual void ping(
             const std::string &destination_ip,
-            const int destination_port,
+            const uint16_t destination_port,
             boost::function< void(bool) > ping_done_callback
     );
 
index 15df1a7..7577915 100644 (file)
@@ -18,6 +18,7 @@ This exception does not invalidate any other reasons why a work based
 on this file might be covered by the GNU General Public License.
 */
 #include <signal.h>
+#include <stdint.h>
 
 #include <vector>
 #include <iostream>
@@ -103,7 +104,7 @@ void init_pingers(
     BOOST_FOREACH( HostItem host, hosts )
     {
         string destination_address = host->get_address();
-        int destination_port = host->get_port();
+        uint16_t destination_port = host->get_port();
         int ping_interval_in_sec = host->get_interval_in_sec();
         PingSchedulerItem scheduler(
                 new PingScheduler(
index 1fdbf4e..96247b0 100644 (file)
@@ -20,6 +20,8 @@ on this file might be covered by the GNU General Public License.
 #ifndef TCP_PINGER_H
 #define TCP_PINGER_H
 
+#include <stdint.h>
+
 #include <string>
 
 #include <boost/asio.hpp>
@@ -52,7 +54,7 @@ public:
 
     virtual void ping(
             const std::string &destination_ip,
-            const int destination_port,
+            const uint16_t destination_port,
             boost::function<void(bool)> ping_done_callback
     );
 
@@ -65,7 +67,7 @@ private:
 
     void set_destination_endpoint(
             const std::string &destination_ip,
-            const int destination_port
+            const uint16_t destination_port
     );
 
     void start_send();