]> granicus.if.org Git - pdns/commitdiff
Some low-hanging LGTM fruit
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 24 Sep 2019 14:30:18 +0000 (16:30 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 24 Sep 2019 14:37:36 +0000 (16:37 +0200)
modules/ldapbackend/exceptions.hh
modules/ldapbackend/ldapauthenticator.hh
modules/ldapbackend/ldapauthenticator_p.hh
modules/ldapbackend/ldapbackend.hh
modules/ldapbackend/ldaputils.hh
modules/ldapbackend/powerldap.hh
modules/ldapbackend/utils.hh
pdns/misc.cc
pdns/syncres.cc
pdns/tsigutils.hh

index 3436e38d1824a9d717d898c885c99b31e4bad8f3..2e7ca6f4bf6eeb286618f3aefc0071fc350db451 100644 (file)
  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#pragma once
+
 #include <exception>
 #include <stdexcept>
 #include <string>
 
-#ifndef LDAPEXCEPTIONS_HH
-#define LDAPEXCEPTIONS_HH
-
 class LDAPException : public std::runtime_error
 {
   public:
@@ -48,4 +47,3 @@ class LDAPNoSuchObject : public LDAPException
     explicit LDAPNoSuchObject() : LDAPException( "No such object" ) {}
 };
 
-#endif // LDAPEXCEPTIONS_HH
index d8452a08b76ef4e18180ab9d313678e9a6f9c831..53d22bed4a4d2ef4f0eca579f15db09fb343c84e 100644 (file)
@@ -16,6 +16,8 @@
  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#pragma once
+
 #include <ldap.h>
 #include <string>
 
@@ -23,9 +25,6 @@
 #include <config.h>
 #endif
 
-#ifndef LDAPAUTHENTICATOR_HH
-#define LDAPAUTHENTICATOR_HH
-
 class LdapAuthenticator
 {
   public:
@@ -34,4 +33,3 @@ class LdapAuthenticator
     virtual std::string getError() const = 0;
 };
 
-#endif // LDAPAUTHENTICATOR_HH
index cd5d083eed9e1ab14b59dfa77a0cf32055089cb4..5cf8d412008aa4ede5f91ae301cd55803dfb26d5 100644 (file)
  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#pragma once
+
 #include <krb5.h>
 #include "ldapauthenticator.hh"
 
-#ifndef LDAPAUTHENTICATOR_P_HH
-#define LDAPAUTHENTICATOR_P_HH
-
 #ifndef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_DEFAULT_FLAGS
 #define krb5_get_init_creds_opt_set_default_flags( a, b, c, d ) /* This does not exist with MIT Kerberos */
 #endif
@@ -69,4 +68,3 @@ class LdapGssapiAuthenticator : public LdapAuthenticator
     virtual std::string getError() const;
 };
 
-#endif // LDAPAUTHENTICATOR_P_HH
index f89e29af22d2c6020eaa137dd212493f9886bc3e..e0589ff2aa547bf7db43ea42aa4216a7717c8ff1 100644 (file)
@@ -20,6 +20,9 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
+
+#pragma once
+
 #include <algorithm>
 #include <sstream>
 #include <utility>
 #include "utils.hh"
 
 
-
-#ifndef LDAPBACKEND_HH
-#define LDAPBACKEND_HH
-
 using std::string;
 using std::vector;
 
@@ -184,4 +183,3 @@ class LdapBackend : public DNSBackend
     void setNotified( uint32_t id, uint32_t serial ) override;
 };
 
-#endif /* LDAPBACKEND_HH */
index 83012f234f720e4ebbcd4fbed98d74e7093f9ad8..5b1bc7a218493d06c426d01d27387fd9789da7c8 100644 (file)
  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#pragma once
+
 #include "exceptions.hh"
 
 #include <ldap.h>
 #include <string>
 
-#ifndef LDAPUTILS_HH
-#define LDAPUTILS_HH
-
 void ldapSetOption( LDAP *conn, int option, void *value );
 
 void ldapGetOption( LDAP *conn, int option, void *value );
