]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Whitespace & cleanup
authorFred Morcos <fred.morcos@open-xchange.com>
Wed, 18 May 2022 11:51:39 +0000 (13:51 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Mon, 13 Jun 2022 12:24:23 +0000 (14:24 +0200)
ext/lmdb-safe/lmdb-safe.hh
ext/lmdb-safe/lmdb-typed.hh
pdns/dnsname.hh
pdns/dnsparser.hh
pdns/packetcache.hh
pdns/reczones.cc
pdns/syncres.hh

index 33bfa8f131202de4bd2f74771a9b206197569ab1..c900fccd4cb675cce2c3a49b728e05c5ad12379c 100644 (file)
@@ -1,4 +1,5 @@
 #pragma once
+#include <string_view>
 #include <lmdb.h>
 #include <iostream>
 #include <fstream>
@@ -17,14 +18,14 @@ using std::string_view;
 /* open issues:
  *
  * - missing convenience functions (string_view, string)
- */ 
+ */
 
 /*
 The error strategy. Anything that "should never happen" turns into an exception. But things like 'duplicate entry' or 'no such key' are for you to deal with.
  */
 
 /*
-  Thread safety: we are as safe as lmdb. You can talk to MDBEnv from as many threads as you want 
+  Thread safety: we are as safe as lmdb. You can talk to MDBEnv from as many threads as you want
 */
 
 /** MDBDbi is our only 'value type' object, as 1) a dbi is actually an integer
@@ -35,13 +36,13 @@ public:
   MDBDbi(): d_dbi(-1)
   {
   }
-  explicit MDBDbi(MDB_env* env, MDB_txn* txn, string_view dbname, int flags);  
+  explicit MDBDbi(MDB_env* env, MDB_txn* txn, string_view dbname, int flags);
 
   operator const MDB_dbi&() const
   {
     return d_dbi;
   }
-  
+
   MDB_dbi d_dbi;
 };
 
@@ -64,7 +65,7 @@ public:
   }
 
   MDBDbi openDB(const string_view dbname, int flags);
-  
+
   MDBRWTransaction getRWTransaction();
   MDBROTransaction getROTransaction();
 
@@ -106,7 +107,7 @@ struct MDBOutVal
     T ret;
     if(d_mdbval.mv_size != sizeof(T))
       throw std::runtime_error("MDB data has wrong length for type");
-    
+
     memcpy(&ret, d_mdbval.mv_data, sizeof(T));
     return ret;
   }
@@ -121,7 +122,7 @@ struct MDBOutVal
     T ret;
     if(d_mdbval.mv_size != sizeof(T))
       throw std::runtime_error("MDB data has wrong length for type");
-    
+
     memcpy(&ret, d_mdbval.mv_data, sizeof(T));
     return ret;
   }
@@ -131,11 +132,11 @@ struct MDBOutVal
   {
     if(d_mdbval.mv_size != sizeof(T))
       throw std::runtime_error("MDB data has wrong length for type");
-    
+
     return reinterpret_cast<const T*>(d_mdbval.mv_data);
   }
-  
-  
+
+
   MDB_val d_mdbval;
 };
 
@@ -159,7 +160,7 @@ public:
   template <class T,
             typename std::enable_if<std::is_arithmetic<T>::value,
                                     T>::type* = nullptr>
-  MDBInVal(T i) 
+  MDBInVal(T i)
   {
     memcpy(&d_memory[0], &i, sizeof(i));
     d_mdbval.mv_size = sizeof(T);
@@ -171,20 +172,20 @@ public:
     d_mdbval.mv_size = strlen(s);
     d_mdbval.mv_data = (void*)s;
   }
-  
-  MDBInVal(const string_view& v) 
+
+  MDBInVal(const string_view& v)
   {
     d_mdbval.mv_size = v.size();
     d_mdbval.mv_data = (void*)&v[0];
   }
 
-  MDBInVal(const std::string& v) 
+  MDBInVal(const std::string& v)
   {
     d_mdbval.mv_size = v.size();
     d_mdbval.mv_data = (void*)&v[0];
   }
 
-  
+
   template<typename T>
   static MDBInVal fromStruct(const T& t)
   {
@@ -193,7 +194,7 @@ public:
     ret.d_mdbval.mv_data = (void*)&t;
     return ret;
   }
-  
+
   operator MDB_val&()
   {
     return d_mdbval;
@@ -250,7 +251,7 @@ public:
                      const_cast<MDB_val*>(&val.d_mdbval));
     if(rc && rc != MDB_NOTFOUND)
       throw std::runtime_error("getting data: " + std::string(mdb_strerror(rc)));
-    
+
     return rc;
   }
 
@@ -263,7 +264,7 @@ public:
     return rc;
   }
 
-  
+
   // this is something you can do, readonly
   MDBDbi openDB(string_view dbname, int flags)
   {
@@ -272,7 +273,7 @@ public:
 
   MDBROCursor getCursor(const MDBDbi&);
   MDBROCursor getROCursor(const MDBDbi&);
-    
+
   operator MDB_txn*()
   {
     return d_txn;
@@ -288,8 +289,8 @@ public:
   }
 };
 
-/* 
-   A cursor in a read-only transaction must be closed explicitly, before or after its transaction ends. It can be reused with mdb_cursor_renew() before finally closing it. 
+/*
+   A cursor in a read-only transaction must be closed explicitly, before or after its transaction ends. It can be reused with mdb_cursor_renew() before finally closing it.
 
    "If the parent transaction commits, the cursor must not be used again."
 */
@@ -379,7 +380,7 @@ public:
        throw std::runtime_error("Unable to find from cursor: " + std::string(mdb_strerror(rc)));
     return rc;
   }
