SERVER-79410 Enable bugprone-unused-return-value clang lint warning

This commit is contained in:
Zack Winter 2023-08-15 18:24:18 +00:00 committed by Evergreen Agent
parent 4086290c7c
commit 27a372d3ab
5 changed files with 14 additions and 10 deletions

View File

@ -25,6 +25,7 @@ Checks: '-*,
bugprone-swapped-arguments,
bugprone-terminating-continue,
bugprone-undelegated-constructor,
bugprone-unused-return-value,
hicpp-static-assert,
hicpp-undelegated-constructor,
misc-static-assert,
@ -75,7 +76,6 @@ Checks: '-*,
-bugprone-suspicious-missing-comma,
-bugprone-suspicious-semicolon,
-bugprone-undefined-memory-manipulation,
-bugprone-unused-return-value,
-cert-err34-c,
-cert-err52-cpp,
-cert-err60-cpp,

View File

@ -120,13 +120,14 @@ public:
uassertOpenSSL("Failed creating RSAKey", rsa.get() != nullptr);
uassertOpenSSL("RSA key setup failed",
RSA_set0_key(rsa.get(), n.get(), e.get(), nullptr) == 1);
n.release(); // Now owned by rsa
e.release(); // Now owned by rsa
(void)n.release(); // Now owned by rsa, cast to void to explicitly ignore the return value.
(void)e.release(); // Now owned by rsa, cast to void to explicitly ignore the return value.
uassertOpenSSL("Failed creating EVP_PKey", _key.get() != nullptr);
uassertOpenSSL("EVP_PKEY assignment failed",
EVP_PKEY_assign_RSA(_key.get(), rsa.get()) == 1);
rsa.release(); // Now owned by _key
(void)rsa
.release(); // Now owned by _key, cast to void to explicitly ignore the return value.
}
Status validate(StringData algorithm, StringData payload, StringData signature) const final {

View File

@ -283,8 +283,8 @@ void CursorManager::unpin(OperationContext* opCtx,
}
// The cursor will stay around in '_cursorMap', so release the unique pointer to avoid deleting
// it.
cursor.release();
// it. Cast to void to explicitly ignore the return value.
(void)cursor.release();
}
void CursorManager::appendActiveSessions(LogicalSessionIdSet* lsids) const {

View File

@ -148,7 +148,9 @@ Status launchServiceWorkerThread(unique_function<void()> task) {
"error"_attr = errorMessage(ec));
}
ctx.release();
// The spawned thread takes over ownership, cast to void to explicitly ignore the return
// value.
(void)ctx.release();
#endif
} catch (const std::exception& e) {

View File

@ -1700,9 +1700,10 @@ UniqueDHParams makeDefaultDHParameters() {
return nullptr;
}
// DH takes over memory management responsibilities after successfully setting these
p.release();
g.release();
// DH takes over memory management responsibilities after successfully setting these.
// Cast to void to explicitly ignore the return value.
(void)p.release();
(void)g.release();
return dhparams;
}