BIND 10 trac2726, updated. b6f5648870e85b8451b624391ad22bcb04a219d2 [2726] Use empty() instead of size()

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Jun 17 13:57:59 UTC 2013


The branch, trac2726 has been updated
       via  b6f5648870e85b8451b624391ad22bcb04a219d2 (commit)
       via  43fae7e83655a6bdb1e1b57654436ffaa8fad8c2 (commit)
       via  007341505307a53b43802c747fe09435346bbf46 (commit)
       via  f57c476f33531dfdbffe892b0462338872f64870 (commit)
       via  7abee20ad8cfd20c3e33f58c414798276b48484b (commit)
      from  253dc4476ac2052dcd9af515ea4955b09c91cc7d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b6f5648870e85b8451b624391ad22bcb04a219d2
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date:   Mon Jun 17 15:54:19 2013 +0200

    [2726] Use empty() instead of size()
    
    To check if there's something inside.

commit 43fae7e83655a6bdb1e1b57654436ffaa8fad8c2
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date:   Mon Jun 17 15:43:55 2013 +0200

    [2726] Explicitly call the default constructor
    
    This is no difference in the code, as the default constructor would be
    called implicitly, but cppcheck warned about not calling one.

commit 007341505307a53b43802c747fe09435346bbf46
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date:   Mon Jun 17 15:39:29 2013 +0200

    [2726] Pass plain old C string
    
    This should prevent cppcheck from complaining on several places about
    passing c_str() as string argument. It is not possible to remove the
    c_str() from the macro, as it might be needed at other places. Putting
    the suppression at several places seems wrong, so this is the least ugly
    solution.

commit f57c476f33531dfdbffe892b0462338872f64870
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date:   Mon Jun 17 15:34:30 2013 +0200

    [2726] Use reference to avoid copy
    
    Not that it would make any difference with such small class, but
    cppcheck insists.

commit 7abee20ad8cfd20c3e33f58c414798276b48484b
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date:   Mon Jun 17 15:31:29 2013 +0200

    [2726] Remove unnecessary template parameters
    
    They are not needed, as it makes no sense to call constructor with
    different template parameter than one of the class being constructed.
    This also confused some versions of cppcheck and it thought there's no
    constructor available.

-----------------------------------------------------------------------

Summary of changes:
 src/bin/resolver/resolver.cc                  |    3 ++-
 src/lib/config/config_data.h                  |    2 +-
 src/lib/datasrc/tests/client_list_unittest.cc |    1 +
 src/lib/dns/message.h                         |    8 ++++----
 src/lib/dns/rdata/any_255/tsig_250.cc         |    8 ++++----
 src/lib/log/message_reader.cc                 |    2 +-
 6 files changed, 13 insertions(+), 11 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/resolver/resolver.cc b/src/bin/resolver/resolver.cc