-  
+
   int lower_bound(const MDBInVal& in, MDBOutVal& key, MDBOutVal& data)
   {
     key.d_mdbval = in.d_mdbval;
@@ -390,7 +391,7 @@ public:
     return rc;
   }
 
-  
+
   int nextprev(MDBOutVal& key, MDBOutVal& data, MDB_cursor_op op)
   {
     int rc = mdb_cursor_get(d_cursor, const_cast<MDB_val*>(&key.d_mdbval), &data.d_mdbval, op);
@@ -499,12 +500,12 @@ public:
   MDBRWTransactionImpl &operator=(MDBRWTransactionImpl&& rhs) = delete;
 
   ~MDBRWTransactionImpl() override;
-  
+
   void commit() override;
   void abort() override;
 
   void clear(MDB_dbi dbi);
-  
+
   void put(MDB_dbi dbi, const MDBInVal& key, const MDBInVal& val, int flags=0)
   {
     if(!d_txn)
@@ -535,7 +536,7 @@ public:
     return rc;
   }
 
+
   int get(MDBDbi& dbi, const MDBInVal& key, MDBOutVal& val)
   {
     if(!d_txn)
@@ -556,7 +557,7 @@ public:
       val = out.get<string_view>();
     return rc;
   }
-  
+
   MDBDbi openDB(string_view dbname, int flags)
   {
     return MDBDbi(environment().d_env, d_txn, dbname, flags);
@@ -569,7 +570,7 @@ public:
   MDBROTransaction getROTransaction();
 };
 
-/* "A cursor in a write-transaction can be closed before its transaction ends, and will otherwise be closed when its transaction ends" 
+/* "A cursor in a write-transaction can be closed before its transaction ends, and will otherwise be closed when its transaction ends"
    This is a problem for us since it may means we are closing the cursor twice, which is bad
 */
 class MDBRWCursor : public MDBGenCursor<MDBRWTransactionImpl, MDBRWCursor>
@@ -592,7 +593,7 @@ public:
       throw std::runtime_error("mdb_cursor_put: " + std::string(mdb_strerror(rc)));
   }
 
