Skip to content

Commit

Permalink
Reformat with clang-format-19
Browse files Browse the repository at this point in the history
  • Loading branch information
omoerbeek committed Feb 12, 2025
1 parent a201418 commit f8854ba
Show file tree
Hide file tree
Showing 53 changed files with 533 additions and 713 deletions.
6 changes: 3 additions & 3 deletions modules/gmysqlbackend/smysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class SMySQLStatement : public SSqlStatement
if (d_req_bind) {
for (int i = 0; i < d_parnum; i++) {
if (d_req_bind[i].buffer)
delete[](char*) d_req_bind[i].buffer;
delete[] (char*)d_req_bind[i].buffer;

Check warning on line 375 in modules/gmysqlbackend/smysql.cc

View workflow job for this annotation

GitHub Actions / Analyze (cpp, auth)

deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead (cppcoreguidelines-owning-memory - Level=Warning)

Check warning on line 375 in modules/gmysqlbackend/smysql.cc

View workflow job for this annotation

GitHub Actions / Analyze (cpp, auth)

do not use C-style cast to convert between unrelated types (cppcoreguidelines-pro-type-cstyle-cast - Level=Warning)

Check warning on line 375 in modules/gmysqlbackend/smysql.cc

View workflow job for this annotation

GitHub Actions / Analyze (cpp, auth)

do not use pointer arithmetic (cppcoreguidelines-pro-bounds-pointer-arithmetic - Level=Warning)
if (d_req_bind[i].length)
delete[] d_req_bind[i].length;
}
Expand Down Expand Up @@ -431,7 +431,7 @@ class SMySQLStatement : public SSqlStatement
if (d_req_bind) {
for (int i = 0; i < d_parnum; i++) {
if (d_req_bind[i].buffer)
delete[](char*) d_req_bind[i].buffer;
delete[] (char*)d_req_bind[i].buffer;

Check warning on line 434 in modules/gmysqlbackend/smysql.cc

View workflow job for this annotation

GitHub Actions / Analyze (cpp, auth)

deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead (cppcoreguidelines-owning-memory - Level=Warning)

Check warning on line 434 in modules/gmysqlbackend/smysql.cc

View workflow job for this annotation

GitHub Actions / Analyze (cpp, auth)

do not use C-style cast to convert between unrelated types (cppcoreguidelines-pro-type-cstyle-cast - Level=Warning)

Check warning on line 434 in modules/gmysqlbackend/smysql.cc

View workflow job for this annotation

GitHub Actions / Analyze (cpp, auth)

do not use pointer arithmetic (cppcoreguidelines-pro-bounds-pointer-arithmetic - Level=Warning)
if (d_req_bind[i].length)
delete[] d_req_bind[i].length;
}
Expand All @@ -441,7 +441,7 @@ class SMySQLStatement : public SSqlStatement
if (d_res_bind) {
for (int i = 0; i < d_fnum; i++) {
if (d_res_bind[i].buffer)
delete[](char*) d_res_bind[i].buffer;
delete[] (char*)d_res_bind[i].buffer;

Check warning on line 444 in modules/gmysqlbackend/smysql.cc

View workflow job for this annotation

GitHub Actions / Analyze (cpp, auth)

deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead (cppcoreguidelines-owning-memory - Level=Warning)

Check warning on line 444 in modules/gmysqlbackend/smysql.cc

View workflow job for this annotation

GitHub Actions / Analyze (cpp, auth)

do not use C-style cast to convert between unrelated types (cppcoreguidelines-pro-type-cstyle-cast - Level=Warning)

Check warning on line 444 in modules/gmysqlbackend/smysql.cc

View workflow job for this annotation

GitHub Actions / Analyze (cpp, auth)

do not use pointer arithmetic (cppcoreguidelines-pro-bounds-pointer-arithmetic - Level=Warning)
if (d_res_bind[i].length)
delete[] d_res_bind[i].length;
if (d_res_bind[i].error)
Expand Down
2 changes: 1 addition & 1 deletion modules/godbcbackend/sodbc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class SODBCStatement : public SSqlStatement

for (auto& i : d_req_bind) {
if (i.ParameterType == SQL_VARCHAR)
delete[](char*) i.ParameterValuePtr;
delete[] (char*)i.ParameterValuePtr;
else if (i.ParameterType == SQL_INTEGER)
delete (ULONG*)i.ParameterValuePtr;
else if (i.ParameterType == SQL_C_UBIGINT)
Expand Down
4 changes: 2 additions & 2 deletions modules/ldapbackend/ldapbackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ LdapBackend::LdapBackend(const string& suffix)
LdapBackend::~LdapBackend()
{
d_search.reset(); // This is necessary otherwise d_pldap will get deleted first and
// we may hang in SearchResult::~SearchResult() waiting for the
// current operation to be abandoned
// we may hang in SearchResult::~SearchResult() waiting for the
// current operation to be abandoned
delete (d_pldap);
delete (d_authenticator);
g_log << Logger::Notice << d_myname << " Ldap connection closed" << endl;
Expand Down
2 changes: 1 addition & 1 deletion modules/ldapbackend/powerldap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ PowerLDAP::SearchResult::~SearchResult()
{
if (!d_finished)
ldap_abandon_ext(d_ld, d_msgid, NULL, NULL); // We don't really care about the return code as there's
// not much we can do now
// not much we can do now
}

bool PowerLDAP::SearchResult::getNext(PowerLDAP::sentry_t& entry, bool dn, int /* timeout */)
Expand Down
58 changes: 29 additions & 29 deletions modules/lmdbbackend/lmdbbackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -821,15 +821,15 @@ namespace serialization
ar& std::string();
}
else {
ar& g.toDNSStringLC();
ar & g.toDNSStringLC();
}
}

template <class Archive>
void load(Archive& ar, DNSName& g, const unsigned int /* version */)
{
string tmp;
ar& tmp;
ar & tmp;
if (tmp.empty()) {
g = DNSName();
}
Expand All @@ -841,44 +841,44 @@ namespace serialization
template <class Archive>
void save(Archive& ar, const QType& g, const unsigned int /* version */)
{
ar& g.getCode();
ar & g.getCode();
}

template <class Archive>
void load(Archive& ar, QType& g, const unsigned int /* version */)
{
uint16_t tmp;
ar& tmp;
ar & tmp;
g = QType(tmp);
}

template <class Archive>
void save(Archive& ar, const DomainInfo& g, const unsigned int /* version */)
{
ar& g.zone;
ar& g.last_check;
ar& g.account;
ar& g.primaries;
ar& g.id;
ar& g.notified_serial;
ar& g.kind;
ar& g.options;
ar& g.catalog;
ar & g.zone;
ar & g.last_check;
ar & g.account;
ar & g.primaries;
ar & g.id;
ar & g.notified_serial;
ar & g.kind;
ar & g.options;
ar & g.catalog;
}

template <class Archive>
void load(Archive& ar, DomainInfo& g, const unsigned int version)
{
ar& g.zone;
ar& g.last_check;
ar& g.account;
ar& g.primaries;
ar& g.id;
ar& g.notified_serial;
ar& g.kind;
ar & g.zone;
ar & g.last_check;
ar & g.account;
ar & g.primaries;
ar & g.id;
ar & g.notified_serial;
ar & g.kind;
if (version >= 1) {
ar& g.options;
ar& g.catalog;
ar & g.options;
ar & g.catalog;
}
else {
g.options.clear();
Expand All @@ -889,21 +889,21 @@ namespace serialization
template <class Archive>
void serialize(Archive& ar, LMDBBackend::DomainMeta& g, const unsigned int /* version */)
{
ar& g.domain& g.key& g.value;
ar & g.domain & g.key & g.value;
}

template <class Archive>
void save(Archive& ar, const LMDBBackend::KeyDataDB& g, const unsigned int /* version */)
{
ar& g.domain& g.content& g.flags& g.active& g.published;
ar & g.domain & g.content & g.flags & g.active & g.published;
}

template <class Archive>
void load(Archive& ar, LMDBBackend::KeyDataDB& g, const unsigned int version)
{
ar& g.domain& g.content& g.flags& g.active;
ar & g.domain & g.content & g.flags & g.active;
if (version >= 1) {
ar& g.published;
ar & g.published;
}
else {
g.published = true;
Expand All @@ -913,9 +913,9 @@ namespace serialization
template <class Archive>
void serialize(Archive& ar, TSIGKey& g, const unsigned int /* version */)
{
ar& g.name;
ar& g.algorithm; // this is the ordername
ar& g.key;
ar & g.name;
ar & g.algorithm; // this is the ordername
ar & g.key;
}

} // namespace serialization
Expand Down
4 changes: 1 addition & 3 deletions modules/remotebackend/httpconnector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,7 @@ int HTTPConnector::send_message(const Json& input)
// connect using tcp
struct addrinfo* gAddr = nullptr;
struct addrinfo* gAddrPtr = nullptr;
struct addrinfo hints
{
};
struct addrinfo hints{};
std::string sPort = std::to_string(d_port);
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
Expand Down
12 changes: 3 additions & 9 deletions modules/remotebackend/unixconnector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,8 @@ int UnixsocketConnector::recv_message(Json& output)
std::string s_output;
std::string err;

struct timeval t0
{
};
struct timeval t
{
};
struct timeval t0{};
struct timeval t{};

gettimeofday(&t0, nullptr);
memcpy(&t, &t0, sizeof(t0));
Expand Down Expand Up @@ -159,9 +155,7 @@ ssize_t UnixsocketConnector::write(const std::string& data)

void UnixsocketConnector::reconnect()
{
struct sockaddr_un sock
{
};
struct sockaddr_un sock{};
int rv = 0;

if (connected) {
Expand Down
2 changes: 1 addition & 1 deletion modules/tinydnsbackend/tinydnsbackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ vector<string> TinyDNSBackend::getLocations()
char key[6];
key[0] = '\000';
key[1] = '\045';
key[2] = (addr)&0xff;
key[2] = (addr) & 0xff;

Check warning on line 53 in modules/tinydnsbackend/tinydnsbackend.cc

View workflow job for this annotation

GitHub Actions / Analyze (cpp, auth)

narrowing conversion from 'unsigned long' to signed type 'char' is implementation-defined (bugprone-narrowing-conversions - Level=Warning)
key[3] = (addr >> 8) & 0xff;
key[4] = (addr >> 16) & 0xff;
key[5] = (addr >> 24) & 0xff;
Expand Down
4 changes: 1 addition & 3 deletions pdns/arguments.cc
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,7 @@ void ArgvMap::gatherIncludes(const std::string& directory, const std::string& su
// build name
string fullName = directory + "/" + std::string(name);
// ensure it's readable file
struct stat statInfo
{
};
struct stat statInfo{};
if (stat(fullName.c_str(), &statInfo) != 0 || !S_ISREG(statInfo.st_mode)) {
string msg = fullName + " is not a regular file";
SLOG(g_log << Logger::Error << msg << std::endl,
Expand Down
2 changes: 1 addition & 1 deletion pdns/backends/gsql/ssql.hh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ public:
{
return true;
}
virtual void reconnect(){};
virtual void reconnect() {};
virtual ~SSql() = default;
};
3 changes: 1 addition & 2 deletions pdns/credentials.cc
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,7 @@ SensitiveData CredentialsHolder::readFromTerminal()

struct std::map<int, struct sigaction> signals;
struct sigaction sigact // just sigaction does not work, it clashes with sigaction(2)
{
};
{};
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
sigact.sa_handler = [](int /* s */) {};
Expand Down
3 changes: 1 addition & 2 deletions pdns/dnsbackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,7 @@ void fillSOAData(const DNSZoneRecord& inZoneRecord, SOAData& soaData)

std::shared_ptr<DNSRecordContent> makeSOAContent(const SOAData& soaData)
{
struct soatimes soaTimes
{
struct soatimes soaTimes{
.serial = soaData.serial,
.refresh = soaData.refresh,
.retry = soaData.retry,
Expand Down
4 changes: 2 additions & 2 deletions pdns/dnsbackend.hh
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ struct TSIGKey
struct AutoPrimary
{
AutoPrimary(string new_ip, string new_nameserver, string new_account) :
ip(std::move(new_ip)), nameserver(std::move(new_nameserver)), account(std::move(new_account)){};
ip(std::move(new_ip)), nameserver(std::move(new_nameserver)), account(std::move(new_account)) {};
std::string ip;
std::string nameserver;
std::string account;
Expand Down Expand Up @@ -534,7 +534,7 @@ public:
struct SOAData
{
SOAData() :
domain_id(-1){};
domain_id(-1) {};

DNSName qname;
DNSName nameserver;
Expand Down
22 changes: 6 additions & 16 deletions pdns/dnsdistdist/dnscrypt.hh
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,12 @@ static_assert(crypto_box_curve25519xchacha20poly1305_BEFORENMBYTES == crypto_box

#define DNSCRYPT_CERT_MAGIC_SIZE (4)
#define DNSCRYPT_CERT_MAGIC_VALUE \
{ \
0x44, 0x4e, 0x53, 0x43 \
}
{0x44, 0x4e, 0x53, 0x43}
#define DNSCRYPT_CERT_PROTOCOL_MINOR_VERSION_VALUE \
{ \
0x00, 0x00 \
}
{0x00, 0x00}
#define DNSCRYPT_CLIENT_MAGIC_SIZE (8)
#define DNSCRYPT_RESOLVER_MAGIC \
{ \
0x72, 0x36, 0x66, 0x6e, 0x76, 0x57, 0x6a, 0x38 \
}
#define DNSCRYPT_RESOLVER_MAGIC \
{0x72, 0x36, 0x66, 0x6e, 0x76, 0x57, 0x6a, 0x38}
#define DNSCRYPT_RESOLVER_MAGIC_SIZE (8)
#define DNSCRYPT_PADDED_BLOCK_SIZE (64)
#define DNSCRYPT_MAX_TCP_PADDING_SIZE (256)
Expand All @@ -100,13 +94,9 @@ static_assert(crypto_box_curve25519xchacha20poly1305_BEFORENMBYTES == crypto_box
static_assert(DNSCRYPT_CLIENT_MAGIC_SIZE <= DNSCRYPT_PUBLIC_KEY_SIZE, "DNSCrypt Client Nonce size should be smaller or equal to public key size.");

#define DNSCRYPT_CERT_ES_VERSION1_VALUE \
{ \
0x00, 0x01 \
}
{0x00, 0x01}
#define DNSCRYPT_CERT_ES_VERSION2_VALUE \
{ \
0x00, 0x02 \
}
{0x00, 0x02}

class DNSCryptContext;

Expand Down
24 changes: 6 additions & 18 deletions pdns/dnsdistdist/dnsdist-async.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ void AsynchronousHolder::stop()
void AsynchronousHolder::mainThread(std::shared_ptr<Data> data)
{
setThreadName("dnsdist/async");
struct timeval now
{
};
struct timeval now{};
std::list<std::pair<uint16_t, std::unique_ptr<CrossProtocolQuery>>> expiredEvents;

auto mplexer = std::unique_ptr<FDMultiplexer>(FDMultiplexer::getMultiplexerSilent(1));
Expand Down Expand Up @@ -181,9 +179,7 @@ std::unique_ptr<CrossProtocolQuery> AsynchronousHolder::get(uint16_t asyncID, ui
auto content = d_data->d_content.lock();
auto contentIt = content->find(std::tie(queryID, asyncID));
if (contentIt == content->end()) {
struct timeval now
{
};
struct timeval now{};
gettimeofday(&now, nullptr);
vinfolog("Asynchronous object %d not found at %d.%d", queryID, now.tv_sec, now.tv_usec);
return nullptr;
Expand Down Expand Up @@ -231,9 +227,7 @@ static bool resumeResponse(std::unique_ptr<CrossProtocolQuery>&& response)

auto sender = response->getTCPQuerySender();
if (sender) {
struct timeval now
{
};
struct timeval now{};
gettimeofday(&now, nullptr);

TCPResponse resp(std::move(response->query.d_buffer), std::move(response->query.d_idstate), nullptr, response->downstream);
Expand Down Expand Up @@ -318,9 +312,7 @@ bool resumeQuery(std::unique_ptr<CrossProtocolQuery>&& query)
return false;
}

struct timeval now
{
};
struct timeval now{};
gettimeofday(&now, nullptr);

TCPResponse response(std::move(query->query.d_buffer), std::move(query->query.d_idstate), nullptr, query->downstream);
Expand Down Expand Up @@ -351,9 +343,7 @@ bool suspendQuery(DNSQuestion& dnsQuestion, uint16_t asyncID, uint16_t queryID,
return false;
}

struct timeval now
{
};
struct timeval now{};
gettimeofday(&now, nullptr);
struct timeval ttd = now;
ttd.tv_sec += timeoutMs / 1000;
Expand All @@ -373,9 +363,7 @@ bool suspendResponse(DNSResponse& dnsResponse, uint16_t asyncID, uint16_t queryI
return false;
}

struct timeval now
{
};
struct timeval now{};
gettimeofday(&now, nullptr);
struct timeval ttd = now;
ttd.tv_sec += timeoutMs / 1000;
Expand Down
Loading

0 comments on commit f8854ba

Please sign in to comment.