未验证 提交 4aad9c69 编写于 作者: Z Zhenghai Zhang 提交者: GitHub

enable bugprone-unused-raii check (#55815)

上级 6b93ba0a
...@@ -41,7 +41,7 @@ Checks: ' ...@@ -41,7 +41,7 @@ Checks: '
-bugprone-undefined-memory-manipulation, -bugprone-undefined-memory-manipulation,
-bugprone-undelegated-constructor, -bugprone-undelegated-constructor,
-bugprone-unhandled-self-assignment, -bugprone-unhandled-self-assignment,
-bugprone-unused-raii, bugprone-unused-raii,
-bugprone-unused-return-value, -bugprone-unused-return-value,
-bugprone-use-after-move, -bugprone-use-after-move,
-bugprone-virtual-near-miss, -bugprone-virtual-near-miss,
......
...@@ -77,7 +77,8 @@ std::string AESCipher::EncryptInternal(const std::string& plaintext, ...@@ -77,7 +77,8 @@ std::string AESCipher::EncryptInternal(const std::string& plaintext,
std::string ciphertext; std::string ciphertext;
m_filter->Attach(new CryptoPP::StringSink(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) { if (need_iv) {
return iv_ + ciphertext; return iv_ + ciphertext;
} }
...@@ -107,9 +108,9 @@ std::string AESCipher::DecryptInternal(const std::string& ciphertext, ...@@ -107,9 +108,9 @@ std::string AESCipher::DecryptInternal(const std::string& ciphertext,
} }
std::string plaintext; std::string plaintext;
m_filter->Attach(new CryptoPP::StringSink(plaintext)); m_filter->Attach(new CryptoPP::StringSink(plaintext));
CryptoPP::StringSource(ciphertext.substr(ciphertext_beg), CryptoPP::Redirector* filter_redirector = new CryptoPP::Redirector(*m_filter);
true, CryptoPP::StringSource(
new CryptoPP::Redirector(*m_filter)); ciphertext.substr(ciphertext_beg), true, filter_redirector);
return plaintext; return plaintext;
} }
...@@ -135,7 +136,8 @@ std::string AESCipher::AuthenticatedEncryptInternal( ...@@ -135,7 +136,8 @@ std::string AESCipher::AuthenticatedEncryptInternal(
std::string ciphertext; std::string ciphertext;
m_filter->Attach(new CryptoPP::StringSink(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) { if (need_iv) {
ciphertext = iv_.append(ciphertext); ciphertext = iv_.append(ciphertext);
} }
...@@ -165,9 +167,9 @@ std::string AESCipher::AuthenticatedDecryptInternal( ...@@ -165,9 +167,9 @@ std::string AESCipher::AuthenticatedDecryptInternal(
} }
std::string plaintext; std::string plaintext;
m_filter->Attach(new CryptoPP::StringSink(plaintext)); m_filter->Attach(new CryptoPP::StringSink(plaintext));
CryptoPP::StringSource(ciphertext.substr(ciphertext_beg), CryptoPP::Redirector* filter_redirector = new CryptoPP::Redirector(*m_filter);
true, CryptoPP::StringSource(
new CryptoPP::Redirector(*m_filter)); ciphertext.substr(ciphertext_beg), true, filter_redirector);
PADDLE_ENFORCE_EQ( PADDLE_ENFORCE_EQ(
m_filter->GetLastResult(), m_filter->GetLastResult(),
true, true,
......
...@@ -72,7 +72,7 @@ void BindGenerator(py::module* m_ptr) { ...@@ -72,7 +72,7 @@ void BindGenerator(py::module* m_ptr) {
return ostr.str(); 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") py::class_<phi::Generator, std::shared_ptr<phi::Generator>>(m, "Generator")
.def("__init__", .def("__init__",
[](phi::Generator& self) { new (&self) phi::Generator(); }) [](phi::Generator& self) { new (&self) phi::Generator(); })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册