From: Guilherme Maciel Ferreira Date: Tue, 20 Dec 2011 09:08:30 +0000 (-0200) Subject: PC-Lint warnings fixed: X-Git-Tag: v1.3~35 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=6e9bbd840219c5cbf138311fbedc0938164766bc;p=pingcheck PC-Lint warnings fixed: - 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 '->'; --- diff --git a/src/dns/dnsresolver.cpp b/src/dns/dnsresolver.cpp index c1f127a..0469ace 100644 --- a/src/dns/dnsresolver.cpp +++ b/src/dns/dnsresolver.cpp @@ -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 *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 ( 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; + } } } diff --git a/src/dns/dnsresolver.h b/src/dns/dnsresolver.h index 030c3e2..62fcd23 100644 --- a/src/dns/dnsresolver.h +++ b/src/dns/dnsresolver.h @@ -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 *resolved_host_address_list - ); + ) const; private: /// The list of IPs available to the host DNS.