From dce16514fee5494b6b14ac9853f63c1a49e417d8 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 29 Jan 2020 14:23:48 +0100 Subject: [PATCH] Enable a clazy CI Starting with only missing-qobject-macro check enabled --- .gitlab-ci.yml | 13 +++++++++++++ examples/aes-cmac/aes-cmac.cpp | 2 ++ examples/tlssocket/tlssocket.h | 1 + plugins/qca-botan/qca-botan.cpp | 6 ++++++ plugins/qca-cyrus-sasl/qca-cyrus-sasl.cpp | 1 + plugins/qca-gcrypt/qca-gcrypt.cpp | 5 +++++ plugins/qca-gnupg/mykeystoreentry.h | 1 + plugins/qca-gnupg/myopenpgpcontext.h | 1 + plugins/qca-gnupg/mypgpkeycontext.h | 1 + plugins/qca-logger/qca-logger.cpp | 1 + plugins/qca-nss/qca-nss.cpp | 3 +++ plugins/qca-ossl/qca-ossl.cpp | 15 +++++++++++++++ plugins/qca-pkcs11/qca-pkcs11.cpp | 2 ++ plugins/qca-softstore/qca-softstore.cpp | 2 ++ src/qca_core.cpp | 2 ++ src/qca_default.cpp | 4 ++++ tools/qcatool/main.cpp | 2 ++ unittest/logger/loggerunittest.cpp | 2 ++ 18 files changed, 64 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ed0e5f5b..8536704d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,3 +11,16 @@ build_ubuntu_18_04: - cmake -G Ninja .. - ninja - ctest + +build_clazy: + stage: build + image: debian:unstable + before_script: + - echo 'deb-src http://deb.debian.org/debian unstable main' >> /etc/apt/sources.list + - apt-get update + - apt-get build-dep --yes --no-install-recommends qca2 + - apt-get install --yes --no-install-recommends ninja-build libbotan-2-dev libnss3-dev libgcrypt20-dev libpkcs11-helper1-dev clazy clang + script: + - mkdir -p build && cd build + - CC=clang CXX=clazy CXXFLAGS="-Werror -Wno-deprecated-declarations" cmake -G Ninja .. + - CLAZY_CHECKS="missing-qobject-macro" ninja diff --git a/examples/aes-cmac/aes-cmac.cpp b/examples/aes-cmac/aes-cmac.cpp index f6b290b3..b1296b06 100644 --- a/examples/aes-cmac/aes-cmac.cpp +++ b/examples/aes-cmac/aes-cmac.cpp @@ -31,6 +31,7 @@ class AESCMACContext : public QCA::MACContext { + Q_OBJECT public: AESCMACContext(QCA::Provider *p) : QCA::MACContext(p, "cmac(aes)") { @@ -316,3 +317,4 @@ int main(int argc, char **argv) return 0; } +#include "aes-cmac.moc" diff --git a/examples/tlssocket/tlssocket.h b/examples/tlssocket/tlssocket.h index 2f6a3ff7..7c0bc927 100644 --- a/examples/tlssocket/tlssocket.h +++ b/examples/tlssocket/tlssocket.h @@ -26,6 +26,7 @@ class TLSSocket : public QTcpSocket { + Q_OBJECT public: TLSSocket(QObject *parent = nullptr); ~TLSSocket(); diff --git a/plugins/qca-botan/qca-botan.cpp b/plugins/qca-botan/qca-botan.cpp index 0b5368ba..e74d84c9 100644 --- a/plugins/qca-botan/qca-botan.cpp +++ b/plugins/qca-botan/qca-botan.cpp @@ -39,6 +39,7 @@ //----------------------------------------------------------- class botanRandomContext : public QCA::RandomContext { +Q_OBJECT public: botanRandomContext(QCA::Provider *p) : RandomContext(p) { @@ -83,6 +84,7 @@ static QString qcaHashToBotanHash(const QString &type) //----------------------------------------------------------- class BotanHashContext : public QCA::HashContext { +Q_OBJECT public: BotanHashContext( QCA::Provider *p, const QString &type) : QCA::HashContext(p, type) { @@ -147,6 +149,7 @@ static QString qcaHmacToBotanHmac(const QString &type) //----------------------------------------------------------- class BotanHMACContext : public QCA::MACContext { +Q_OBJECT public: BotanHMACContext(QCA::Provider *p, const QString &type) : QCA::MACContext(p, type) { @@ -218,6 +221,7 @@ static QString qcaPbkdfToBotanPbkdf(const QString &pbkdf) //----------------------------------------------------------- class BotanPBKDFContext: public QCA::KDFContext { +Q_OBJECT public: BotanPBKDFContext( QCA::Provider *p, const QString &type) : QCA::KDFContext(p, type) { @@ -295,6 +299,7 @@ static QString qcaHkdfToBotanHkdf(const QString &type) //----------------------------------------------------------- class BotanHKDFContext: public QCA::HKDFContext { + Q_OBJECT public: BotanHKDFContext(QCA::Provider *p, const QString &type) : QCA::HKDFContext(p, type) { @@ -435,6 +440,7 @@ static void qcaCipherToBotanCipher(const QString &type, std::string *algoName, s //----------------------------------------------------------- class BotanCipherContext : public QCA::CipherContext { + Q_OBJECT public: BotanCipherContext( QCA::Provider *p, const QString &type) : QCA::CipherContext(p, type) { diff --git a/plugins/qca-cyrus-sasl/qca-cyrus-sasl.cpp b/plugins/qca-cyrus-sasl/qca-cyrus-sasl.cpp index 9292af58..39f89d6a 100644 --- a/plugins/qca-cyrus-sasl/qca-cyrus-sasl.cpp +++ b/plugins/qca-cyrus-sasl/qca-cyrus-sasl.cpp @@ -213,6 +213,7 @@ static QString addrString(const SASLContext::HostPort &hp) class saslContext : public SASLContext { + Q_OBJECT saslProvider *g; // core props diff --git a/plugins/qca-gcrypt/qca-gcrypt.cpp b/plugins/qca-gcrypt/qca-gcrypt.cpp index bdd0c878..1d978cd1 100644 --- a/plugins/qca-gcrypt/qca-gcrypt.cpp +++ b/plugins/qca-gcrypt/qca-gcrypt.cpp @@ -44,6 +44,7 @@ void check_error( const QString &label, gcry_error_t err ) class gcryHashContext : public QCA::HashContext { + Q_OBJECT public: gcryHashContext(int hashAlgorithm, QCA::Provider *p, const QString &type) : QCA::HashContext(p, type) { @@ -93,6 +94,7 @@ protected: class gcryHMACContext : public QCA::MACContext { + Q_OBJECT public: gcryHMACContext(int hashAlgorithm, QCA::Provider *p, const QString &type) : QCA::MACContext(p, type) { @@ -153,6 +155,7 @@ protected: class gcryCipherContext : public QCA::CipherContext { + Q_OBJECT public: gcryCipherContext(int algorithm, int mode, bool pad, QCA::Provider *p, const QString &type) : QCA::CipherContext(p, type) { @@ -271,6 +274,7 @@ protected: class pbkdf1Context : public QCA::KDFContext { + Q_OBJECT public: pbkdf1Context(int algorithm, QCA::Provider *p, const QString &type) : QCA::KDFContext(p, type) { @@ -415,6 +419,7 @@ protected: class pbkdf2Context : public QCA::KDFContext { + Q_OBJECT public: pbkdf2Context(int algorithm, QCA::Provider *p, const QString &type) : QCA::KDFContext(p, type) { diff --git a/plugins/qca-gnupg/mykeystoreentry.h b/plugins/qca-gnupg/mykeystoreentry.h index e0c969f8..e47cdcdc 100644 --- a/plugins/qca-gnupg/mykeystoreentry.h +++ b/plugins/qca-gnupg/mykeystoreentry.h @@ -27,6 +27,7 @@ class MyKeyStoreList; class MyKeyStoreEntry : public QCA::KeyStoreEntryContext { + Q_OBJECT public: QCA::KeyStoreEntry::Type item_type; QCA::PGPKey pub, sec; diff --git a/plugins/qca-gnupg/myopenpgpcontext.h b/plugins/qca-gnupg/myopenpgpcontext.h index 115100b8..64bce90a 100644 --- a/plugins/qca-gnupg/myopenpgpcontext.h +++ b/plugins/qca-gnupg/myopenpgpcontext.h @@ -25,6 +25,7 @@ namespace gpgQCAPlugin class MyOpenPGPContext : public QCA::SMSContext { + Q_OBJECT public: MyOpenPGPContext(QCA::Provider *p); diff --git a/plugins/qca-gnupg/mypgpkeycontext.h b/plugins/qca-gnupg/mypgpkeycontext.h index 52921d4b..f23cbd02 100644 --- a/plugins/qca-gnupg/mypgpkeycontext.h +++ b/plugins/qca-gnupg/mypgpkeycontext.h @@ -27,6 +27,7 @@ namespace gpgQCAPlugin class MyPGPKeyContext : public QCA::PGPKeyContext { + Q_OBJECT public: QCA::PGPKeyContextProps _props; diff --git a/plugins/qca-logger/qca-logger.cpp b/plugins/qca-logger/qca-logger.cpp index dee72cde..1ec23fd4 100644 --- a/plugins/qca-logger/qca-logger.cpp +++ b/plugins/qca-logger/qca-logger.cpp @@ -31,6 +31,7 @@ namespace loggerQCAPlugin { class StreamLogger : public QCA::AbstractLogDevice { + Q_OBJECT public: StreamLogger(QTextStream &stream) : QCA::AbstractLogDevice( "Stream logger" ), _stream(stream) { diff --git a/plugins/qca-nss/qca-nss.cpp b/plugins/qca-nss/qca-nss.cpp index 6d7191a1..2c1e2313 100644 --- a/plugins/qca-nss/qca-nss.cpp +++ b/plugins/qca-nss/qca-nss.cpp @@ -30,6 +30,7 @@ //----------------------------------------------------------- class nssHashContext : public QCA::HashContext { + Q_OBJECT public: nssHashContext( QCA::Provider *p, const QString &type) : QCA::HashContext(p, type) { @@ -139,6 +140,7 @@ private: //----------------------------------------------------------- class nssHmacContext : public QCA::MACContext { + Q_OBJECT public: nssHmacContext( QCA::Provider *p, const QString &type) : QCA::MACContext(p, type) { @@ -273,6 +275,7 @@ private: //----------------------------------------------------------- class nssCipherContext : public QCA::CipherContext { + Q_OBJECT public: nssCipherContext( QCA::Provider *p, const QString &type) : QCA::CipherContext(p, type) { diff --git a/plugins/qca-ossl/qca-ossl.cpp b/plugins/qca-ossl/qca-ossl.cpp index 96839965..c3b9d0e9 100644 --- a/plugins/qca-ossl/qca-ossl.cpp +++ b/plugins/qca-ossl/qca-ossl.cpp @@ -1031,6 +1031,7 @@ EVP_PKEY *qca_d2i_PKCS8PrivateKey(const SecureArray &in, EVP_PKEY **x, pem_passw class opensslHashContext : public HashContext { + Q_OBJECT public: opensslHashContext(const EVP_MD *algorithm, Provider *p, const QString &type) : HashContext(p, type) { @@ -1084,6 +1085,7 @@ protected: class opensslPbkdf1Context : public KDFContext { + Q_OBJECT public: opensslPbkdf1Context(const EVP_MD *algorithm, Provider *p, const QString &type) : KDFContext(p, type) { @@ -1223,6 +1225,7 @@ protected: class opensslPbkdf2Context : public KDFContext { + Q_OBJECT public: opensslPbkdf2Context(Provider *p, const QString &type) : KDFContext(p, type) { @@ -1283,6 +1286,7 @@ protected: #ifdef OSSL_110 class opensslHkdfContext : public HKDFContext { + Q_OBJECT public: opensslHkdfContext(Provider *p, const QString &type) : HKDFContext(p, type) { @@ -1313,6 +1317,7 @@ public: class opensslHMACContext : public MACContext { + Q_OBJECT public: opensslHMACContext(const EVP_MD *algorithm, Provider *p, const QString &type) : MACContext(p, type) { @@ -3003,6 +3008,7 @@ static RSA *createFromExisting(const RSAPrivateKey &key) //---------------------------------------------------------------------------- class MyPKeyContext : public PKeyContext { + Q_OBJECT public: PKeyBase *k; @@ -3495,6 +3501,7 @@ static bool sameChain(STACK_OF(X509) *ossl, const QList &q // TODO: support read/write of multiple info values with the same name class MyCertContext : public CertContext { + Q_OBJECT public: X509Item item; CertContextProps _props; @@ -3926,6 +3933,7 @@ bool sameChain(STACK_OF(X509) *ossl, const QList &qca) // Thanks to Pascal Patry class MyCAContext : public CAContext { + Q_OBJECT public: X509Item caCert; MyPKeyContext *privateKey; @@ -4094,6 +4102,7 @@ public: //---------------------------------------------------------------------------- class MyCSRContext : public CSRContext { + Q_OBJECT public: X509Item item; CertContextProps _props; @@ -4381,6 +4390,7 @@ public: //---------------------------------------------------------------------------- class MyCRLContext : public CRLContext { + Q_OBJECT public: X509Item item; CRLContextProps _props; @@ -4883,6 +4893,7 @@ Validity MyCertContext::validate_chain(const QList &chain, const Q class MyPKCS12Context : public PKCS12Context { + Q_OBJECT public: MyPKCS12Context(Provider *p) : PKCS12Context(p) { @@ -5551,6 +5562,7 @@ static QString cipherIDtoString( const TLS::Version &version, const unsigned lon static bool ssl_init = false; class MyTLSContext : public TLSContext { + Q_OBJECT public: enum { Good, TryAgain, Bad }; enum { Idle, Connect, Accept, Handshake, Active, Closing }; @@ -6355,6 +6367,7 @@ public: class CMSContext : public SMSContext { + Q_OBJECT public: CertificateCollection trustedCerts; CertificateCollection untrustedCerts; @@ -6992,6 +7005,7 @@ MessageContext *CMSContext::createMessage() class opensslCipherContext : public CipherContext { + Q_OBJECT public: opensslCipherContext(const EVP_CIPHER *algorithm, const int pad, Provider *p, const QString &type) : CipherContext(p, type) { @@ -7316,6 +7330,7 @@ public: class opensslRandomContext : public RandomContext { + Q_OBJECT public: opensslRandomContext(QCA::Provider *p) : RandomContext(p) { diff --git a/plugins/qca-pkcs11/qca-pkcs11.cpp b/plugins/qca-pkcs11/qca-pkcs11.cpp index bdb21245..88bbe4b4 100644 --- a/plugins/qca-pkcs11/qca-pkcs11.cpp +++ b/plugins/qca-pkcs11/qca-pkcs11.cpp @@ -1042,6 +1042,7 @@ private: //---------------------------------------------------------------------------- class pkcs11PKeyContext : public PKeyContext { + Q_OBJECT private: PKeyBase *_k; @@ -1195,6 +1196,7 @@ public: //---------------------------------------------------------------------------- class pkcs11KeyStoreEntryContext : public KeyStoreEntryContext { + Q_OBJECT private: KeyStoreEntry::Type _item_type; KeyBundle _key; diff --git a/plugins/qca-softstore/qca-softstore.cpp b/plugins/qca-softstore/qca-softstore.cpp index 4a640615..72ac090c 100644 --- a/plugins/qca-softstore/qca-softstore.cpp +++ b/plugins/qca-softstore/qca-softstore.cpp @@ -475,6 +475,7 @@ public: class softstorePKeyContext : public PKeyContext { + Q_OBJECT private: PKeyBase *_k; @@ -625,6 +626,7 @@ public: class softstoreKeyStoreEntryContext : public KeyStoreEntryContext { + Q_OBJECT private: KeyStoreEntry::Type _item_type; KeyBundle _key; diff --git a/src/qca_core.cpp b/src/qca_core.cpp index 0120bcd3..28914a05 100644 --- a/src/qca_core.cpp +++ b/src/qca_core.cpp @@ -2124,6 +2124,7 @@ public Q_SLOTS: class PasswordAsker::Private : public AskerPrivate { + Q_OBJECT public: Private(PasswordAsker *_q) : AskerPrivate(_q) { @@ -2185,6 +2186,7 @@ SecureArray PasswordAsker::password() const //---------------------------------------------------------------------------- class TokenAsker::Private : public AskerPrivate { + Q_OBJECT public: Private(TokenAsker *_q) : AskerPrivate(_q) { diff --git a/src/qca_default.cpp b/src/qca_default.cpp index 8a484e3a..05c2ee7a 100644 --- a/src/qca_default.cpp +++ b/src/qca_default.cpp @@ -87,6 +87,7 @@ public: //---------------------------------------------------------------------------- class DefaultRandomContext : public RandomContext { + Q_OBJECT public: DefaultRandomContext(Provider *p) : RandomContext(p) {} @@ -512,6 +513,7 @@ md5_finish(md5_state_t *pms, md5_byte_t digest[16]) class DefaultMD5Context : public HashContext { + Q_OBJECT public: DefaultMD5Context(Provider *p) : HashContext(p, "md5") { @@ -609,6 +611,7 @@ typedef union { class DefaultSHA1Context : public HashContext { + Q_OBJECT public: SHA1_CONTEXT _context; #ifdef Q_PROCESSOR_ARM @@ -905,6 +908,7 @@ static bool entry_deserialize(const QString &in, QString *storeId, QString *stor class DefaultKeyStoreEntry : public KeyStoreEntryContext { + Q_OBJECT public: KeyStoreEntry::Type _type; QString _id, _name, _storeId, _storeName; diff --git a/tools/qcatool/main.cpp b/tools/qcatool/main.cpp index 1625a651..90bacc93 100644 --- a/tools/qcatool/main.cpp +++ b/tools/qcatool/main.cpp @@ -75,6 +75,7 @@ static QStringList wrapstring(const QString &str, int width) class StreamLogger : public QCA::AbstractLogDevice { + Q_OBJECT public: StreamLogger(QTextStream &stream) : QCA::AbstractLogDevice( "Stream logger" ), _stream(stream) { @@ -681,6 +682,7 @@ private Q_SLOTS: class PassphrasePromptThread : public QCA::SyncThread { + Q_OBJECT public: PassphrasePrompt *pp; diff --git a/unittest/logger/loggerunittest.cpp b/unittest/logger/loggerunittest.cpp index 126f0c0d..5e435f94 100644 --- a/unittest/logger/loggerunittest.cpp +++ b/unittest/logger/loggerunittest.cpp @@ -48,6 +48,7 @@ private: class NullLogger : public QCA::AbstractLogDevice { + Q_OBJECT public: NullLogger() : QCA::AbstractLogDevice( "null logger" ) {} @@ -58,6 +59,7 @@ public: class LastLogger : public QCA::AbstractLogDevice { + Q_OBJECT public: LastLogger() : QCA::AbstractLogDevice( "last logger" ) {}