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

enable bugprone-unused-raii check (#55815)

上级 6b93ba0a
......@@ -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,
......
......@@ -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,
......
......@@ -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(); })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册