Skip to content

Commit

Permalink
Some low-hanging LGTM fruit
Browse files Browse the repository at this point in the history
  • Loading branch information
omoerbeek committed Sep 24, 2019
1 parent c604f94 commit f0dbdd6
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 39 deletions.
6 changes: 2 additions & 4 deletions modules/ldapbackend/exceptions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
* 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:
Expand All @@ -48,4 +47,3 @@ class LDAPNoSuchObject : public LDAPException
explicit LDAPNoSuchObject() : LDAPException( "No such object" ) {}
};

#endif // LDAPEXCEPTIONS_HH
6 changes: 2 additions & 4 deletions modules/ldapbackend/ldapauthenticator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#pragma once

#include <ldap.h>
#include <string>

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#ifndef LDAPAUTHENTICATOR_HH
#define LDAPAUTHENTICATOR_HH

class LdapAuthenticator
{
public:
Expand All @@ -34,4 +33,3 @@ class LdapAuthenticator
virtual std::string getError() const = 0;
};

#endif // LDAPAUTHENTICATOR_HH
6 changes: 2 additions & 4 deletions modules/ldapbackend/ldapauthenticator_p.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
* 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
Expand Down Expand Up @@ -69,4 +68,3 @@ class LdapGssapiAuthenticator : public LdapAuthenticator
virtual std::string getError() const;
};

#endif // LDAPAUTHENTICATOR_P_HH
8 changes: 3 additions & 5 deletions modules/ldapbackend/ldapbackend.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -39,10 +42,6 @@
#include "utils.hh"



#ifndef LDAPBACKEND_HH
#define LDAPBACKEND_HH

using std::string;
using std::vector;

Expand Down Expand Up @@ -184,4 +183,3 @@ class LdapBackend : public DNSBackend
void setNotified( uint32_t id, uint32_t serial ) override;
};

#endif /* LDAPBACKEND_HH */
6 changes: 2 additions & 4 deletions modules/ldapbackend/ldaputils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
* 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 );
Expand All @@ -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
11 changes: 2 additions & 9 deletions modules/ldapbackend/powerldap.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -31,12 +33,6 @@
#include <lber.h>
#include <ldap.h>




#ifndef POWERLDAP_HH
#define POWERLDAP_HH

using std::list;
using std::map;
using std::string;
Expand Down Expand Up @@ -100,6 +96,3 @@ class PowerLDAP
static const string escape( const string& tobe );
};



#endif
8 changes: 3 additions & 5 deletions modules/ldapbackend/utils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@
* 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 <stdlib.h>
#include "pdns/misc.hh"
#include "pdns/utility.hh"


#ifndef LDAPBACKEND_UTILS_HH
#define LDAPBACKEND_UTILS_HH

using std::string;
using std::vector;

Expand Down Expand Up @@ -174,4 +173,3 @@ inline time_t str2tstamp( const string& str )
return 0;
}

#endif
5 changes: 3 additions & 2 deletions pdns/misc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 4 additions & 2 deletions pdns/syncres.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions pdns/tsigutils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
* 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);

0 comments on commit f0dbdd6

Please sign in to comment.