index a3de340..41ed7af 100644
--- a/src/bin/resolver/resolver.cc
+++ b/src/bin/resolver/resolver.cc
@@ -524,7 +524,8 @@ ResolverImpl::processNormalQuery(const IOMessage& io_message,
 {
     const ConstQuestionPtr question = *query_message->beginQuestion();
     const RRType qtype = question->getType();
-    const RRClass qclass = question->getClass();
+    // Make cppcheck happy with the reference.
+    const RRClass& qclass = question->getClass();
 
     // Apply query ACL
     const Client client(io_message);
diff --git a/src/lib/config/config_data.h b/src/lib/config/config_data.h
index e40600d..bcc97de 100644
--- a/src/lib/config/config_data.h
+++ b/src/lib/config/config_data.h
@@ -29,7 +29,7 @@ namespace config {
 /// point to anything defined in the .spec file)
 class DataNotFoundError : public isc::Exception {
 public:
-    DataNotFoundError(const char* file, size_t line, const std::string& what) :
+    DataNotFoundError(const char* file, size_t line, const char* what) :
         isc::Exception(file, line, what) {}
 };
 
diff --git a/src/lib/datasrc/tests/client_list_unittest.cc b/src/lib/datasrc/tests/client_list_unittest.cc
index acffd23..5b173a9 100644
--- a/src/lib/datasrc/tests/client_list_unittest.cc
+++ b/src/lib/datasrc/tests/client_list_unittest.cc
@@ -125,6 +125,7 @@ public:
         rrclass_(RRClass::IN()),
         // The empty list corresponds to a list with no elements inside
         list_(new TestedList(rrclass_)),
+        negative_result_(),
         config_elem_(Element::fromJSON("["
             "{"
             "   \"type\": \"test_type\","
diff --git a/src/lib/dns/message.h b/src/lib/dns/message.h
index 8aaaa48..1c83e1e 100644
--- a/src/lib/dns/message.h
+++ b/src/lib/dns/message.h
@@ -98,10 +98,10 @@ struct SectionIteratorImpl;
 template <typename T>
 class SectionIterator : public std::iterator<std::input_iterator_tag, T> {
 public:
-    SectionIterator<T>() : impl_(NULL) {}
-    SectionIterator<T>(const SectionIteratorImpl<T>& impl);
-    ~SectionIterator<T>();
-    SectionIterator<T>(const SectionIterator<T>& source);
+    SectionIterator() : impl_(NULL) {}
+    SectionIterator(const SectionIteratorImpl<T>& impl);
+    ~SectionIterator();
+    SectionIterator(const SectionIterator<T>& source);
     void operator=(const SectionIterator<T>& source);
     SectionIterator<T>& operator++();
     SectionIterator<T> operator++(int);
diff --git a/src/lib/dns/rdata/any_255/tsig_250.cc b/src/lib/dns/rdata/any_255/tsig_250.cc
index 43cce7a..796e320 100644
--- a/src/lib/dns/rdata/any_255/tsig_250.cc
+++ b/src/lib/dns/rdata/any_255/tsig_250.cc
@@ -370,13 +370,13 @@ TSIG::toText() const {
         lexical_cast<string>(impl_->time_signed_) + " " +
         lexical_cast<string>(impl_->fudge_) + " " +
         lexical_cast<string>(impl_->mac_.size()) + " ";
-    if (impl_->mac_.size() > 0) {
+    if (!impl_->mac_.empty()) {
         result += encodeBase64(impl_->mac_) + " ";
     }
     result += lexical_cast<string>(impl_->original_id_) + " ";
     result += TSIGError(impl_->error_).toText() + " ";
     result += lexical_cast<string>(impl_->other_data_.size());
-    if (impl_->other_data_.size() > 0) {
+    if (!impl_->other_data_.empty()) {
         result += " " + encodeBase64(impl_->other_data_);
     }
 
@@ -520,7 +520,7 @@ TSIG::getMACSize() const {
 
 const void*
 TSIG::getMAC() const {
-    if (impl_->mac_.size() > 0) {
+    if (!impl_->mac_.empty()) {
         return (&impl_->mac_[0]);
     } else {
         return (NULL);
@@ -544,7 +544,7 @@ TSIG::getOtherLen() const {
 
 const void*
 TSIG::getOtherData() const {
-    if (impl_->other_data_.size() > 0) {
+    if (!impl_->other_data_.empty()) {
         return (&impl_->other_data_[0]);
     } else {
         return (NULL);
diff --git a/src/lib/log/message_reader.cc b/src/lib/log/message_reader.cc
index b5a4d35..d54c41d 100644
--- a/src/lib/log/message_reader.cc
+++ b/src/lib/log/message_reader.cc
@@ -127,7 +127,7 @@ void
 MessageReader::parsePrefix(const vector<string>& tokens) {
 
     // Should not get here unless there is something in the tokens array.
-    assert(tokens.size() > 0);
+    assert(!tokens.empty());
 
     // Process $PREFIX.  With no arguments, the prefix is set to the empty
     // string.  One argument sets the prefix to the to its value and more than



More information about the bind10-changes mailing list