-  
+
   int put(const MDBOutVal& key, const MDBOutVal& data, int flags=0)
   {
     // XXX check errors
@@ -607,4 +608,3 @@ public:
   }
 
 };
-
index 8fdce352278b366aa67dc12abb98d299f19956e7..3e119daf5ae3e85bb76daabe4a1c11a39e75c0a1 100644 (file)
@@ -1,4 +1,5 @@
 #pragma once
+#include <string_view>
 #include <iostream>
 #include "lmdb-safe.hh"
 #include <boost/archive/binary_oarchive.hpp>
@@ -14,7 +15,7 @@
 // using std::endl;
 
 
-/* 
+/*
    Open issues:
 
    Everything should go into a namespace
@@ -30,7 +31,7 @@
 
 
 /** Return the highest ID used in a database. Returns 0 for an empty DB.
-    This makes us start everything at ID=1, which might make it possible to 
+    This makes us start everything at ID=1, which might make it possible to
     treat id 0 as special
 */
 unsigned int MDBGetMaxID(MDBRWTransaction& txn, MDBDbi& dbi);
@@ -51,7 +52,7 @@ std::string serToString(const T& t)
   boost::iostreams::back_insert_device<std::string> inserter(serial_str);
   boost::iostreams::stream<boost::iostreams::back_insert_device<std::string> > s(inserter);
   boost::archive::binary_oarchive oa(s, boost::archive::no_header | boost::archive::no_codecvt);
-  
+
   oa << t;
   return serial_str;
 }
@@ -83,7 +84,7 @@ inline std::string keyConv(const T& t)
   return std::string((char*)&t, sizeof(t));
 }
 
-// this is how to override specific types.. it is ugly 
+// this is how to override specific types.. it is ugly
 template<class T, typename std::enable_if<std::is_same<T, std::string>::value,T>::type* = nullptr>
 inline std::string keyConv(const T& t)
 {
@@ -91,7 +92,7 @@ inline std::string keyConv(const T& t)
 }
 
 
-/** This is a struct that implements index operations, but 
+/** This is a struct that implements index operations, but
     only the operations that are broadcast to all indexes.
     Specifically, to deal with databases with less than the maximum
     number of interfaces, this only includes calls that should be
@@ -136,7 +137,7 @@ struct index_on : LMDBIndexOps<Class, Type, index_on<Class, Type, PtrToMember>>
   {
     return c.*PtrToMember;
   }
-  
+
   typedef Type type;
 };
 
@@ -152,7 +153,7 @@ struct index_on_function : LMDBIndexOps<Class, Type, index_on_function<Class, Ty
     return f(c);
   }
 
-  typedef Type type;           
+  typedef Type type;
 };
 
 /** nop index, so we can fill our N indexes, even if you don't use them all */
@@ -164,10 +165,10 @@ struct nullindex_t
   template<typename Class>
   void del(MDBRWTransaction& txn, const Class& t, uint32_t id)
   {}
-  
+
   void openDB(std::shared_ptr<MDBEnv>& env, string_view str, int flags)
   {
-    
+
   }
   typedef uint32_t type; // dummy
 };
@@ -194,9 +195,9 @@ public:
 #undef openMacro
   }
 
-  
+
   // we get a lot of our smarts from this tuple, it enables get<0> etc
-  typedef std::tuple<I1, I2, I3, I4> tuple_t; 
+  typedef std::tuple<I1, I2, I3, I4> tuple_t;
   tuple_t d_tuple;
 
   // We support readonly and rw transactions. Here we put the Readonly operations
@@ -230,7 +231,7 @@ public:
       MDBOutVal data;
       if((*d_parent.d_txn)->get(d_parent.d_parent->d_main, id, data))
         return false;
-      
+
       serFromString(data.get<std::string>(), t);
       return true;
     }
@@ -283,7 +284,7 @@ public:
         if(d_end)
           return;
         d_prefix.clear();
