From 7392719be2b7e00822104e3580326a4993ddd9de Mon Sep 17 00:00:00 2001 From: ccsuzzh <1719571694@qq.com> Date: Sat, 29 Jul 2023 17:18:04 +0800 Subject: [PATCH] enable bugprone-unused-raii check --- .clang-tidy | 2 +- paddle/fluid/framework/io/crypto/aes_cipher.cc | 18 ++++++++++-------- paddle/fluid/pybind/generator_py.cc | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 48acc3f66d3ae..c13a3811f0082 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -41,7 +41,7 @@ Checks: ' -bugprone-undefined-memory-manipulation, -bugprone-undelegated-constructor, -bugprone-unhandled-self-assignment, --bugprone-unused-raii, +bugprone-unused-raii, -bugprone-unused-return-value, -bugprone-use-after-move, -bugprone-virtual-near-miss, diff --git a/paddle/fluid/framework/io/crypto/aes_cipher.cc b/paddle/fluid/framework/io/crypto/aes_cipher.cc index 5c03a83663664..fd07d4d6ebfb1 100644 --- a/paddle/fluid/framework/io/crypto/aes_cipher.cc +++ b/paddle/fluid/framework/io/crypto/aes_cipher.cc @@ -77,7 +77,8 @@ std::string AESCipher::EncryptInternal(const std::string& plaintext, std::string ciphertext; m_filter->Attach(new CryptoPP::StringSink(ciphertext)); - CryptoPP::StringSource(plaintext, true, new CryptoPP::Redirector(*m_filter)); + CryptoPP::Redirector* filter_redirector = new CryptoPP::Redirector(*m_filter); + CryptoPP::StringSource(plaintext, true, filter_redirector); if (need_iv) { return iv_ + ciphertext; } @@ -107,9 +108,9 @@ std::string AESCipher::DecryptInternal(const std::string& ciphertext, } std::string plaintext; m_filter->Attach(new CryptoPP::StringSink(plaintext)); - CryptoPP::StringSource(ciphertext.substr(ciphertext_beg), - true, - new CryptoPP::Redirector(*m_filter)); + CryptoPP::Redirector* filter_redirector = new CryptoPP::Redirector(*m_filter); + CryptoPP::StringSource( + ciphertext.substr(ciphertext_beg), true, filter_redirector); return plaintext; } @@ -135,7 +136,8 @@ std::string AESCipher::AuthenticatedEncryptInternal( std::string ciphertext; m_filter->Attach(new CryptoPP::StringSink(ciphertext)); - CryptoPP::StringSource(plaintext, true, new CryptoPP::Redirector(*m_filter)); + CryptoPP::Redirector* filter_redirector = new CryptoPP::Redirector(*m_filter); + CryptoPP::StringSource(plaintext, true, filter_redirector); if (need_iv) { ciphertext = iv_.append(ciphertext); } @@ -165,9 +167,9 @@ std::string AESCipher::AuthenticatedDecryptInternal( } std::string plaintext; m_filter->Attach(new CryptoPP::StringSink(plaintext)); - CryptoPP::StringSource(ciphertext.substr(ciphertext_beg), - true, - new CryptoPP::Redirector(*m_filter)); + CryptoPP::Redirector* filter_redirector = new CryptoPP::Redirector(*m_filter); + CryptoPP::StringSource( + ciphertext.substr(ciphertext_beg), true, filter_redirector); PADDLE_ENFORCE_EQ( m_filter->GetLastResult(), true, diff --git a/paddle/fluid/pybind/generator_py.cc b/paddle/fluid/pybind/generator_py.cc index 3aab0d8e3f4ed..520fe09bc710c 100644 --- a/paddle/fluid/pybind/generator_py.cc +++ b/paddle/fluid/pybind/generator_py.cc @@ -72,7 +72,7 @@ void BindGenerator(py::module* m_ptr) { return ostr.str(); }); - py::class_(m, "mt19937_64", ""); + py::class_(m, "mt19937_64", ""); // NOLINT py::class_>(m, "Generator") .def("__init__", [](phi::Generator& self) { new (&self) phi::Generator(); })