@@ -33,4 +32,3 @@ std::string ldapGetError( LDAP *conn, int code );
 
 int ldapWaitResult( LDAP *conn, int msgid, int timeout, LDAPMessage** result = NULL );
 
-#endif // LDAPUTILS_HH
index 8ff3441df30640c4254c02cf638b6351da49eea1..4c7e8ff2c06c5f35e38394363ed9fb41173f9353 100644 (file)
@@ -20,6 +20,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
+#pragma once
+
 #include <list>
 #include <map>
 #include <memory>
 #include <lber.h>
 #include <ldap.h>
 
-
-
-
-#ifndef POWERLDAP_HH
-#define POWERLDAP_HH
-
 using std::list;
 using std::map;
 using std::string;
@@ -100,6 +96,3 @@ class PowerLDAP
     static const string escape( const string& tobe );
 };
 
-
-
-#endif
index 902c3d53251d9cebd07abe04b342835b8037cee3..7fc99fbb7e77279ab6c50874021b3d0cd117b980 100644 (file)
@@ -19,6 +19,9 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
+
+#pragma once
+
 #include <string>
 #include <vector>
 #include <time.h>
 #include "pdns/misc.hh"
 #include "pdns/utility.hh"
 
-
-#ifndef LDAPBACKEND_UTILS_HH
-#define LDAPBACKEND_UTILS_HH
-
 using std::string;
 using std::vector;
 
@@ -174,4 +173,3 @@ inline time_t str2tstamp( const string& str )
   return 0;
 }
 
-#endif
index ab2ea0c6869b6df41a58472f975cbd6c25135273..c44d674be90c1dd8eb10cb0389de485d52e4033b 100644 (file)
@@ -197,10 +197,11 @@ size_t writen2WithTimeout(int fd, const void * buffer, size_t len, int timeout)
 string nowTime()
 {
   time_t now = time(nullptr);
-  struct tm* tm = localtime(&now);
+  struct tm tm;
+  localtime_r(&now, &tm);
   char buffer[30];
   // YYYY-mm-dd HH:MM:SS TZOFF
-  strftime(buffer, sizeof(buffer), "%F %T %z", tm);
+  strftime(buffer, sizeof(buffer), "%F %T %z", &tm);
   buffer[sizeof(buffer)-1] = '\0';
   return string(buffer);
 }
index 7e2c548d774461bf4f20c44ac1feb321f2132c6a..627c467fcc075587e4ada3bf795c5ddddf2f2f61 100644 (file)
@@ -414,7 +414,8 @@ uint64_t SyncRes::doEDNSDump(int fd)
   fprintf(fp.get(),"; edns from thread follows\n;\n");
   for(const auto& eds : t_sstorage.ednsstatus) {
     count++;
-    fprintf(fp.get(), "%s\t%d\t%s", eds.first.toString().c_str(), (int)eds.second.mode, ctime(&eds.second.modeSetAt));
+    char tmp[26];
+    fprintf(fp.get(), "%s\t%d\t%s", eds.first.toString().c_str(), (int)eds.second.mode, ctime_r(&eds.second.modeSetAt, tmp));
   }
   return count;
 }
@@ -456,8 +457,9 @@ uint64_t SyncRes::doDumpThrottleMap(int fd)
   for(const auto& i : throttleMap)
   {
     count++;
+    char tmp[26];
     // remote IP, dns name, qtype, count, ttd
-    fprintf(fp.get(), "%s\t%s\t%d\t%u\t%s", i.first.get<0>().toString().c_str(), i.first.get<1>().toLogString().c_str(), i.first.get<2>(), i.second.count, ctime(&i.second.ttd));
+    fprintf(fp.get(), "%s\t%s\t%d\t%u\t%s", i.first.get<0>().toString().c_str(), i.first.get<1>().toLogString().c_str(), i.first.get<2>(), i.second.count, ctime_r(&i.second.ttd, tmp));
   }
 
   return count;
index bffd0971d73f0a105a6ff4b609fa9aa69a1c1a3d..3b5c926651d9b71483fbfdb7f5a5aa0489205592 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#pragma once
+
 #include "dnsname.hh"
 #include <string>
 
 std::string makeTSIGKey(const DNSName& algorithm);
+