-        
+
         if(d_cursor.get(d_key, d_id,  MDB_GET_CURRENT)) {
           d_end = true;
           return;
@@ -303,7 +304,7 @@ public:
         d_cursor(std::move(cursor)),
         d_on_index(true), // is this an iterator on main database or on index?
         d_one_key(false),
-        d_prefix(prefix),  
+        d_prefix(prefix),
         d_end(false)
       {
         if(d_end)
@@ -323,28 +324,28 @@ public:
           serFromString(d_id.get<std::string>(), d_t);
       }
 
-      
+
       std::function<bool(const MDBOutVal&)> filter;
       void del()
       {
         d_cursor.del();
       }
-      
+
       bool operator!=(const eiter_t& rhs) const
       {
         return !d_end;
       }
-      
+
       bool operator==(const eiter_t& rhs) const
       {
         return d_end;
       }
-      
+
       const T& operator*()
       {
         return d_t;
       }
-      
+
       const T* operator->()
       {
         return &d_t;
@@ -372,13 +373,13 @@ public:
               throw std::runtime_error("Missing id field");
             if(filter && !filter(data))
               goto next;
-            
+
             serFromString(data.get<std::string>(), d_t);
           }
           else {
             if(filter && !filter(data))
               goto next;
-                        
+
             serFromString(d_id.get<std::string>(), d_t);
           }
         }
@@ -407,8 +408,8 @@ public:
       {
         return d_key;
       }
-      
-      
+
+
       // transaction we are part of
       Parent* d_parent;
       typename Parent::cursor_t d_cursor;
@@ -426,9 +427,9 @@ public:
     iter_t genbegin(MDB_cursor_op op)
     {
       typename Parent::cursor_t cursor = (*d_parent.d_txn)->getCursor(std::get<N>(d_parent.d_parent->d_tuple).d_idx);
-      
+
       MDBOutVal out, id;
-      
+
       if(cursor.get(out, id,  op)) {
                                              // on_index, one_key, end
         return iter_t{&d_parent, std::move(cursor), true, false, true};
@@ -452,11 +453,11 @@ public:
     iter_t begin()
     {
       typename Parent::cursor_t cursor = (*d_parent.d_txn)->getCursor(d_parent.d_parent->d_main);
-      
+
       MDBOutVal out, id;
-      
+
       if(cursor.get(out, id,  MDB_FIRST)) {
-                                              // on_index, one_key, end        
+                                              // on_index, one_key, end
         return iter_t{&d_parent, std::move(cursor), false, false, true};
       }
 
@@ -478,9 +479,9 @@ public:
       MDBInVal in(keystr);
       MDBOutVal out, id;
       out.d_mdbval = in.d_mdbval;
-      
+
       if(cursor.get(out, id,  op)) {
-                                              // on_index, one_key, end        
+                                              // on_index, one_key, end
         return iter_t{&d_parent, std::move(cursor), true, false, true};
       }
 
@@ -510,9 +511,9 @@ public:
       MDBInVal in(keyString);
       MDBOutVal out, id;
       out.d_mdbval = in.d_mdbval;
-      
+
       if(cursor.get(out, id,  MDB_SET)) {
-                                              // on_index, one_key, end        
+                                              // on_index, one_key, end
         return {iter_t{&d_parent, std::move(cursor), true, true, true}, eiter_t()};
       }
 
@@ -529,34 +530,34 @@ public:
       MDBInVal in(keyString);
       MDBOutVal out, id;
       out.d_mdbval = in.d_mdbval;
-      
+
       if(cursor.get(out, id,  MDB_SET_RANGE)) {
-                                              // on_index, one_key, end        
+                                              // on_index, one_key, end
         return {iter_t{&d_parent, std::move(cursor), true, true, true}, eiter_t()};
       }
 
       return {iter_t(&d_parent, std::move(cursor), keyString), eiter_t()};
     };
 
-    
+
     Parent& d_parent;
   };
-  
+
   class ROTransaction : public ReadonlyOperations<ROTransaction>
   {
   public:
-    explicit ROTransaction(TypedDBI* parent) : ReadonlyOperations<ROTransaction>(*this), d_parent(parent), d_txn(std::make_shared<MDBROTransaction>(d_parent->d_env->getROTransaction())) 
+    explicit ROTransaction(TypedDBI* parent) : ReadonlyOperations<ROTransaction>(*this), d_parent(parent), d_txn(std::make_shared<MDBROTransaction>(d_parent->d_env->getROTransaction()))
     {
     }
 
-    explicit ROTransaction(TypedDBI* parent, std::shared_ptr<MDBROTransaction> txn) : ReadonlyOperations<ROTransaction>(*this), d_parent(parent), d_txn(txn) 
+    explicit ROTransaction(TypedDBI* parent, std::shared_ptr<MDBROTransaction> txn) : ReadonlyOperations<ROTransaction>(*this), d_parent(parent), d_txn(txn)
     {
     }
 
-    
+
     ROTransaction(ROTransaction&& rhs) :
       ReadonlyOperations<ROTransaction>(*this), d_parent(rhs.d_parent),d_txn(std::move(rhs.d_txn))
-      
+
     {
       rhs.d_parent = 0;
     }
@@ -565,14 +566,14 @@ public:
     {
       return d_txn;
     }
-    
+
     typedef MDBROCursor cursor_t;
 
     TypedDBI* d_parent;
-    std::shared_ptr<MDBROTransaction> d_txn;    
-  };    
+    std::shared_ptr<MDBROTransaction> d_txn;
+  };
+
 
