Skip to content

Commit

Permalink
Merge pull request #14409 from fredmorcos/various-cleanups
Browse files Browse the repository at this point in the history
Various cleanups
  • Loading branch information
fredmorcos authored Jul 3, 2024
2 parents 61e0281 + d262b84 commit 53bcb9f
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 21 deletions.
6 changes: 4 additions & 2 deletions modules/geoipbackend/geoipbackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,9 @@ void GeoIPBackend::lookup(const QType& qtype, const DNSName& qdomain, int zoneId
}

Netmask addr{"0.0.0.0/0"};
if (pkt_p != nullptr)
if (pkt_p != nullptr) {
addr = Netmask(pkt_p->getRealRemote());
}

gl.netmask = 0;

Expand Down Expand Up @@ -582,8 +583,9 @@ void GeoIPBackend::lookup(const QType& qtype, const DNSName& qdomain, int zoneId

bool GeoIPBackend::get(DNSResourceRecord& r)
{
if (d_result.empty())
if (d_result.empty()) {
return false;
}

r = d_result.back();
d_result.pop_back();
Expand Down
3 changes: 3 additions & 0 deletions modules/lua2backend/lua2api2.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include "boost/algorithm/string/join.hpp"
#include "pdns/arguments.hh"

#include "pdns/dnsbackend.hh"
#include "pdns/lua-auth4.hh"

class Lua2BackendAPIv2 : public DNSBackend, AuthLua4
{
private:
Expand Down
10 changes: 3 additions & 7 deletions pdns/dnspacket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ ComboAddress DNSPacket::getRemote() const

ComboAddress DNSPacket::getInnerRemote() const
{
if (d_inner_remote)
return *d_inner_remote;
return d_remote;
return d_inner_remote ? *d_inner_remote : d_remote;
}

uint16_t DNSPacket::getRemotePort() const
Expand Down Expand Up @@ -708,14 +706,12 @@ bool DNSPacket::hasValidEDNSCookie() const

Netmask DNSPacket::getRealRemote() const
{
if(d_haveednssubnet)
return d_eso.source;
return Netmask(getInnerRemote());
return d_haveednssubnet ? d_eso.source : Netmask{getInnerRemote()};
}

void DNSPacket::setSocket(Utility::sock_t sock)
{
d_socket=sock;
d_socket = sock;
}

void DNSPacket::commitD()
Expand Down
2 changes: 1 addition & 1 deletion pdns/misc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ auto pdns::OpenSSL::error(const std::string& errorMessage) -> std::runtime_error
}
}
#endif
return std::runtime_error(fullErrorMessage);
return std::runtime_error{fullErrorMessage};
}

auto pdns::OpenSSL::error(const std::string& componentName, const std::string& errorMessage) -> std::runtime_error
Expand Down
12 changes: 11 additions & 1 deletion pdns/misc.hh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,17 @@
class DNSName;

// Do not change to "using TSIGHashEnum ..." until you know CodeQL does not choke on it
typedef enum { TSIG_MD5, TSIG_SHA1, TSIG_SHA224, TSIG_SHA256, TSIG_SHA384, TSIG_SHA512, TSIG_GSS } TSIGHashEnum;
typedef enum
{
TSIG_MD5,
TSIG_SHA1,
TSIG_SHA224,
TSIG_SHA256,
TSIG_SHA384,
TSIG_SHA512,
TSIG_GSS,
} TSIGHashEnum;

namespace pdns
{
/**
Expand Down
5 changes: 2 additions & 3 deletions pdns/opensslsigners.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "config.h"
#include "misc.hh"
#include <memory>
#include <openssl/crypto.h>
#include <openssl/ec.h>
#include <optional>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <openssl/obj_mac.h>
#ifdef HAVE_LIBCRYPTO_ECDSA
#include <openssl/ecdsa.h>
Expand Down
13 changes: 6 additions & 7 deletions pdns/pdnsutil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4231,16 +4231,15 @@ try
}
return 0;
}
catch(PDNSException& ae) {
cerr<<"Error: "<<ae.reason<<endl;
catch (PDNSException& ae) {
cerr << "Error: " << ae.reason << endl;
return 1;
}
catch(std::exception& e) {
cerr<<"Error: "<<e.what()<<endl;
catch (std::exception& e) {
cerr << "Error: " << e.what() << endl;
return 1;
}
catch(...)
{
cerr<<"Caught an unknown exception"<<endl;
catch (...) {
cerr << "Caught an unknown exception" << endl;
return 1;
}

0 comments on commit 53bcb9f

Please sign in to comment.