Rewrite code a bit so clang-format doesn't break exceptions

clazy and clang-tidy comments needs to in the proper place
This commit is contained in:
Albert Astals Cid 2020-09-06 20:45:09 +02:00
parent 0fd3c4cb26
commit f88abb0697
4 changed files with 18 additions and 8 deletions

View File

@ -436,6 +436,12 @@ static void qcaCipherToBotanCipher(const QString &type, std::string *algoName, s
}
}
static std::string qcaCipherToBotanCipher(const QString &qcaCipher) {
std::string algoName, algoMode, algoPadding;
qcaCipherToBotanCipher(qcaCipher, &algoName, &algoMode, &algoPadding);
return algoName+'/'+algoMode+'/'+algoPadding; // NOLINT(performance-inefficient-string-concatenation)
}
//-----------------------------------------------------------
class BotanCipherContext : public QCA::CipherContext
{
@ -648,11 +654,10 @@ public:
list += QStringLiteral("blowfish-ofb");
for (const QString &cipher : qAsConst(list)) {
std::string algoName, algoMode, algoPadding;
qcaCipherToBotanCipher(cipher, &algoName, &algoMode, &algoPadding);
const std::string bothanCipher = qcaCipherToBotanCipher(cipher);
try {
std::unique_ptr<Botan::Keyed_Filter> enc(Botan::get_cipher(algoName+'/'+algoMode+'/'+algoPadding, Botan::ENCRYPTION)); // NOLINT(performance-inefficient-string-concatenation)
std::unique_ptr<Botan::Keyed_Filter> dec(Botan::get_cipher(algoName+'/'+algoMode+'/'+algoPadding, Botan::DECRYPTION)); // NOLINT(performance-inefficient-string-concatenation)
std::unique_ptr<Botan::Keyed_Filter> enc(Botan::get_cipher(bothanCipher, Botan::ENCRYPTION));
std::unique_ptr<Botan::Keyed_Filter> dec(Botan::get_cipher(bothanCipher, Botan::DECRYPTION));
supported += cipher;
} catch (Botan::Exception& e) {
}

View File

@ -2021,7 +2021,9 @@ CRLEntry::CRLEntry(const Certificate &c, Reason r)
_reason = r;
}
CRLEntry::CRLEntry(const BigInteger serial, const QDateTime &time, Reason r) // clazy:exclude=function-args-by-ref NOLINT(performance-unnecessary-value-param) TODO make serial const & when we break ABI
// TODO make serial const & when we break ABI
CRLEntry::CRLEntry(const BigInteger serial, // clazy:exclude=function-args-by-ref NOLINT(performance-unnecessary-value-param)
const QDateTime &time, Reason r)
{
_serial = serial;
_time = time;

View File

@ -81,7 +81,8 @@ void CertUnitTest::nullCert()
else {
QCA::Certificate nullCert;
QVERIFY(nullCert.isNull());
QCA::Certificate anotherNullCert = nullCert; // NOLINT(performance-unnecessary-copy-initialization) This is copied on purpose to check the assignment operator
// This is copied on purpose to check the assignment operator
QCA::Certificate anotherNullCert = nullCert; // NOLINT(performance-unnecessary-copy-initialization)
QVERIFY( anotherNullCert.isNull() );
QCOMPARE( nullCert, anotherNullCert );
}
@ -1114,7 +1115,8 @@ void CertUnitTest::csr()
else {
QCA::CertificateRequest nullCSR;
QVERIFY( nullCSR.isNull() );
QCA::CertificateRequest anotherNullCSR = nullCSR; // NOLINT(performance-unnecessary-copy-initialization) This is copied on purpose to check the assignment operator
// This is copied on purpose to check the assignment operator
QCA::CertificateRequest anotherNullCSR = nullCSR; // NOLINT(performance-unnecessary-copy-initialization)
QVERIFY( anotherNullCSR.isNull() );
QCOMPARE( nullCSR, anotherNullCSR);

View File

@ -64,7 +64,8 @@ void HexUnitTest::testHexString_data()
QTest::newRow("ABCD") << QStringLiteral("ABCD") << QStringLiteral("41424344");
QTest::newRow("empty") << QString(QLatin1String("")) << QString(QLatin1String(""));
QTest::newRow("abcddef") << QStringLiteral("abcddef") << QStringLiteral("61626364646566");
QTest::newRow("empty too") << QString::fromLatin1("\0") << QString::fromLatin1(""); // Empty QString. clazy:exclude=qstring-allocations
QTest::newRow("empty too") << QString::fromLatin1("\0") // clazy:exclude=qstring-allocations
<< QString::fromLatin1(""); // Empty QString. clazy:exclude=qstring-allocations
QTest::newRow("BEL") << QStringLiteral("\a") << QStringLiteral("07"); // BEL
QTest::newRow("BS") << QStringLiteral("\b") << QStringLiteral("08"); // BS
QTest::newRow("HT") << QStringLiteral("\t") << QStringLiteral("09"); // HT