Parcourir la source

[trac493] Fix some coding style problems

Ocean Wang il y a 14 ans
Parent
commit
c0cec07920
2 fichiers modifiés avec 23 ajouts et 25 suppressions
  1. 18 18
      src/lib/cache/message_entry.cc
  2. 5 7
      src/lib/cache/resolver_cache.cc

+ 18 - 18
src/lib/cache/message_entry.cc

@@ -82,7 +82,7 @@ MessageEntry::addRRset(isc::dns::Message& message,
         end_index = start_index + additional_count_;
     }
 
-    for(uint16_t index = start_index; index < end_index; ++index) {
+    for (uint16_t index = start_index; index < end_index; ++index) {
         message.addRRset(section, rrset_entry_vec[index]->getRRset(), dnssec_need);
     }
 }
@@ -235,9 +235,9 @@ MessageEntry::parseNegativeResponseAuthoritySection(const isc::dns::Message& msg
 
     // We found the SOA record, so we can cache the message and RRsets in the cache
     uint16_t count = 0;
-    for(RRsetIterator iter = msg.beginSection(Message::SECTION_AUTHORITY);
+    for (RRsetIterator iter = msg.beginSection(Message::SECTION_AUTHORITY);
             iter != msg.endSection(Message::SECTION_AUTHORITY);
-            ++iter){
+            ++iter) {
         RRsetPtr rrset_ptr = *iter;
         RRsetTrustLevel level = getRRsetTrustLevel(msg, rrset_ptr, Message::SECTION_AUTHORITY);
         uint32_t rrset_ttl = 0;
@@ -283,7 +283,7 @@ MessageEntry::initMessageEntry(const isc::dns::Message& msg) {
         uint16_t rrset_count = 0;
 
         // For negative response, if no soa RRset is found in authority section, dont cache it
-        if(!hasTheRecordInAuthoritySection(msg, RRType::SOA())){
+        if (!hasTheRecordInAuthoritySection(msg, RRType::SOA())) {
             return;
         }
 
@@ -301,35 +301,35 @@ MessageEntry::initMessageEntry(const isc::dns::Message& msg) {
 bool
 MessageEntry::isNegativeResponse(const isc::dns::Message& msg)
 {
-    if(msg.getRcode() == Rcode::NXDOMAIN()){
-        return true;
-    } else if (msg.getRcode() == Rcode::NOERROR()){
+    if (msg.getRcode() == Rcode::NXDOMAIN()) {
+        return (true);
+    } else if (msg.getRcode() == Rcode::NOERROR()) {
         // no data in the answer section
-        if (msg.getRRCount(Message::SECTION_ANSWER) == 0){
+        if (msg.getRRCount(Message::SECTION_ANSWER) == 0) {
             // NODATA type 1/ type 2 (ref sec2.2 of RFC2308) 
-            if(hasTheRecordInAuthoritySection(msg, RRType::SOA())){
-                return true;
-            } else if (!hasTheRecordInAuthoritySection(msg, RRType::NS())){ // NODATA type 3 (sec2.2 of RFC2308)
-                return true;
+            if (hasTheRecordInAuthoritySection(msg, RRType::SOA())) {
+                return (true);
+            } else if (!hasTheRecordInAuthoritySection(msg, RRType::NS())) { // NODATA type 3 (sec2.2 of RFC2308)
+                return (true);
             }
         }
     }
 
-    return false;
+    return (false);
 }
 
 bool
 MessageEntry::hasTheRecordInAuthoritySection(const isc::dns::Message& msg, const isc::dns::RRType& type)
 {
-    for(RRsetIterator iter = msg.beginSection(Message::SECTION_AUTHORITY);
+    for (RRsetIterator iter = msg.beginSection(Message::SECTION_AUTHORITY);
             iter != msg.endSection(Message::SECTION_AUTHORITY);
-            ++iter){
+            ++iter) {
         RRsetPtr rrset_ptr = *iter;
-        if (rrset_ptr->getType() == type){
-            return true;
+        if (rrset_ptr->getType() == type) {
+            return (true);
         }
     }
-    return false;
+    return (false);
 }
 
 } // namespace cache

+ 5 - 7
src/lib/cache/resolver_cache.cc

@@ -35,8 +35,7 @@ ResolverClassCache::ResolverClassCache(const RRClass& cache_class) :
     rrsets_cache_ = RRsetCachePtr(new RRsetCache(RRSET_CACHE_DEFAULT_SIZE,
                                                  cache_class_.getCode()));
     // SOA rrset cache from negative response
-    negative_soa_cache_ = RRsetCachePtr(new
-                        RRsetCache(NEGATIVE_RRSET_CACHE_DEFAULT_SIZE, cache_class_.getCode()));
+    negative_soa_cache_ = RRsetCachePtr(new RRsetCache(NEGATIVE_RRSET_CACHE_DEFAULT_SIZE, cache_class_.getCode()));
 
     messages_cache_ = MessageCachePtr(new MessageCache(rrsets_cache_,
                                       MESSAGE_CACHE_DEFAULT_SIZE,
@@ -52,8 +51,7 @@ ResolverClassCache::ResolverClassCache(CacheSizeInfo cache_info) :
     rrsets_cache_ = RRsetCachePtr(new
                         RRsetCache(cache_info.rrset_cache_size, klass));
     // SOA rrset cache from negative response
-    negative_soa_cache_ = RRsetCachePtr(new
-                        RRsetCache(cache_info.rrset_cache_size, klass));
+    negative_soa_cache_ = RRsetCachePtr(new RRsetCache(cache_info.rrset_cache_size, klass));
 
     messages_cache_ = MessageCachePtr(new MessageCache(rrsets_cache_,
                                       cache_info.message_cache_size,
@@ -62,7 +60,7 @@ ResolverClassCache::ResolverClassCache(CacheSizeInfo cache_info) :
 
 const RRClass&
 ResolverClassCache::getClass() const {
-    return cache_class_;
+    return (cache_class_);
 }
 
 bool
@@ -243,10 +241,10 @@ ResolverClassCache*
 ResolverCache::getClassCache(const isc::dns::RRClass& cache_class) const {
     for (int i = 0; i < class_caches_.size(); ++i) {
         if (class_caches_[i]->getClass() == cache_class) {
-            return class_caches_[i];
+            return (class_caches_[i]);
         }
     }
-    return NULL;
+    return (NULL);
 }
 
 } // namespace cache