PC-Lint warnings fixed:
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 20 Dec 2011 09:08:30 +0000 (07:08 -0200)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 20 Dec 2011 09:08:30 +0000 (07:08 -0200)
- Info 713: Loss of precision (initialization) (unsigned int to int) of 'resolved_ip_count' and 'current_ttl';
- Info 1762: Member function 'DnsResolver::fill_answers_list(...)' could be made const;
- Info 1762: Member function 'DnsResolver::fill_resolved_ip_list(...)' could be made const;
- Warning 578: Declaration of symbol 'ip' hides symbol 'boost::asio::ip';
- Warning 613: Possible use of null pointer 'a_rr' in left argument to operator '->';

src/dns/dnsresolver.cpp
src/dns/dnsresolver.h

index c1f127a..0469ace 100644 (file)
@@ -90,7 +90,7 @@ bool DnsResolver::resolve()
     {
         rr_list_t answers_list = fill_answers_list( HostDnsAddress, NameServer);
 
-        int resolved_ip_count = answers_list.size();
+        size_t resolved_ip_count = answers_list.size();
         if ( resolved_ip_count < 1 )
         {
             GlobalLogger.error() << "Error: host "
@@ -219,7 +219,8 @@ bool DnsResolver::handle_ip_address()
 
 rr_list_t DnsResolver::fill_answers_list(
         const string &host_dns_address,
-        const string &name_server)
+        const string &name_server
+) const
 {
     BOOST_ASSERT( !host_dns_address.empty() );
     BOOST_ASSERT( !name_server.empty() );
@@ -236,7 +237,7 @@ rr_list_t DnsResolver::fill_answers_list(
 void DnsResolver::fill_resolved_ip_list(
         const rr_list_t& answers_list,
         list<HostAddress> *resolved_host_address_list
-)
+) const
 {
     BOOST_ASSERT( 1 <= answers_list.size() );
     BOOST_ASSERT( resolved_host_address_list != NULL );
@@ -249,14 +250,17 @@ void DnsResolver::fill_resolved_ip_list(
             a_resource *a_rr = dynamic_cast<a_resource *> (
                     resource_record.get()
             );
-            string ip = a_rr->address().to_string();
-            int ttl = a_rr->ttl();
+            if ( a_rr != NULL )
+            {
+                string current_ip = a_rr->address().to_string();
+                uint32_t current_ttl = a_rr->ttl();
 
-            HostAddress resolved_host( ip, ttl );
-            resolved_host_address_list->push_back( resolved_host );
+                HostAddress resolved_host( current_ip, current_ttl );
+                resolved_host_address_list->push_back( resolved_host );
 
-            GlobalLogger.info() << "- " << ip
-                    << " [" << ttl << "s]" << endl;
+                GlobalLogger.info() << "- " << current_ip
+                        << " [" << current_ttl << "s]" << endl;
+            }
         }
     }
 
index 030c3e2..62fcd23 100644 (file)
@@ -54,11 +54,11 @@ private:
     boost::net::dns::rr_list_t fill_answers_list(
             const std::string &host_dns_address,
             const std::string &name_server
-    );
+    ) const;
     void fill_resolved_ip_list(
             const boost::net::dns::rr_list_t& answers_list,
             std::list<HostAddress> *resolved_host_address_list
-    );
+    ) const;
 
 private:
     /// The list of IPs available to the host DNS.