-  
   class RWTransaction :  public ReadonlyOperations<RWTransaction>
   {
   public:
@@ -585,7 +586,7 @@ public:
     {
     }
 
-    
+
     RWTransaction(RWTransaction&& rhs) :
       ReadonlyOperations<RWTransaction>(*this),
       d_parent(rhs.d_parent), d_txn(std::move(rhs.d_txn))
@@ -622,10 +623,10 @@ public:
     void modify(uint32_t id, std::function<void(T&)> func)
     {
       T t;
-      if(!this->get(id, t)) 
+      if(!this->get(id, t))
         throw std::runtime_error("Could not modify id "+std::to_string(id));
       func(t);
-      
+
       del(id);  // this is the lazy way. We could test for changed index fields
       put(t, id);
     }
@@ -634,9 +635,9 @@ public:
     void del(uint32_t id)
     {
       T t;
-      if(!this->get(id, t)) 
+      if(!this->get(id, t))
         return;
-      
+
       (*d_txn)->del(d_parent->d_main, id);
       clearIndex(id, t);
     }
@@ -675,7 +676,7 @@ public:
       return d_txn;
     }
 
-    
+
   private:
     // clear this ID from all indexes
     void clearIndex(uint32_t id, const T& t)
@@ -685,7 +686,7 @@ public:
       clearMacro(1);
       clearMacro(2);
       clearMacro(3);
-#undef clearMacro      
+#undef clearMacro
     }
 
   public:
@@ -721,14 +722,9 @@ public:
   {
     return d_env;
   }
-  
+
 private:
   std::shared_ptr<MDBEnv> d_env;
   MDBDbi d_main;
   std::string d_name;
 };
-
-
-
-
-
index f27b50c38957e4cfc834ddb6e79f3209fb0527c2..d0b655703a4096ff22f9ff0f981048ebb089e7b6 100644 (file)
@@ -61,14 +61,14 @@ uint32_t burtleCI(const unsigned char* k, uint32_t length, uint32_t init);
 
 //#include <ext/vstring.h>
 
