Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang-tidy] NO.45 enable bugprone-unused-raii check #55815

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 10 additions & 8 deletions paddle/fluid/framework/io/crypto/aes_cipher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/pybind/generator_py.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void BindGenerator(py::module* m_ptr) {
return ostr.str();
});

py::class_<std::mt19937_64>(m, "mt19937_64", "");
py::class_<std::mt19937_64>(m, "mt19937_64", ""); // NOLINT
py::class_<phi::Generator, std::shared_ptr<phi::Generator>>(m, "Generator")
.def("__init__",
[](phi::Generator& self) { new (&self) phi::Generator(); })
Expand Down