From 6e58535e4cf4b5d139e66cc3c6f18f7b2e62e64a Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 18 Mar 2024 13:29:02 +0100 Subject: [PATCH] Fix clang-tidy warnings, again --- pdns/dnspcap2protobuf.cc | 2 ++ pdns/libssl.cc | 3 ++- pdns/misc.cc | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pdns/dnspcap2protobuf.cc b/pdns/dnspcap2protobuf.cc index 00eed1deef28..6a997133005a 100644 --- a/pdns/dnspcap2protobuf.cc +++ b/pdns/dnspcap2protobuf.cc @@ -63,9 +63,11 @@ try { PcapPacketReader pr(argv[1]); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic): it's argv.. auto filePtr = pdns::openFileForWriting(argv[2], 0600, true, false); if (!filePtr) { auto error = errno; + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic): it's argv.. cerr<<"Error opening output file "<(SSL_CTX_get_ex_data(sslCtx, s_keyLogIndex)); + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast): OpenSSL's API + auto* filePtr = reinterpret_cast(SSL_CTX_get_ex_data(sslCtx, s_keyLogIndex)); if (filePtr == nullptr) { return; } diff --git a/pdns/misc.cc b/pdns/misc.cc index 7d2f68366437..b69155daea76 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -1789,14 +1789,14 @@ UniqueFilePtr openFileForWriting(const std::string& filePath, mode_t permissions } int fileDesc = open(filePath.c_str(), flags, permissions); if (fileDesc == -1) { - return UniqueFilePtr(nullptr); + return {}; } auto filePtr = pdns::UniqueFilePtr(fdopen(fileDesc, appendIfExists ? "a" : "w")); if (!filePtr) { auto error = errno; close(fileDesc); errno = error; - return UniqueFilePtr(nullptr); + return {}; } return filePtr; }