-/* Quest in life: 
+/* Quest in life:
      accept escaped ascii presentations of DNS names and store them "natively"
      accept a DNS packet with an offset, and extract a DNS name from it
      build up DNSNames with prepend and append of 'raw' unescaped labels
 
    Be able to turn them into ASCII and "DNS name in a packet" again on request
 
-   Provide some common operators for comparison, detection of being part of another domain 
+   Provide some common operators for comparison, detection of being part of another domain
 
    NOTE: For now, everything MUST be . terminated, otherwise it is an error
 */
@@ -98,7 +98,7 @@ public:
   explicit DNSName(const char* p, size_t len);      //!< Constructs from a human formatted, escaped presentation
   explicit DNSName(const std::string& str) : DNSName(str.c_str(), str.length()) {}; //!< Constructs from a human formatted, escaped presentation
   DNSName(const char* p, int len, int offset, bool uncompress, uint16_t* qtype=nullptr, uint16_t* qclass=nullptr, unsigned int* consumed=nullptr, uint16_t minOffset=0); //!< Construct from a DNS Packet, taking the first question if offset=12. If supplied, consumed is set to the number of bytes consumed from the packet, which will not be equal to the wire length of the resulting name in case of compression.
-  
+
   bool isPartOf(const DNSName& rhs) const;   //!< Are we part of the rhs name? Note that name.isPartOf(name).
   inline bool operator==(const DNSName& rhs) const; //!< DNS-native comparison (case insensitive) - empty compares to empty
   bool operator!=(const DNSName& other) const { return !(*this == other); }
@@ -162,7 +162,7 @@ public:
 
   bool operator<(const DNSName& rhs)  const // this delivers _some_ kind of ordering, but not one useful in a DNS context. Really fast though.
   {
-    return std::lexicographical_compare(d_storage.rbegin(), d_storage.rend(), 
+    return std::lexicographical_compare(d_storage.rbegin(), d_storage.rend(),
                                 rhs.d_storage.rbegin(), rhs.d_storage.rend(),
                                 [](const unsigned char& a, const unsigned char& b) {
                                          return dns_tolower(a) < dns_tolower(b);
@@ -170,7 +170,7 @@ public:
   }
 
   inline bool canonCompare(const DNSName& rhs) const;
-  bool slowCanonCompare(const DNSName& rhs) const;  
+  bool slowCanonCompare(const DNSName& rhs) const;
 
 #if BOOST_VERSION >= 105300
   typedef boost::container::string string_t;
@@ -230,7 +230,7 @@ inline bool DNSName::canonCompare(const DNSName& rhs) const
   //
   // 0,2,6,a
   // 0,4,a
-  
+
   uint8_t ourpos[64], rhspos[64];
   uint8_t ourcount=0, rhscount=0;
   //cout<<"Asked to compare "<<toString()<<" to "<<rhs.toString()<<endl;
@@ -242,7 +242,7 @@ inline bool DNSName::canonCompare(const DNSName& rhs) const
   if(ourcount == sizeof(ourpos) || rhscount==sizeof(rhspos)) {
     return slowCanonCompare(rhs);
   }
-  
+
   for(;;) {
     if(ourcount == 0 && rhscount != 0)
       return true;
@@ -252,21 +252,21 @@ inline bool DNSName::canonCompare(const DNSName& rhs) const
     rhscount--;
 
     bool res=std::lexicographical_compare(
-                                         d_storage.c_str() + ourpos[ourcount] + 1, 
+                                         d_storage.c_str() + ourpos[ourcount] + 1,
                                          d_storage.c_str() + ourpos[ourcount] + 1 + *(d_storage.c_str() + ourpos[ourcount]),
-                                         rhs.d_storage.c_str() + rhspos[rhscount] + 1, 
+                                         rhs.d_storage.c_str() + rhspos[rhscount] + 1,
                                          rhs.d_storage.c_str() + rhspos[rhscount] + 1 + *(rhs.d_storage.c_str() + rhspos[rhscount]),
                                          [](const unsigned char& a, const unsigned char& b) {
                                            return dns_tolower(a) < dns_tolower(b);
                                          });
-    
+
     //    cout<<"Forward: "<<res<<endl;
     if(res)
       return true;
 
-    res=std::lexicographical_compare(    rhs.d_storage.c_str() + rhspos[rhscount] + 1, 
+    res=std::lexicographical_compare(    rhs.d_storage.c_str() + rhspos[rhscount] + 1,
                                          rhs.d_storage.c_str() + rhspos[rhscount] + 1 + *(rhs.d_storage.c_str() + rhspos[rhscount]),
-                                         d_storage.c_str() + ourpos[ourcount] + 1, 
+                                         d_storage.c_str() + ourpos[ourcount] + 1,
                                          d_storage.c_str() + ourpos[ourcount] + 1 + *(d_storage.c_str() + ourpos[ourcount]),
                                          [](const unsigned char& a, const unsigned char& b) {
                                            return dns_tolower(a) < dns_tolower(b);
@@ -320,7 +320,7 @@ struct SuffixMatchTree
   {
     return strcasecmp(d_name.c_str(), rhs.d_name.c_str()) < 0;
   }
-  
+
   std::string d_name;
   mutable std::set<SuffixMatchTree, std::less<>> children;
   mutable bool endNode;
@@ -582,16 +582,19 @@ namespace std {
 }
 
 DNSName::string_t segmentDNSNameRaw(const char* input, size_t inputlen); // from ragel
+
 bool DNSName::operator==(const DNSName& rhs) const
 {
-  if(rhs.empty() != empty() || rhs.d_storage.size() != d_storage.size())
+  if (rhs.empty() != empty() || rhs.d_storage.size() != d_storage.size()) {
     return false;
+  }
 
-  auto us = d_storage.cbegin();
-  auto p = rhs.d_storage.cbegin();
-  for(; us != d_storage.cend() && p != rhs.d_storage.cend(); ++us, ++p) { 
-    if(dns_tolower(*p) != dns_tolower(*us))
+  const auto* us = d_storage.cbegin();
+  const auto* p = rhs.d_storage.cbegin();
+  for (; us != d_storage.cend() && p != rhs.d_storage.cend(); ++us, ++p) {
+    if (dns_tolower(*p) != dns_tolower(*us)) {
       return false;
+    }
   }
   return true;
 }
index 980e327e441ef4eb7dc4fceacd6ad6ec7f0463e1..fbb850efee0864814fbafd19f7fa6c2b1cd8c332 100644 (file)
@@ -25,7 +25,7 @@
 #include <stdexcept>
 #include <iostream>
 #include <vector>
-#include <errno.h>
+#include <cerrno>
 // #include <netinet/in.h>
 #include "misc.hh"
 
@@ -343,11 +343,11 @@ struct DNSRecord
     return lzrp < rzrp;
   }
 
-
   bool operator==(const DNSRecord& rhs) const
   {
-    if(d_type != rhs.d_type || d_class != rhs.d_class || d_name != rhs.d_name)
+    if (d_type != rhs.d_type || d_class != rhs.d_class || d_name != rhs.d_name) {
       return false;
+    }
 
     return *d_content == *rhs.d_content;
   }
index eba68221f64f0bde3f771cd8783026294505e65a..e9141b3bb528c8be44336001b51f69c7d046e26b 100644 (file)
@@ -175,7 +175,7 @@ public:
        = 15
     */
     const dnsheader_aligned dnsheaderdata(query.data());
-    const struct dnsheader* dh = dnsheaderdata.get();    
+    const struct dnsheader* dh = dnsheaderdata.get();
     if (ntohs(dh->qdcount) != 1 || ntohs(dh->ancount) != 0 || ntohs(dh->nscount) != 0 || ntohs(dh->arcount) != 1 || (pos + 15) >= querySize || optionsToIgnore.empty()) {
       return cachedQuery.compare(pos, cachedQuerySize - pos, query, pos, querySize - pos) == 0;
     }
index b3f649ea0d8e6aeafbe95af92321b4cc04b4bdd4..d81678ffc0ecc807b0107e382783999c33829b06 100644 (file)
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+
 #include "syncres.hh"
 #include "arguments.hh"
 #include "zoneparser-tng.hh"
@@ -291,8 +293,8 @@ static void convertServersForAD(const std::string& zone, const std::string& inpu
   ad.d_servers.clear();
 
   vector<string> addresses;
-  for (vector<string>::const_iterator iter = servers.begin(); iter != servers.end(); ++iter) {
-    ComboAddress addr = parseIPAndPort(*iter, 53);
+  for (auto server = servers.begin(); server != servers.end(); ++server) {
+    ComboAddress addr = parseIPAndPort(*server, 53);
     ad.d_servers.push_back(addr);
     if (verbose) {
       addresses.push_back(addr.toStringWithPort());
@@ -540,8 +542,12 @@ std::tuple<std::shared_ptr<SyncRes::domainmap_t>, std::shared_ptr<notifyset_t>>
         newSet->insert(ad.d_name);
       }
     }
-    SLOG(g_log << Logger::Warning << "Done parsing " << newMap->size() - before << " forwarding instructions from file '" << ::arg()["forward-zones-file"] << "'" << endl,
-         log->info(Logr::Notice, "Done parsing forwarding instructions from file", "file", Logging::Loggable(::arg()["forward-zones-file"]), "count", Logging::Loggable(newMap->size() - before)));
+    SLOG(g_log << Logger::Warning << "Done parsing " << newMap->size() - before
+               << " forwarding instructions from file '"
+               << ::arg()["forward-zones-file"] << "'" << endl,
+         log->info(Logr::Notice, "Done parsing forwarding instructions from file", "file",
+                   Logging::Loggable(::arg()["forward-zones-file"]), "count",
+                   Logging::Loggable(newMap->size() - before)));
   }
 
   if (::arg().mustDo("export-etc-hosts")) {
@@ -605,8 +611,8 @@ std::tuple<std::shared_ptr<SyncRes::domainmap_t>, std::shared_ptr<notifyset_t>>
 
   parts.clear();
   stringtok(parts, ::arg()["allow-notify-for"], " ,\t\n\r");
-  for (parts_t::const_iterator iter = parts.begin(); iter != parts.end(); ++iter) {
-    newSet->insert(DNSName(*iter));
+  for (auto& part : parts) {
+    newSet->insert(DNSName(part));
   }
 
   if (auto anff = ::arg()["allow-notify-for-file"]; !anff.empty()) {
index 58759b88649c3bae71960d09bfca0ecb068cf465..e817d9d3f711bd644ebea49d823ed5a4a527ec9a 100644 (file)
@@ -151,7 +151,7 @@ public:
                                                        ordered_non_unique<tag<time_t>, member<EDNSStatus, time_t, &EDNSStatus::modeSetAt>>
                                   >> {
     void reset(index<ComboAddress>::type &ind, iterator it) {
-      ind.modify(it, [](EDNSStatus &s) { s.mode = EDNSStatus::EDNSMode::UNKNOWN; s.modeSetAt = 0; }); 
+      ind.modify(it, [](EDNSStatus &s) { s.mode = EDNSStatus::EDNSMode::UNKNOWN; s.modeSetAt = 0; });
     }
     void setMode(index<ComboAddress>::type &ind, iterator it, EDNSStatus::EDNSMode mode) {
       it->mode = mode;
@@ -519,7 +519,7 @@ public:
   static const int event_trace_to_log = 2;
   static int s_event_trace_enabled;
   static bool s_save_parent_ns_set;
-  
+
   std::unordered_map<std::string,bool> d_discardedPolicies;
   DNSFilterEngine::Policy d_appliedPolicy;
   std::unordered_set<std::string> d_policyTags;
@@ -953,4 +953,3 @@ struct ThreadTimes
     return *this;
   }
 };
-