From 993da2d474bb8a51668a6fc5e99f9417175f3beb Mon Sep 17 00:00:00 2001 From: Christian Hohnstaedt Date: Sun, 8 Oct 2023 01:11:03 +0200 Subject: [PATCH] Use C++11 initializers for all non-static class members When XCA started in 2002, there were no C++ initializers. Drop explicit initializers from the constructors. - Fix indentations of section declarators. - Replace NULL by nullptr when feasible. - Sort private section: properties first, then methods. --- lib/BioByteArray.h | 19 +++++------ lib/Passwd.h | 2 +- lib/PwDialogCore.h | 6 ++-- lib/XcaProgress.h | 12 +++---- lib/XcaWarningCore.h | 6 ++-- lib/arguments.cpp | 1 - lib/arguments.h | 26 +++++++-------- lib/asn1int.h | 7 ++-- lib/asn1time.cpp | 16 --------- lib/asn1time.h | 6 ++-- lib/builtin_curves.h | 28 ++++++++-------- lib/database_model.cpp | 2 +- lib/database_model.h | 15 +++++---- lib/db_base.cpp | 6 +--- lib/db_base.h | 25 +++++++------- lib/db_temp.h | 6 ++-- lib/db_token.h | 3 +- lib/dbhistory.cpp | 1 - lib/dbhistory.h | 2 +- lib/dhgen.h | 10 +++--- lib/digest.h | 3 +- lib/entropy.h | 6 ++-- lib/exception.h | 2 +- lib/headerlist.h | 62 +++++++++++++---------------------- lib/load_obj.h | 4 +-- lib/main.h | 3 +- lib/pass_info.cpp | 8 ++--- lib/pass_info.h | 18 +++++----- lib/pk11_attribute.h | 8 ++--- lib/pkcs11.h | 7 ++-- lib/pkcs11_lib.cpp | 1 - lib/pkcs11_lib.h | 13 ++++---- lib/pki_base.cpp | 11 +------ lib/pki_base.h | 26 +++++++-------- lib/pki_crl.cpp | 2 +- lib/pki_crl.h | 31 +++++++++--------- lib/pki_export.h | 4 +-- lib/pki_key.h | 13 ++++---- lib/pki_multi.h | 2 +- lib/pki_pkcs12.cpp | 1 - lib/pki_pkcs12.h | 12 +++---- lib/pki_pkcs7.cpp | 1 - lib/pki_pkcs7.h | 2 +- lib/pki_scard.cpp | 5 +-- lib/pki_scard.h | 16 ++++----- lib/pki_temp.cpp | 9 ++--- lib/pki_temp.h | 16 ++++----- lib/pki_x509.cpp | 7 +--- lib/pki_x509.h | 16 ++++----- lib/pki_x509req.cpp | 3 +- lib/pki_x509req.h | 6 ++-- lib/pki_x509super.h | 6 ++-- lib/settings.cpp | 10 ++++-- lib/settings.h | 20 +++++------ lib/sql.cpp | 5 --- lib/sql.h | 4 +-- lib/x509name.cpp | 2 -- lib/x509name.h | 2 +- lib/x509rev.h | 7 ++-- lib/x509v3ext.cpp | 7 ++-- lib/x509v3ext.h | 2 +- widgets/CertDetail.h | 8 ++--- widgets/CertExtend.h | 2 +- widgets/CrlDetail.cpp | 2 +- widgets/CrlDetail.h | 2 +- widgets/ExportDialog.h | 8 ++--- widgets/FocusCombo.h | 2 +- widgets/Help.cpp | 2 +- widgets/Help.h | 6 ++-- widgets/ImportMulti.h | 4 +-- widgets/ItemCombo.h | 2 +- widgets/KeyDetail.cpp | 2 +- widgets/KeyDetail.h | 2 +- widgets/KeyTreeView.h | 4 +-- widgets/MainWindow.cpp | 4 --- widgets/MainWindow.h | 26 +++++++-------- widgets/NewCrl.h | 6 ++-- widgets/NewX509.cpp | 8 ++--- widgets/NewX509.h | 41 ++++++++++++----------- widgets/OpenDb.h | 2 +- widgets/Options.cpp | 1 - widgets/Options.h | 4 +-- widgets/PwDialog.cpp | 2 +- widgets/PwDialog.h | 6 ++-- widgets/RevocationList.cpp | 5 +-- widgets/RevocationList.h | 4 +-- widgets/TempTreeView.h | 6 ++-- widgets/X509SuperTreeView.cpp | 1 - widgets/X509SuperTreeView.h | 13 +++----- widgets/XcaApplication.cpp | 2 +- widgets/XcaApplication.h | 12 +++---- widgets/XcaDetail.cpp | 2 +- widgets/XcaDetail.h | 6 ++-- widgets/XcaDialog.h | 2 +- widgets/XcaProgressGui.h | 10 +++--- widgets/XcaProxyModel.h | 2 +- widgets/XcaTreeView.cpp | 4 --- widgets/XcaTreeView.h | 16 ++++----- widgets/XcaWarning.h | 2 +- widgets/clicklabel.h | 2 +- widgets/distname.h | 6 ++-- widgets/hashBox.h | 12 ++++--- widgets/kvView.cpp | 4 ++- widgets/kvView.h | 45 ++++++++++++------------- widgets/pkcs12EncBox.h | 2 +- widgets/v3ext.cpp | 6 ++-- widgets/v3ext.h | 17 +++++----- widgets/validity.cpp | 6 ++-- widgets/validity.h | 4 +-- 109 files changed, 417 insertions(+), 502 deletions(-) diff --git a/lib/BioByteArray.h b/lib/BioByteArray.h index 3db8fdc5..1cddb3bf 100644 --- a/lib/BioByteArray.h +++ b/lib/BioByteArray.h @@ -14,23 +14,20 @@ class BioByteArray { - protected: - BIO *read_write; - BIO *read_only; - QByteArray store; + protected: + BIO *read_write{}; + BIO *read_only{}; + QByteArray store{}; void set(const QByteArray &qba); void add(const QByteArray &qba); void biowrite(const QByteArray &qba); void cleanse_and_free(BIO *bio); - public: - BioByteArray(const QByteArray &qba) : - read_write(NULL), read_only(NULL), store(qba) { } - BioByteArray(const BioByteArray &bba) : - read_write(NULL), read_only(NULL), store(bba.byteArray()) { } - BioByteArray() : - read_write(NULL), read_only(NULL), store() { } + public: + BioByteArray(const QByteArray &qba) : store(qba) { } + BioByteArray(const BioByteArray &bba) : store(bba.byteArray()) { } + BioByteArray() { } ~BioByteArray(); int size() const; BIO *bio(); diff --git a/lib/Passwd.h b/lib/Passwd.h index eead501a..620b8bc7 100644 --- a/lib/Passwd.h +++ b/lib/Passwd.h @@ -12,7 +12,7 @@ class Passwd: public QByteArray { - public: + public: void cleanse(); ~Passwd(); unsigned char *constUchar() const; diff --git a/lib/PwDialogCore.h b/lib/PwDialogCore.h index 49fb2a06..c202809a 100644 --- a/lib/PwDialogCore.h +++ b/lib/PwDialogCore.h @@ -14,7 +14,7 @@ class PwDialogUI_i { - public: + public: virtual enum open_result execute(pass_info *p, Passwd *passwd, bool write = false, bool abort = false) = 0; virtual ~PwDialogUI_i() { }; @@ -22,10 +22,10 @@ class PwDialogUI_i class PwDialogCore { - private: + private: static PwDialogUI_i *pwdialog; - public: + public: static Passwd cmdline_passwd; static enum open_result execute(pass_info *p, Passwd *passwd, bool write = false, bool abort = false); diff --git a/lib/XcaProgress.h b/lib/XcaProgress.h index 78d71348..e1d3d6f9 100644 --- a/lib/XcaProgress.h +++ b/lib/XcaProgress.h @@ -12,7 +12,7 @@ class XcaProgress_i { - public: + public: XcaProgress_i() = default; virtual void start(const QString &what, int max) = 0; virtual void stop() = 0; @@ -22,10 +22,10 @@ class XcaProgress_i class XcaProgressCmd : public XcaProgress_i { - private: - int i; + private: + int i{}; - public: + public: void start(const QString &what, int max); void stop(); void increment(); @@ -33,10 +33,10 @@ class XcaProgressCmd : public XcaProgress_i class XcaProgress { - private: + private: static XcaProgress_i *progress; - public: + public: XcaProgress(const QString &what = QString(), int max = 100); ~XcaProgress(); void increment(); diff --git a/lib/XcaWarningCore.h b/lib/XcaWarningCore.h index d5c2be49..d8e0c5e0 100644 --- a/lib/XcaWarningCore.h +++ b/lib/XcaWarningCore.h @@ -24,7 +24,7 @@ class xcaWarning_i { - public: + public: virtual void information(const QString &msg) = 0; virtual void warning(const QString &msg) = 0; virtual void warningv3(const QString &msg, const extList &el) = 0; @@ -39,7 +39,7 @@ class xcaWarningCore : public QObject, public xcaWarning_i { Q_OBJECT - public: + public: void information(const QString &msg); void warning(const QString &msg); bool yesno(const QString &msg); @@ -53,7 +53,7 @@ class xcaWarning { static class xcaWarning_i *gui; - public: + public: xcaWarning() = delete; xcaWarning(const xcaWarningCore &) = delete; ~xcaWarning() = delete; diff --git a/lib/arguments.cpp b/lib/arguments.cpp index df28c89c..4adc4131 100644 --- a/lib/arguments.cpp +++ b/lib/arguments.cpp @@ -271,7 +271,6 @@ int arguments::parse(int argc, char *argv[]) arguments::arguments(int argc, char *argv[]) { - need_db = false; parse(argc, argv); } diff --git a/lib/arguments.h b/lib/arguments.h index 7cf94b9b..5f0ffd7d 100644 --- a/lib/arguments.h +++ b/lib/arguments.h @@ -22,13 +22,13 @@ enum { class arg_option { - public: - const char *long_opt; - const char *arg; - int arg_type; - bool no_gui; - bool need_db; - QString help; + public: + const char *long_opt{}; + const char *arg{}; + int arg_type{}; + bool no_gui{}; + bool need_db{}; + QString help{}; arg_option(const char *l, const char *a, int has_arg, bool n, bool nd, const char *h); @@ -37,14 +37,14 @@ class arg_option class arguments { - private: + private: static const QList opts; - int result; - QMap found_options; - QStringList files; - bool need_db; + int result{}; + QMap found_options{}; + QStringList files{}; + bool need_db{ false }; - public: + public: static bool is_console(int argc, char *argv[]); static QString help(); static QString man(); diff --git a/lib/asn1int.h b/lib/asn1int.h index b048ba0d..2948509a 100644 --- a/lib/asn1int.h +++ b/lib/asn1int.h @@ -13,12 +13,13 @@ class a1int { - private: - ASN1_INTEGER *in; + private: + ASN1_INTEGER *in{}; ASN1_INTEGER *dup(const ASN1_INTEGER *a) const; a1int &setQString(const QString &s, int dec); QString toQString(int dec) const; - public: + + public: a1int(); a1int(const ASN1_INTEGER *i); a1int(const a1int &a); diff --git a/lib/asn1time.cpp b/lib/asn1time.cpp index 53e2dfe8..f296e0d7 100644 --- a/lib/asn1time.cpp +++ b/lib/asn1time.cpp @@ -77,42 +77,26 @@ int a1time::set_asn1(const QString &str, int type) return 0; } -a1time::a1time(const QDateTime &a) - : QDateTime(a) -{ - atime = NULL; -} - -a1time::a1time(const a1time &a) - : QDateTime(a) -{ - atime = NULL; -} - a1time &a1time::operator = (const a1time &a) { if (atime) ASN1_TIME_free(atime); - atime = NULL; QDateTime::operator=(a); return *this; } a1time::a1time() { - atime = NULL; *this = now(); } a1time::a1time(const ASN1_TIME *a) { - atime = NULL; from_asn1(a); } a1time::a1time(const QString &plain) { - atime = NULL; fromPlain(plain); } diff --git a/lib/asn1time.h b/lib/asn1time.h index 54bd450d..8c864077 100644 --- a/lib/asn1time.h +++ b/lib/asn1time.h @@ -22,15 +22,15 @@ class a1time : public QDateTime { private: - ASN1_TIME *atime; + ASN1_TIME *atime{}; int from_asn1(const ASN1_TIME *a); int set_asn1(const QString &str, int type); public: a1time(); - a1time(const QDateTime &a); + a1time(const QDateTime &a) : QDateTime(a) { }; + a1time(const a1time &a) : QDateTime(a) { }; a1time(const ASN1_TIME *a); - a1time(const a1time &a); a1time(const QString &plain); a1time &operator = (const a1time &a); ~a1time(); diff --git a/lib/builtin_curves.h b/lib/builtin_curves.h index cbd914b7..7019d0c8 100644 --- a/lib/builtin_curves.h +++ b/lib/builtin_curves.h @@ -1,4 +1,5 @@ -/* +/* vi: set sw=4 ts=4: + * * Copyright (C) 2014 - 2020 Christian Hohnstaedt. * * All rights reserved. @@ -18,25 +19,22 @@ class builtin_curve { - public: - int nid; - QString comment; - unsigned order_size; - int flags; + public: + int nid{}; + QString comment{}; + unsigned order_size{}; + int flags{}; /* type: CKF_EC_F_P || CKF_EC_F_2M */ - unsigned long type; - builtin_curve(int n, QString c, int s, int f, int t) { - nid = n; - comment = c; - order_size = s; - flags = f; - type = t; - }; + unsigned long type{}; + + builtin_curve(int n, QString c, int s, int f, int t) + : nid(n), comment(c), order_size(s), flags(f), type(t) { }; + builtin_curve() = delete; }; class builtin_curves: public QList { - public: + public: builtin_curves(); bool containNid(int nid) { diff --git a/lib/database_model.cpp b/lib/database_model.cpp index 2e315d96..6d2dbea9 100644 --- a/lib/database_model.cpp +++ b/lib/database_model.cpp @@ -140,9 +140,9 @@ database_model::database_model(const QString &name, const Passwd &pass) #ifndef APPSTORE_COMPLIANT dbName = name; #else + (void)name; dbName = "default.xdb"; #endif - dbTimer = 0; if (dbName.isEmpty()) dbName = get_default_db(); diff --git a/lib/database_model.h b/lib/database_model.h index 1a47042a..5164aa1f 100644 --- a/lib/database_model.h +++ b/lib/database_model.h @@ -25,12 +25,13 @@ class database_model: public QObject Q_OBJECT private: - QList models; - int dbTimer; + QList models{}; + int dbTimer{}; + QString dbName{}; + QString db_provider{}; void openSqlDB(); + QSqlError initSqlDB(); - QString dbName; - QString db_provider; const QString &detect_provider(); bool checkForOldDbFormat(const QString &dbfile) const; enum open_result verifyOldDbPass(const QString &dbname) const; @@ -74,7 +75,7 @@ class database_model: public QObject if (m) return m; } - return NULL; + return nullptr; } pki_base *insert(pki_base *pki); @@ -89,10 +90,10 @@ class database_model: public QObject class xca_db { private: - database_model *db; + database_model *db{}; public: - xca_db() : db(nullptr) { } + xca_db() { } ~xca_db() { close(); diff --git a/lib/db_base.cpp b/lib/db_base.cpp index 13178f24..bb6f3fc8 100644 --- a/lib/db_base.cpp +++ b/lib/db_base.cpp @@ -33,10 +33,7 @@ db_base::db_base(const char *classname) { rootItem = new pki_base(QString("ROOTitem(%1)").arg(classname)); treeItem = new pki_base(QString("TREEitem(%1)").arg(classname)); - colResizing = 0; class_name = classname; - secondsTimer = minutesTimer = hoursTimer = 0; - treeview = true; restart_timer(); } @@ -48,9 +45,8 @@ db_base::~db_base() delete treeItem; } -pki_base *db_base::newPKI(enum pki_type type) +pki_base *db_base::newPKI(enum pki_type) { - (void)type; return new pki_base(); } diff --git a/lib/db_base.h b/lib/db_base.h index d3580845..eed527f4 100644 --- a/lib/db_base.h +++ b/lib/db_base.h @@ -28,23 +28,24 @@ class db_base: public QAbstractItemModel Q_OBJECT protected: - int secondsTimer, minutesTimer, hoursTimer; - void _writePKI(pki_base *pki, bool overwrite); - QList pkitype; - QList pkitype_depends; - QString class_name; + int secondsTimer{}, minutesTimer{}, hoursTimer{}; + QList pkitype{}; + QList pkitype_depends{}; + QString class_name{}; /* Sql table containing the 'hash' of this items */ - QString sqlHashTable; - dbheaderList allHeaders; + QString sqlHashTable{}; + dbheaderList allHeaders{}; + int colResizing{}; + bool treeview{ true }; + pki_base *rootItem{}; + pki_base *treeItem{}; + QVariant selected{}; + + void _writePKI(pki_base *pki, bool overwrite); virtual dbheaderList getHeaders(); - int colResizing; QString sqlItemSelector(); bool isValidCol(int col) const; void timerEvent(QTimerEvent *event); - bool treeview; - pki_base *rootItem; - pki_base *treeItem; - QVariant selected; public: void restart_timer(); diff --git a/lib/db_temp.h b/lib/db_temp.h index 1a53b246..2a75b29b 100644 --- a/lib/db_temp.h +++ b/lib/db_temp.h @@ -16,10 +16,10 @@ class pki_temp; class db_temp: public db_x509name { Q_OBJECT - protected: - QList predefs; + protected: + QList predefs{}; - public: + public: db_temp(); ~db_temp(); pki_base *newPKI(enum pki_type type = none); diff --git a/lib/db_token.h b/lib/db_token.h index 10b223c4..f3a6f5c8 100644 --- a/lib/db_token.h +++ b/lib/db_token.h @@ -16,7 +16,8 @@ class db_token: public db_base { Q_OBJECT private: - slotid slot; + slotid slot{}; + public: db_token(); bool setData(const QModelIndex &index, diff --git a/lib/dbhistory.cpp b/lib/dbhistory.cpp index 019d2014..b13943b2 100644 --- a/lib/dbhistory.cpp +++ b/lib/dbhistory.cpp @@ -30,7 +30,6 @@ dbhistory::dbhistory() return; } - history.clear(); while (!file.atEnd()) { QByteArray ba; ba = file.readLine(1024); diff --git a/lib/dbhistory.h b/lib/dbhistory.h index 53d10826..0aac6546 100644 --- a/lib/dbhistory.h +++ b/lib/dbhistory.h @@ -13,7 +13,7 @@ class dbhistory { private: - QStringList history; + QStringList history{}; static QString lastRemote; public: diff --git a/lib/dhgen.h b/lib/dhgen.h index 90a72c8b..5d6abf41 100644 --- a/lib/dhgen.h +++ b/lib/dhgen.h @@ -15,16 +15,16 @@ class DHgen: public QThread { - QString fname; - int bits; - errorEx err; + QString fname{}; + int bits{}; + errorEx err{}; - public: + public: DHgen(const QString &n, int b) : QThread(), fname(n), bits(b) {} QString filename() const { return fname; } errorEx error() const { return err; } - protected: + protected: void run(); }; #endif diff --git a/lib/digest.h b/lib/digest.h index 3f0d59c0..e9454f3e 100644 --- a/lib/digest.h +++ b/lib/digest.h @@ -15,11 +15,12 @@ class digest { private: static int default_md; - int md_nid; + int md_nid{ NID_sha256 }; public: static const QList all_digests; + digest() { }; digest(int nid); digest(const EVP_MD *md); digest(const QString &name); diff --git a/lib/entropy.h b/lib/entropy.h index 5f0097f5..93363c54 100644 --- a/lib/entropy.h +++ b/lib/entropy.h @@ -14,15 +14,15 @@ class Entropy { - protected: - QString rnd; + protected: + QString rnd{}; static QElapsedTimer timer; static unsigned char pool[512]; static unsigned pool_pos; static unsigned seed_strength; static int random_from_file(QString fname, unsigned amount, int weakness=1); - public: + public: Entropy(); ~Entropy(); static void add(int rand); diff --git a/lib/exception.h b/lib/exception.h index 09c1beee..96e9aa42 100644 --- a/lib/exception.h +++ b/lib/exception.h @@ -24,7 +24,7 @@ enum open_result { class errorEx { protected: - QString msg; + QString msg{}; public: errorEx(QString txt = "", QString className = "") diff --git a/lib/headerlist.h b/lib/headerlist.h index 174681d4..124409ef 100644 --- a/lib/headerlist.h +++ b/lib/headerlist.h @@ -61,20 +61,10 @@ class dbheader { - protected: - void init() - { - id = HD_undef; - action = NULL; - show = showDefault = false; - size = -1; - visualIndex = -1; - sortIndicator = -1; - type = hd_default; - } - QString name, tooltip; + protected: + QString name{}, tooltip{}; - public: + public: enum hdr_type { hd_default, hd_x509name, @@ -84,30 +74,23 @@ class dbheader hd_asn1time, hd_key, }; - int id; - bool show; - bool showDefault; + int id{ HD_undef }; + bool show{ false }; + bool showDefault{ false }; + QAction *action{}; + int size{ -1 }; + int visualIndex{ -1 }; + int sortIndicator{ -1 }; + enum hdr_type type{ hd_default }; + virtual QString getName() { return name; } virtual QString getTooltip() { return tooltip; } - QAction *action; - int size; - int visualIndex; - int sortIndicator; - enum hdr_type type; - dbheader(QString aname = QString()) - { - init(); - name = aname; - } + dbheader(QString aname = QString()) : name(aname) { } dbheader(int aid, bool ashow = false, QString aname = QString(), QString atip = QString()) + : name(aname), tooltip(atip), id(aid), show(ashow), showDefault(ashow) { - init(); - id = aid; - name = aname; - tooltip = atip; - show = showDefault = ashow; } virtual ~dbheader() { } @@ -136,11 +119,12 @@ class dbheader } QString toData() { - QStringList sl; sl - << QString::number(visualIndex) - << QString::number(sortIndicator) - << QString::number(size) - << QString::number(show); + QStringList sl{ + QString::number(visualIndex), + QString::number(sortIndicator), + QString::number(size), + QString::number(show) + }; return sl.join(" "); } void fromData(QString s) @@ -185,10 +169,10 @@ class dbheader class nid_dbheader : public dbheader { - private: - QString sn; + private: + QString sn{}; - public: + public: nid_dbheader(int aid, enum hdr_type atype) : dbheader(aid, aid == NID_commonName) { diff --git a/lib/load_obj.h b/lib/load_obj.h index 23ea0b4b..a3559ed2 100644 --- a/lib/load_obj.h +++ b/lib/load_obj.h @@ -16,8 +16,8 @@ class pki_base; class load_base { public: - QString filter; - QString caption; + QString filter{}; + QString caption{}; load_base(); virtual ~load_base(); virtual pki_base *loadItem(const QString &s); diff --git a/lib/main.h b/lib/main.h index 58b81991..3ab5affd 100644 --- a/lib/main.h +++ b/lib/main.h @@ -16,8 +16,7 @@ class MainWindow; extern MainWindow *mainwin; extern char segv_data[1024]; -//extern bool exitApp; -pki_multi *probeAnything(const QString &, int *ret = NULL); +pki_multi *probeAnything(const QString &, int *ret = nullptr); int exportIndex(const QString &fname, bool hierarchy); #endif diff --git a/lib/pass_info.cpp b/lib/pass_info.cpp index 884f3ddf..5056dee6 100644 --- a/lib/pass_info.cpp +++ b/lib/pass_info.cpp @@ -8,13 +8,9 @@ #include "pass_info.h" pass_info::pass_info(const QString &t, const QString &d, QWidget *w) + : title(t), description(d), widget(w), + type(tr("Password")), pixmap(QString(":keyImg")), result(pw_ok) { - title = t; - description = d; - widget = w; - type = tr("Password"); - pixmap = QString(":keyImg"); - result = pw_ok; } void pass_info::setPin() diff --git a/lib/pass_info.h b/lib/pass_info.h index 9be3008a..793aa17b 100644 --- a/lib/pass_info.h +++ b/lib/pass_info.h @@ -20,16 +20,16 @@ class pass_info: public QObject { Q_OBJECT - private: - QString title; - QString description; - QWidget *widget; - QString type; - QString pixmap; - enum open_result result; + private: + QString title{}; + QString description{}; + QWidget *widget{}; + QString type{}; + QString pixmap{}; + enum open_result result{}; - public: - pass_info(const QString &t, const QString &d, QWidget *w = NULL); + public: + pass_info(const QString &t, const QString &d, QWidget *w = nullptr); QString getTitle() const { return title; diff --git a/lib/pk11_attribute.h b/lib/pk11_attribute.h index 47d9d274..6c49ce19 100644 --- a/lib/pk11_attribute.h +++ b/lib/pk11_attribute.h @@ -22,13 +22,13 @@ class pk11_attlist; class pk11_attribute { friend class pk11_attlist; -protected: - CK_ATTRIBUTE attr; -public: + protected: + CK_ATTRIBUTE attr{}; + + public: pk11_attribute(unsigned long type) { - memset(&attr, 0, sizeof(attr)); attr.type = type; } virtual ~pk11_attribute() { } diff --git a/lib/pkcs11.h b/lib/pkcs11.h index c74a694d..e9bffef3 100644 --- a/lib/pkcs11.h +++ b/lib/pkcs11.h @@ -39,12 +39,9 @@ extern char segv_data[1024]; class tkInfo { private: - CK_TOKEN_INFO token_info; + CK_TOKEN_INFO token_info{}; public: - tkInfo() - { - memset(&token_info, 0, sizeof token_info); - } + tkInfo() { } tkInfo(const CK_TOKEN_INFO *ti) { set(ti); diff --git a/lib/pkcs11_lib.cpp b/lib/pkcs11_lib.cpp index a87ada10..23ec7b71 100644 --- a/lib/pkcs11_lib.cpp +++ b/lib/pkcs11_lib.cpp @@ -22,7 +22,6 @@ pkcs11_lib::pkcs11_lib(const QString &f) CK_RV (*c_get_function_list)(CK_FUNCTION_LIST_PTR_PTR); CK_RV rv; file = name2File(f, &enabled); - p11 = NULL; if (!enabled) return; diff --git a/lib/pkcs11_lib.h b/lib/pkcs11_lib.h index daeb48ac..7d341cb5 100644 --- a/lib/pkcs11_lib.h +++ b/lib/pkcs11_lib.h @@ -20,14 +20,15 @@ class pkcs11_lib : public QLibrary { Q_OBJECT - private: - CK_FUNCTION_LIST *p11; - QString file, load_error; - bool enabled; + private: + CK_FUNCTION_LIST *p11{}; + QString file, load_error{}; + bool enabled{}; - public: - static QString name2File(const QString &name, bool *enabled = NULL); + public: + static QString name2File(const QString &name, bool *enabled = nullptr); pkcs11_lib(const QString &file); + pkcs11_lib() = delete; ~pkcs11_lib(); QList getSlotList(); diff --git a/lib/pki_base.cpp b/lib/pki_base.cpp index 6097b9ea..30fded95 100644 --- a/lib/pki_base.cpp +++ b/lib/pki_base.cpp @@ -22,24 +22,15 @@ QRegularExpression pki_base::limitPattern; bool pki_base::pem_comment; QBrush pki_base::red, pki_base::cyan, pki_base::yellow; -pki_base::pki_base(const QString &name) +pki_base::pki_base(const QString &name) : desc(name) { - desc = name; - parent = nullptr; - childItems.clear(); - pkiType=none; - pkiSource=unknown; - iamvisible = 1; } pki_base::pki_base(const pki_base *p) { desc = p->desc; - parent = nullptr; - childItems.clear(); pkiType = p->pkiType; pkiSource = p->pkiSource; - iamvisible = 1; p->inheritFilename(this); } diff --git a/lib/pki_base.h b/lib/pki_base.h index ea660e88..536726ea 100644 --- a/lib/pki_base.h +++ b/lib/pki_base.h @@ -59,20 +59,21 @@ class pki_base : public QObject static void setupColors(const QPalette &pal); protected: - QVariant sqlItemId; - QString desc, comment; - a1time insertion_date; - enum pki_type pkiType; + QVariant sqlItemId{}; + QString desc{}, comment{}; + a1time insertion_date{}; + enum pki_type pkiType{ none }; /* model data */ - pki_base *parent; + pki_base *parent{}; + QString filename{}; + QList childItems{}; + mutable QRegularExpression lastPattern{}; + int iamvisible{ 1 }; + static QBrush red, yellow, cyan; + void my_error(const QString &error) const; - QString filename; virtual QByteArray PEM_comment() const; virtual void collect_properties(QMap &) const; - QList childItems; - mutable QRegularExpression lastPattern; - static QBrush red, yellow, cyan; - int iamvisible; public: enum msg_type { @@ -86,7 +87,7 @@ class pki_base : public QObject print_pem, print_coloured, }; - enum pki_source pkiSource; + enum pki_source pkiSource{ unknown }; pki_base(const QString &d = QString()); pki_base(const pki_base *p); @@ -178,9 +179,8 @@ class pki_base : public QObject virtual void writeDefault(const QString&) const; /* Qt Model-View methods */ - virtual QVariant bg_color(const dbheader *hd) const + virtual QVariant bg_color(const dbheader *) const { - (void)hd; return QVariant(); } virtual QVariant column_data(const dbheader *hd) const; diff --git a/lib/pki_crl.cpp b/lib/pki_crl.cpp index f67da406..c8fadead 100644 --- a/lib/pki_crl.cpp +++ b/lib/pki_crl.cpp @@ -12,7 +12,7 @@ #include "database_model.h" #include -pki_crl::pki_crl(const QString name ) +pki_crl::pki_crl(const QString &name) :pki_x509name(name) { crl = X509_CRL_new(); diff --git a/lib/pki_crl.h b/lib/pki_crl.h index ba830828..bc3bbc74 100644 --- a/lib/pki_crl.h +++ b/lib/pki_crl.h @@ -22,19 +22,19 @@ class crljob { - public: - pki_x509 *issuer; - bool withReason; - bool authKeyId; - bool subAltName; - bool setCrlNumber; - a1int crlNumber; - int crlDays; - digest hashAlgo; - a1time lastUpdate; - a1time nextUpdate; + public: + pki_x509 *issuer{}; + bool withReason{}; + bool authKeyId{}; + bool subAltName{}; + bool setCrlNumber{}; + a1int crlNumber{}; + int crlDays{}; + digest hashAlgo{}; + a1time lastUpdate{}; + a1time nextUpdate{}; - crljob(pki_x509 *x) : issuer(x), + crljob(pki_x509 *x = nullptr) : issuer(x), withReason(true), authKeyId(true), subAltName(true), @@ -52,7 +52,6 @@ class crljob delete key; } } - crljob() = delete; }; class pki_crl: public pki_x509name @@ -60,12 +59,12 @@ class pki_crl: public pki_x509name Q_OBJECT friend class pki_x509; protected: - QVariant issuerSqlId; - X509_CRL *crl; + QVariant issuerSqlId{}; + X509_CRL *crl{}; extList extensions() const; void collect_properties(QMap &prp) const; public: - pki_crl(const QString name = ""); + pki_crl(const QString &name = QString()); ~pki_crl(); void fromPEM_BIO(BIO *bio, const QString &name); void fload(const QString &fname); diff --git a/lib/pki_export.h b/lib/pki_export.h index b4a7b039..d80171b7 100644 --- a/lib/pki_export.h +++ b/lib/pki_export.h @@ -53,7 +53,7 @@ class pki_export : public QObject { Q_OBJECT - public: + public: int id; enum pki_type pki_type; @@ -69,7 +69,7 @@ class pki_export : public QObject { static void free_elements(); bool match_all(int match_flags) const; - private: + private: static QList elements; }; diff --git a/lib/pki_key.h b/lib/pki_key.h index 22bcd813..8398c5e9 100644 --- a/lib/pki_key.h +++ b/lib/pki_key.h @@ -1,4 +1,5 @@ -/* +/* vi: set sw=4 ts=4: + * * Copyright (C) 2001 - 2020 Christian Hohnstaedt. * * All rights reserved. @@ -28,7 +29,7 @@ extern builtin_curves builtinCurves; class keytype { - public: + public: static QList types() { return QList { @@ -45,10 +46,10 @@ class keytype #endif }; } - int type; - QString name; - CK_MECHANISM_TYPE mech; - bool curve, length; + int type{}; + QString name{}; + CK_MECHANISM_TYPE mech{}; + bool curve{}, length{}; keytype(int t, const QString &n, CK_MECHANISM_TYPE m, bool c, bool l) : type(t), name(n), mech(m), curve(c), length(l) { } diff --git a/lib/pki_multi.h b/lib/pki_multi.h index d1c677da..06700e0a 100644 --- a/lib/pki_multi.h +++ b/lib/pki_multi.h @@ -16,7 +16,7 @@ class pki_multi: public pki_base { Q_OBJECT protected: - QList multi; + QList multi{}; public: pki_multi(const QString &name = ""); ~pki_multi(); diff --git a/lib/pki_pkcs12.cpp b/lib/pki_pkcs12.cpp index dc2995c4..0ca73586 100644 --- a/lib/pki_pkcs12.cpp +++ b/lib/pki_pkcs12.cpp @@ -34,7 +34,6 @@ pki_pkcs12::pki_pkcs12(const QString &fname) Passwd pass; EVP_PKEY *mykey = NULL; X509 *mycert = NULL; - key = NULL; cert = NULL; pass_info p(XCA_TITLE, tr("Please enter the password to decrypt the PKCS#12 file:\n%1").arg(compressFilename(fname))); const X509_ALGOR *macalgid = NULL; const ASN1_INTEGER *maciter = NULL; diff --git a/lib/pki_pkcs12.h b/lib/pki_pkcs12.h index 1257efa7..4aa1252e 100644 --- a/lib/pki_pkcs12.h +++ b/lib/pki_pkcs12.h @@ -15,11 +15,11 @@ class pki_x509; class encAlgo { - private: + private: static int default_encAlgo; - int encAlgo_nid; + int encAlgo_nid { NID_undef }; - public: + public: static const QList all_encAlgos; encAlgo(int nid); @@ -41,9 +41,9 @@ class pki_pkcs12: public pki_multi friend class pki_evp; protected: - QString alias, algorithm; - pki_x509 *cert; - pki_key *key; + QString alias{}, algorithm{}; + pki_x509 *cert{}; + pki_key *key{}; public: pki_pkcs12(const QString &d, pki_x509 *acert, pki_key *akey); diff --git a/lib/pki_pkcs7.cpp b/lib/pki_pkcs7.cpp index 79b55085..831b5a69 100644 --- a/lib/pki_pkcs7.cpp +++ b/lib/pki_pkcs7.cpp @@ -17,7 +17,6 @@ pki_pkcs7::pki_pkcs7(const QString &name) :pki_multi(name) { - p7 = NULL; } pki_pkcs7::~pki_pkcs7() diff --git a/lib/pki_pkcs7.h b/lib/pki_pkcs7.h index 5b9ac8b2..590b44af 100644 --- a/lib/pki_pkcs7.h +++ b/lib/pki_pkcs7.h @@ -22,7 +22,7 @@ class pki_pkcs7: public pki_multi friend class pki_x509; protected: - PKCS7 *p7; + PKCS7 *p7{}; void signBio(pki_x509 *crt, BIO *bio); void encryptBio(pki_x509 *crt, BIO *bio); void append_certs(PKCS7 *myp7, const QString &name); diff --git a/lib/pki_scard.cpp b/lib/pki_scard.cpp index 2a139fd0..1de27549 100644 --- a/lib/pki_scard.cpp +++ b/lib/pki_scard.cpp @@ -25,12 +25,9 @@ void pki_scard::init(void) ownPass = ptPin; pkiType = smartCard; isPub = false; - - card_serial = card_manufacturer = card_label = ""; - card_model = slot_label = ""; } -pki_scard::pki_scard(const QString name) +pki_scard::pki_scard(const QString &name) :pki_key(name) { init(); diff --git a/lib/pki_scard.h b/lib/pki_scard.h index 51d61537..c7ca710b 100644 --- a/lib/pki_scard.h +++ b/lib/pki_scard.h @@ -26,17 +26,17 @@ class pki_scard: public pki_key { Q_OBJECT protected: - QString card_serial; - QString card_manufacturer; - QString card_model; - QString card_label; - QString slot_label; - QString object_id; - QList mech_list; + QString card_serial{}; + QString card_manufacturer{}; + QString card_model{}; + QString card_label{}; + QString slot_label{}; + QString object_id{}; + QList mech_list{}; void init(void); public: - pki_scard(const QString name); + pki_scard(const QString &name); virtual ~pki_scard(); void load_token(pkcs11 &p11, CK_OBJECT_HANDLE object); bool prepare_card(slotid *slot) const; diff --git a/lib/pki_temp.cpp b/lib/pki_temp.cpp index d6546477..3175d499 100644 --- a/lib/pki_temp.cpp +++ b/lib/pki_temp.cpp @@ -88,19 +88,14 @@ const QList pki_temp::tmpl_keys = { }; pki_temp::pki_temp(const pki_temp *pk) - :pki_x509name(pk->getIntName()) + :pki_x509name(pk->getIntName()), xname(pk->xname), settings(pk->settings) { - pre_defined = false; - - xname = pk->xname; - settings = pk->settings; } pki_temp::pki_temp(const QString &d) :pki_x509name(d) { pkiType = tmpl; - pre_defined = false; foreach(QString key, tmpl_keys) { settings[key] = QString(); @@ -112,7 +107,7 @@ pki_temp::pki_temp(const QString &d) QString pki_temp::comboText() const { return pre_defined ? QString("[default] ") + pki_base::comboText() : - pki_base::comboText(); + pki_base::comboText(); } QSqlError pki_temp::insertSqlData() diff --git a/lib/pki_temp.h b/lib/pki_temp.h index f8fe0740..3893e05b 100644 --- a/lib/pki_temp.h +++ b/lib/pki_temp.h @@ -29,10 +29,10 @@ class pki_temp: public pki_x509name static const QList tmpl_keys; int dataSize(); void try_fload(XFile &file); - bool pre_defined; - x509name xname; - QMap settings; - QString adv_ext; + bool pre_defined{ false }; + x509name xname{}; + QMap settings{}; + QString adv_ext{}; void fromExtList(extList *el, int nid, const char *item); public: @@ -40,22 +40,22 @@ class pki_temp: public pki_x509name pki_temp(const QString &d = QString()); ~pki_temp(); - QString getSetting(QString key) + QString getSetting(const QString &key) { CHECK_TMPL_KEY return settings[key]; } - int getSettingInt(QString key) + int getSettingInt(const QString &key) { CHECK_TMPL_KEY return settings[key].toInt(); } - void setSetting(QString key, QString value) + void setSetting(const QString &key, const QString &value) { CHECK_TMPL_KEY settings[key] = value; } - void setSetting(QString key, int value) + void setSetting(const QString &key, int value) { CHECK_TMPL_KEY settings[key] = QString::number(value); diff --git a/lib/pki_x509.cpp b/lib/pki_x509.cpp index 09c19eb0..4ef48d3c 100644 --- a/lib/pki_x509.cpp +++ b/lib/pki_x509.cpp @@ -18,11 +18,9 @@ #include "pass_info.h" pki_x509::pki_x509(X509 *c) - :pki_x509super() + :pki_x509super(), cert(c) { init(); - cert = c; - pki_openssl_error(); } pki_x509::pki_x509(const pki_x509 *crt) @@ -249,10 +247,7 @@ pki_x509::~pki_x509() void pki_x509::init() { - caTemplateSqlId = QVariant(); - crlDays = 30; crlExpire.setUndefined(); - cert = NULL; pkiType = x509; } diff --git a/lib/pki_x509.h b/lib/pki_x509.h index ac3b5d69..cbe89074 100644 --- a/lib/pki_x509.h +++ b/lib/pki_x509.h @@ -34,15 +34,15 @@ class pki_x509 : public pki_x509super { Q_OBJECT private: - QVariant issuerSqlId; - a1time crlExpire; - a1int crlNumber; - int crlDays; - QVariant caTemplateSqlId; - X509 *cert; + QVariant issuerSqlId{}; + a1time crlExpire{}; + a1int crlNumber{}; + int crlDays{ 30 }; + QVariant caTemplateSqlId{}; + X509 *cert{}; + x509rev revocation{}; + x509revList fromDataRevList{}; void init(); - x509rev revocation; - x509revList fromDataRevList; void resetX509ReqCount() const; protected: diff --git a/lib/pki_x509req.cpp b/lib/pki_x509req.cpp index b91a27b6..968b9850 100644 --- a/lib/pki_x509req.cpp +++ b/lib/pki_x509req.cpp @@ -22,8 +22,7 @@ pki_x509req::pki_x509req(const QString &name) { request = X509_REQ_new(); pki_openssl_error(); - pkiType=x509_req; - done = false; + pkiType = x509_req; resetX509count(); } diff --git a/lib/pki_x509req.h b/lib/pki_x509req.h index 7f8c2d4f..c7cb878e 100644 --- a/lib/pki_x509req.h +++ b/lib/pki_x509req.h @@ -25,10 +25,10 @@ class pki_x509req : public pki_x509super { Q_OBJECT - mutable int x509count; + mutable int x509count{}; protected: - X509_REQ *request; - bool done; + X509_REQ *request{}; + bool done{ false }; int sigAlg() const; void collect_properties(QMap &prp) const; diff --git a/lib/pki_x509super.h b/lib/pki_x509super.h index 5aef13da..9a9b3987 100644 --- a/lib/pki_x509super.h +++ b/lib/pki_x509super.h @@ -19,10 +19,10 @@ class pki_x509name : public pki_base { - protected: + protected: QByteArray PEM_comment() const; - public: + public: pki_x509name(const QString &name = QString()); pki_x509name(const pki_x509name *n); virtual x509name getSubject() const = 0; @@ -36,7 +36,7 @@ class pki_x509super : public pki_x509name { Q_OBJECT protected: - QVariant keySqlId; + QVariant keySqlId{}; virtual int sigAlg() const = 0; void collect_properties(QMap &prp) const; public: diff --git a/lib/settings.cpp b/lib/settings.cpp index a543e6f6..16b2e6c4 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -1,3 +1,10 @@ +/* vi: set sw=4 ts=4: + * + * Copyright (C) 2018 Christian Hohnstaedt. + * + * All rights reserved. + */ + #include "settings.h" #include "func.h" #include "sql.h" @@ -13,9 +20,8 @@ settings Settings; svalue::svalue(settings *s, const QString &k) + : setting(s), key(k) { - setting = s; - key = k; } QString svalue::get() const diff --git a/lib/settings.h b/lib/settings.h index 99c44a08..7229e0fc 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -16,13 +16,13 @@ class settings; class svalue { - private: - settings *setting; - QString key; + private: + settings *setting{}; + QString key{}; QString get() const; void set(const QString &val); - public: + public: svalue(settings *s, const QString &k); QStringList split(QString sep) { @@ -91,17 +91,17 @@ class settings { friend class svalue; - private: - bool loaded; - QStringList db_keys, hostspecific; - QMap values; - QMap defaul; + private: + bool loaded{}; + QStringList db_keys{}, hostspecific{}; + QMap values{}; + QMap defaul{}; void load_settings(); QString get(QString key); void set(QString key, QString value); void setAction(const QString &key, const QString &value); - public: + public: settings(); void clear(); QString defaults(const QString &key); diff --git a/lib/sql.cpp b/lib/sql.cpp index 6afaadb4..dea0e958 100644 --- a/lib/sql.cpp +++ b/lib/sql.cpp @@ -27,11 +27,6 @@ void DbTransaction::debug(const char *func, const char *file, int line) .arg(line).arg(func).arg(mutex).arg(error); } -DbTransaction::DbTransaction() -{ - has_begun = false; -} - DbTransaction::~DbTransaction() { if (has_begun) diff --git a/lib/sql.h b/lib/sql.h index 9c403bc4..3f9e8f6f 100644 --- a/lib/sql.h +++ b/lib/sql.h @@ -23,12 +23,12 @@ class DbTransaction static int error; static QList items; static bool hasTransaction; - bool has_begun; + bool has_begun{}; void debug(const char *func, const char *file, int line); bool finish(const char *oper, const char *file, int line); public: - DbTransaction(); + DbTransaction() { }; ~DbTransaction(); bool begin(const char *file, int line); bool commit(const char *file, int line); diff --git a/lib/x509name.cpp b/lib/x509name.cpp index e4f3ca9b..b1db9382 100644 --- a/lib/x509name.cpp +++ b/lib/x509name.cpp @@ -26,13 +26,11 @@ x509name::x509name(const X509_NAME *n) x509name::x509name(STACK_OF(X509_NAME_ENTRY) *entries) { - xn = NULL; set(entries); } x509name::x509name(const x509name &n) { - xn = NULL; set(n.xn); } diff --git a/lib/x509name.h b/lib/x509name.h index ec6ba575..14d49da3 100644 --- a/lib/x509name.h +++ b/lib/x509name.h @@ -16,7 +16,7 @@ class x509name { private: - X509_NAME *xn; + X509_NAME *xn{}; public: x509name(); x509name(const X509_NAME *n); diff --git a/lib/x509rev.h b/lib/x509rev.h index e13d482a..a5db1c1d 100644 --- a/lib/x509rev.h +++ b/lib/x509rev.h @@ -20,9 +20,9 @@ class x509rev { private: - a1int serial; - a1time date, ivalDate; - int reason_idx, crlNo; + a1int serial{}; + a1time date{}, ivalDate{}; + int reason_idx{}, crlNo{}; void set(const x509rev &x); X509_REVOKED *toREVOKED(bool withReason=true) const; @@ -38,7 +38,6 @@ class x509rev x509rev() { - reason_idx = 0; date.setUndefined(); } x509rev(X509_REVOKED *n) diff --git a/lib/x509v3ext.cpp b/lib/x509v3ext.cpp index 84c779dc..4c9d30e1 100644 --- a/lib/x509v3ext.cpp +++ b/lib/x509v3ext.cpp @@ -20,10 +20,9 @@ x509v3ext::x509v3ext() { - ext = nullptr; } -x509v3ext::x509v3ext(const X509_EXTENSION *n) : ext(nullptr) +x509v3ext::x509v3ext(const X509_EXTENSION *n) { if (n) { ext = X509_EXTENSION_dup((X509_EXTENSION *)n); @@ -31,12 +30,12 @@ x509v3ext::x509v3ext(const X509_EXTENSION *n) : ext(nullptr) } } -x509v3ext::x509v3ext(const x509v3ext &n) : ext(nullptr) +x509v3ext::x509v3ext(const x509v3ext &n) { set(n.ext); } -x509v3ext::x509v3ext(int nid, const QString &et, X509V3_CTX *ctx) : ext(nullptr) +x509v3ext::x509v3ext(int nid, const QString &et, X509V3_CTX *ctx) { create(nid, et, ctx); } diff --git a/lib/x509v3ext.h b/lib/x509v3ext.h index 326fab24..a12729e3 100644 --- a/lib/x509v3ext.h +++ b/lib/x509v3ext.h @@ -19,7 +19,7 @@ class QString; class x509v3ext { private: - X509_EXTENSION *ext; + X509_EXTENSION *ext{}; const ASN1_OBJECT *object() const; public: x509v3ext(); diff --git a/widgets/CertDetail.h b/widgets/CertDetail.h index 668a1454..92855e2e 100644 --- a/widgets/CertDetail.h +++ b/widgets/CertDetail.h @@ -19,11 +19,11 @@ class CertDetail: public XcaDetail, public Ui::CertDetail { Q_OBJECT - bool showConf; - QVariant keySqlId, issuerSqlId, thisSqlId; - QString conf, exts; + bool showConf{ false }; + QVariant keySqlId{}, issuerSqlId{}, thisSqlId{}; + QString conf{}, exts{}; QLabel *labelFromAsn1String(ASN1_STRING *s); - pki_key *myPubKey, *tmpPubKey; + pki_key *myPubKey{}, *tmpPubKey{}; void setCert(pki_x509 *cert); void setReq(pki_x509req *req); diff --git a/widgets/CertExtend.h b/widgets/CertExtend.h index af451461..92ca9004 100644 --- a/widgets/CertExtend.h +++ b/widgets/CertExtend.h @@ -17,7 +17,7 @@ class CertExtend: public QDialog, public Ui::CertExtend { Q_OBJECT - pki_x509 *signer; + pki_x509 *signer{}; public: CertExtend(QWidget *parent, pki_x509 *s); diff --git a/widgets/CrlDetail.cpp b/widgets/CrlDetail.cpp index 3d22794b..b5ef2f5e 100644 --- a/widgets/CrlDetail.cpp +++ b/widgets/CrlDetail.cpp @@ -20,7 +20,7 @@ #include #include -CrlDetail::CrlDetail(QWidget *w) : XcaDetail(w), issuerSqlId(), crlSqlId() +CrlDetail::CrlDetail(QWidget *w) : XcaDetail(w) { setupUi(this); init("crldetail", ":revImg"); diff --git a/widgets/CrlDetail.h b/widgets/CrlDetail.h index 89f17915..05e10848 100644 --- a/widgets/CrlDetail.h +++ b/widgets/CrlDetail.h @@ -19,7 +19,7 @@ class CrlDetail: public XcaDetail, public Ui::CrlDetail Q_OBJECT private: - QVariant issuerSqlId, crlSqlId; + QVariant issuerSqlId{}, crlSqlId{}; public: CrlDetail(QWidget *w = nullptr); void setCrl(pki_crl *crl); diff --git a/widgets/ExportDialog.h b/widgets/ExportDialog.h index 1a7b2715..1133d09d 100644 --- a/widgets/ExportDialog.h +++ b/widgets/ExportDialog.h @@ -19,10 +19,10 @@ class ExportDialog: public QDialog, public Ui::ExportDialog { Q_OBJECT - protected: - QString filter; + protected: + QString filter{}; - public: + public: ExportDialog(QWidget *w, const QString &title, const QString &filt, const QModelIndexList &indexes, const QPixmap &img, QList types, @@ -31,7 +31,7 @@ class ExportDialog: public QDialog, public Ui::ExportDialog static bool mayWriteFile(const QString &fname); const pki_export *export_type(int idx = -1) const; - public slots: + public slots: void on_fileBut_clicked(); void on_exportFormat_activated(int); void on_exportFormat_highlighted(int index); diff --git a/widgets/FocusCombo.h b/widgets/FocusCombo.h index 811dff4d..a8dd39e6 100644 --- a/widgets/FocusCombo.h +++ b/widgets/FocusCombo.h @@ -12,7 +12,7 @@ class focusCombo : public QComboBox { - public: + public: focusCombo(QWidget *parent) : QComboBox(parent) { } void hidePopup() { diff --git a/widgets/Help.cpp b/widgets/Help.cpp index f55626d2..80c65ef3 100644 --- a/widgets/Help.cpp +++ b/widgets/Help.cpp @@ -16,7 +16,7 @@ #include #endif -Help::Help() : QWidget(NULL), helpengine(nullptr) +Help::Help() : QWidget(NULL) { setupUi(this); setWindowTitle(XCA_TITLE); diff --git a/widgets/Help.h b/widgets/Help.h index 82c9be37..b639a3af 100644 --- a/widgets/Help.h +++ b/widgets/Help.h @@ -18,17 +18,17 @@ class Help: public QWidget, public Ui::Help { Q_OBJECT - QHelpEngineCore *helpengine; + QHelpEngineCore *helpengine{}; void display(const QUrl &url); - public: + public: Help(); ~Help(); void register_ctxhelp_button(QDialog *dlg, const QString &help_ctx) const; QList url_by_ctx(const QString &ctx) const; - public slots: + public slots: void contexthelp(); void contexthelp(const QString &context); void content(); diff --git a/widgets/ImportMulti.h b/widgets/ImportMulti.h index 0cef173e..4200b3a7 100644 --- a/widgets/ImportMulti.h +++ b/widgets/ImportMulti.h @@ -21,8 +21,8 @@ class ImportMulti: public QDialog, private Ui::ImportMulti Q_OBJECT private: - slotid slot; - db_token *mcont; + slotid slot{}; + db_token *mcont{}; void importError(QStringList failed); public: diff --git a/widgets/ItemCombo.h b/widgets/ItemCombo.h index 2525aefb..c94b7ff5 100644 --- a/widgets/ItemCombo.h +++ b/widgets/ItemCombo.h @@ -18,7 +18,7 @@ template class itemCombo : public QComboBox { - public: + public: itemCombo(QWidget *parent) : QComboBox(parent) { } void insertPkiItems(QList items) { clear(); diff --git a/widgets/KeyDetail.cpp b/widgets/KeyDetail.cpp index 6928534c..bab75736 100644 --- a/widgets/KeyDetail.cpp +++ b/widgets/KeyDetail.cpp @@ -22,7 +22,7 @@ #include #include -KeyDetail::KeyDetail(QWidget *w) : XcaDetail(w) , keySqlId() +KeyDetail::KeyDetail(QWidget *w) : XcaDetail(w) { setupUi(this); diff --git a/widgets/KeyDetail.h b/widgets/KeyDetail.h index 070501f8..4d956677 100644 --- a/widgets/KeyDetail.h +++ b/widgets/KeyDetail.h @@ -18,7 +18,7 @@ class KeyDetail: public XcaDetail, public Ui::KeyDetail { Q_OBJECT - QVariant keySqlId; + QVariant keySqlId{}; public: KeyDetail(QWidget *w = nullptr); diff --git a/widgets/KeyTreeView.h b/widgets/KeyTreeView.h index d822ed72..e38953dc 100644 --- a/widgets/KeyTreeView.h +++ b/widgets/KeyTreeView.h @@ -21,14 +21,14 @@ class KeyTreeView: public XcaTreeView return dynamic_cast(basemodel); } - public: + public: KeyTreeView(QWidget *parent) : XcaTreeView(parent) { } void fillContextMenu(QMenu *menu, QMenu *subExport, const QModelIndex &index, QModelIndexList indexes); void showPki(pki_base *pki); ExportDialog *exportDialog(const QModelIndexList &indexes); - public slots: + public slots: void resetOwnPass(); void setOwnPass(); void changePin(); diff --git a/widgets/MainWindow.cpp b/widgets/MainWindow.cpp index 679ed2ab..e278c8c9 100644 --- a/widgets/MainWindow.cpp +++ b/widgets/MainWindow.cpp @@ -89,7 +89,6 @@ MainWindow::MainWindow() : QMainWindow() OpenDb::initDatabases(); - historyMenu = NULL; helpdlg = new Help(); init_menu(); setItemEnabled(false); @@ -128,9 +127,6 @@ MainWindow::MainWindow() : QMainWindow() XcaProgress::setGui(new XcaProgressGui(this)); xcaWarning::setGui(new xcaWarningGui()); PwDialogCore::setGui(new PwDialogUI()); - - dhgen = nullptr; - dhgenProgress = nullptr; } void MainWindow::dropEvent(QDropEvent *event) diff --git a/widgets/MainWindow.h b/widgets/MainWindow.h index dca22621..bf28733d 100644 --- a/widgets/MainWindow.h +++ b/widgets/MainWindow.h @@ -35,7 +35,7 @@ class tipMenu : public QMenu { Q_OBJECT - public: + public: tipMenu(QString n, QWidget *w) : QMenu(n, w) {} bool event (QEvent * e) { @@ -58,22 +58,22 @@ class MainWindow: public QMainWindow, public Ui::MainWindow private: static OidResolver *resolver; - QString string_opt; - QList wdList; - QList wdMenuList; - QList scardList; - QList acList; - tipMenu *historyMenu; + QString string_opt{}; + QList wdList{}; + QList wdMenuList{}; + QList scardList{}; + QList acList{}; + tipMenu *historyMenu{}; + QLineEdit *searchEdit{}; + QStringList urlsToOpen{}; + XcaProgress *dhgenProgress{}; + DHgen *dhgen{}; + QList views{}; + dbhistory history{}; void set_geometry(QString geo); - QLineEdit *searchEdit; - QStringList urlsToOpen; int checkOldGetNewPass(Passwd &pass); void checkDB(); - XcaProgress *dhgenProgress; - DHgen *dhgen; const QList getTranslators() const; - QList views; - dbhistory history; void exportIndex(const QString &fname, bool hierarchy) const; QAction *languageMenuEntry(const QStringList &sl); diff --git a/widgets/NewCrl.h b/widgets/NewCrl.h index 8b7f1360..eb4f6aeb 100644 --- a/widgets/NewCrl.h +++ b/widgets/NewCrl.h @@ -17,14 +17,14 @@ class NewCrl: public QWidget, public Ui::NewCrl { Q_OBJECT - crljob task; - public: + crljob task{}; + public: NewCrl(const crljob &task, QWidget *w = nullptr); ~NewCrl(); crljob getCrlJob() const; static void newCrl(QWidget *parent, pki_x509 *issuer); - public slots: + public slots: void on_applyTime_clicked(); }; #endif diff --git a/widgets/NewX509.cpp b/widgets/NewX509.cpp index 088ccb64..805636eb 100644 --- a/widgets/NewX509.cpp +++ b/widgets/NewX509.cpp @@ -110,9 +110,8 @@ QList NewX509::setupExplicitInputs(NIDlist nid_list, return edits; } -NewX509::NewX509(QWidget *w) : QDialog(w ? w : mainwin) +NewX509::NewX509(QWidget *w) : QDialog(w && w->isVisible() ? w : nullptr) { - int i; QStringList keys; db_key *keymodel = Database.model(); db_x509req *reqmodel = Database.model(); @@ -123,8 +122,6 @@ NewX509::NewX509(QWidget *w) : QDialog(w ? w : mainwin) mainwin->helpdlg->register_ctxhelp_button(this, "wizard"); /* temporary storage for creating temporary X509V3_CTX */ - ctx_cert = NULL; - pkiSource = generated; foreach(int nid, distname_nid) keys << QString(OBJ_nid2ln(nid)); @@ -152,7 +149,7 @@ NewX509::NewX509(QWidget *w) : QDialog(w ? w : mainwin) setWindowTitle(XCA_TITLE); - for (i=0; icount(); i++) { + for (int i=0; icount(); i++) { tabWidget->widget(i)->setObjectName(tabnames[i]); qDebug() << "TAB:" << i << tabWidget->tabText(i); } @@ -207,7 +204,6 @@ NewX509::NewX509(QWidget *w) : QDialog(w ? w : mainwin) certList->setDisabled(true); tabWidget->setCurrentIndex(0); attrWidget->hide(); - pt = none; notAfter->setEndDate(true); basicPath->setValidator(new QIntValidator(0, 1000, this)); diff --git a/widgets/NewX509.h b/widgets/NewX509.h index c898a761..dc95f748 100644 --- a/widgets/NewX509.h +++ b/widgets/NewX509.h @@ -28,11 +28,12 @@ class x509name; class x509v3ext; class extList; -class nameEdit { - public: - int nid; - QLineEdit *edit; - QLabel *label; +class nameEdit +{ + public: + int nid{}; + QLineEdit *edit{}; + QLabel *label{}; nameEdit(int n, QLineEdit *e, QLabel *l) { nid = n; edit = e; label = l; } @@ -42,30 +43,30 @@ class NewX509: public QDialog, public Ui::NewX509 { Q_OBJECT private: - NIDlist aia_nid; - NIDlist attr_nid; - QList attrEdits; - QList nameEdits; - X509V3_CTX ext_ctx; + NIDlist aia_nid{}; + NIDlist attr_nid{}; + QList attrEdits{}; + QList nameEdits{}; + X509V3_CTX ext_ctx{}; void editV3ext(QLineEdit *le, QString types, int n); - enum pki_type pt; - enum pki_source pkiSource; + enum pki_type pt{ none }; + enum pki_source pkiSource{ generated }; void templateChanged(QString templatename); QString mandatoryDnRemain(); - QStringList tabnames; - QList unusedKeys, allKeys; - pki_x509 *ctx_cert; - QString v3ext_backup; - kvmodel *extDNmodel; + QStringList tabnames{}; + QList unusedKeys, allKeys{}; + pki_x509 *ctx_cert{}; + QString v3ext_backup{}; + kvmodel *extDNmodel{}; extList getExtDuplicates(); void checkIcon(const QString &text, int nid, QLabel*img); void selfComment(QString msg); - QMap templateLineEdits; - QMap templateCheckBoxes; + QMap templateLineEdits{}; + QMap templateCheckBoxes{}; pki_temp *caTemplate(pki_x509 *ca) const; void setupExplicitDN(NIDlist my_dn_nid); QList setupExplicitInputs(NIDlist nid_list, - QWidget *parent, QWidget *old, int columns); + QWidget *parent, QWidget *old, int columns); public: NewX509(QWidget *w = nullptr); diff --git a/widgets/OpenDb.h b/widgets/OpenDb.h index 8caa5967..846bdb7e 100644 --- a/widgets/OpenDb.h +++ b/widgets/OpenDb.h @@ -20,7 +20,7 @@ class OpenDb: public QDialog, public Ui::OpenDb private: static DbMap databases; static QString lastRemote; - bool sqlite, show_connection_settings; + bool sqlite{}, show_connection_settings{}; void setupDatabaseName(const QString &db); QString getDbType() const; void fillDbDropDown(const QString ¤t); diff --git a/widgets/Options.cpp b/widgets/Options.cpp index 81cb2c22..ebf014fc 100644 --- a/widgets/Options.cpp +++ b/widgets/Options.cpp @@ -41,7 +41,6 @@ Options::Options(QWidget *parent) mbstring->setCurrentIndex(string_opts.indexOf( QString(Settings["string_opt"]))); - searchP11 = NULL; transDnEntries->setText(transDnEntries->text() .arg(OBJ_nid2ln(NID_commonName)) .arg(dn_translations[NID_commonName])); diff --git a/widgets/Options.h b/widgets/Options.h index 950fc7b3..93f4f0c6 100644 --- a/widgets/Options.h +++ b/widgets/Options.h @@ -18,8 +18,8 @@ class Options: public QDialog, public Ui::Options { Q_OBJECT private: - SearchPkcs11 *searchP11; - QStringList string_opts; + SearchPkcs11 *searchP11{}; + QStringList string_opts{}; QString getDnString(QListWidget *w); void setDnString(QString dn, QListWidget *w); diff --git a/widgets/PwDialog.cpp b/widgets/PwDialog.cpp index bc1bf104..a9c6e413 100644 --- a/widgets/PwDialog.cpp +++ b/widgets/PwDialog.cpp @@ -48,7 +48,7 @@ enum open_result PwDialogUI::execute(pass_info *p, Passwd *passwd, } PwDialog::PwDialog(pass_info *p, bool write) - :QDialog(p->getWidget()) + :QDialog(p->getWidget()), pi(p) { pi = p; setupUi(this); diff --git a/widgets/PwDialog.h b/widgets/PwDialog.h index 3e8c8c14..c16b7b37 100644 --- a/widgets/PwDialog.h +++ b/widgets/PwDialog.h @@ -17,9 +17,9 @@ class PwDialog: public QDialog, public Ui::PwDialog Q_OBJECT private: - bool wrDialog; - Passwd final; - pass_info *pi; + pass_info *pi{}; + Passwd final{}; + bool wrDialog{}; public: PwDialog(pass_info *p, bool write = false); diff --git a/widgets/RevocationList.cpp b/widgets/RevocationList.cpp index 3c75e2b7..48bbabad 100644 --- a/widgets/RevocationList.cpp +++ b/widgets/RevocationList.cpp @@ -18,7 +18,7 @@ enum revCol { Cnumber, Cserial, Cdate, Creason, CiDate, Cmax }; class revListItem : public QTreeWidgetItem { - public: + public: revListItem(QTreeWidget *w) : QTreeWidgetItem(w) { }; bool operator < (const QTreeWidgetItem &other) const { @@ -95,7 +95,8 @@ void RevocationList::setupRevocationView(QTreeWidget *certList, certList->setSelectionMode(QAbstractItemView::ExtendedSelection); } -RevocationList::RevocationList(QWidget *w) : QDialog(w ? w : mainwin) +RevocationList::RevocationList(QWidget *w) + : QDialog(w && w->isVisible() ? w : nullptr) { QPushButton *genCrl; setupUi(this); diff --git a/widgets/RevocationList.h b/widgets/RevocationList.h index fbd98d96..0fccc3de 100644 --- a/widgets/RevocationList.h +++ b/widgets/RevocationList.h @@ -20,8 +20,8 @@ class RevocationList: public QDialog, public Ui::RevocationList Q_OBJECT private: - x509revList revList; - pki_x509 *issuer; + x509revList revList{}; + pki_x509 *issuer{}; public: static void setupRevocationView(QTreeWidget *certList, const x509revList &revList, const pki_x509 *iss); diff --git a/widgets/TempTreeView.h b/widgets/TempTreeView.h index 99933d44..6d6f7f95 100644 --- a/widgets/TempTreeView.h +++ b/widgets/TempTreeView.h @@ -22,7 +22,7 @@ class TempTreeView: public XcaTreeView bool runTempDlg(pki_temp *temp); - public: + public: TempTreeView(QWidget *parent) : XcaTreeView(parent) { } void fillContextMenu(QMenu *menu, QMenu *subExport, const QModelIndex &index, QModelIndexList indexes); @@ -30,14 +30,14 @@ class TempTreeView: public XcaTreeView bool alterTemp(pki_temp *temp); ExportDialog *exportDialog(const QModelIndexList &index); - public slots: + public slots: void certFromTemp(); void reqFromTemp(); void duplicateTemp(); void newItem(); void load(); - signals: + signals: void newReq(pki_temp *); void newCert(pki_temp *); }; diff --git a/widgets/X509SuperTreeView.cpp b/widgets/X509SuperTreeView.cpp index b95793d0..047d4653 100644 --- a/widgets/X509SuperTreeView.cpp +++ b/widgets/X509SuperTreeView.cpp @@ -21,7 +21,6 @@ void X509SuperTreeView::fillContextMenu(QMenu *menu, QMenu *subExport, { pki_x509super *x = dynamic_cast( db_base::fromIndex(index)); - transform = NULL; if (indexes.size() != 1 || !x) return; diff --git a/widgets/X509SuperTreeView.h b/widgets/X509SuperTreeView.h index dc7ce515..c204f44c 100644 --- a/widgets/X509SuperTreeView.h +++ b/widgets/X509SuperTreeView.h @@ -20,18 +20,15 @@ class X509SuperTreeView: public XcaTreeView return dynamic_cast(basemodel); } - protected: - QMenu *transform; + protected: + QMenu *transform{}; - public: - X509SuperTreeView(QWidget *parent) : XcaTreeView(parent) - { - transform = NULL; - } + public: + X509SuperTreeView(QWidget *parent) : XcaTreeView(parent) { } void fillContextMenu(QMenu *menu, QMenu *subExport, const QModelIndex &index, QModelIndexList indexes); - public slots: + public slots: void showPki(pki_base *pki); void extractPubkey(); void toTemplate(); diff --git a/widgets/XcaApplication.cpp b/widgets/XcaApplication.cpp index 1e56f2ff..1ba79405 100644 --- a/widgets/XcaApplication.cpp +++ b/widgets/XcaApplication.cpp @@ -35,7 +35,7 @@ static QString defaultlang() } XcaApplication::XcaApplication(int &argc, char *argv[]) - :QApplication(argc, argv), mainw(nullptr), qtTr(nullptr), xcaTr(nullptr) + : QApplication(argc, argv) { QLocale lang; diff --git a/widgets/XcaApplication.h b/widgets/XcaApplication.h index 4d7b6235..8f2ad86e 100644 --- a/widgets/XcaApplication.h +++ b/widgets/XcaApplication.h @@ -18,7 +18,7 @@ class QAction; class XcaTranslator : public QTranslator { Q_OBJECT -public: + public: XcaTranslator(QObject *p = NULL) : QTranslator(p) { } bool load(const QLocale &locale, const QString &filename, const QString &dir) @@ -32,13 +32,13 @@ class XcaApplication : public QApplication { Q_OBJECT -private: - MainWindow *mainw; - XcaTranslator *qtTr; - XcaTranslator *xcaTr; + private: + MainWindow *mainw{}; + XcaTranslator *qtTr{}; + XcaTranslator *xcaTr{}; static QList langAvail; -public: + public: XcaApplication(int &argc, char *argv[]); virtual ~XcaApplication(); void setMainwin(MainWindow *m); diff --git a/widgets/XcaDetail.cpp b/widgets/XcaDetail.cpp index a3baca0c..edba42ae 100644 --- a/widgets/XcaDetail.cpp +++ b/widgets/XcaDetail.cpp @@ -19,7 +19,7 @@ #include "lib/database_model.h" XcaDetail::XcaDetail(QWidget *w) - : QDialog(w && w->isVisible() ? w : nullptr), pki(nullptr) + : QDialog(w && w->isVisible() ? w : nullptr) { importmulti = dynamic_cast(w); setWindowTitle(XCA_TITLE); diff --git a/widgets/XcaDetail.h b/widgets/XcaDetail.h index e89fde05..079830ee 100644 --- a/widgets/XcaDetail.h +++ b/widgets/XcaDetail.h @@ -18,9 +18,9 @@ class XcaDetail: public QDialog Q_OBJECT protected: - pki_base *pki; - ImportMulti *importmulti; - QPushButton *importbut; + pki_base *pki{}; + ImportMulti *importmulti{}; + QPushButton *importbut{}; void updateNameComment(); public: diff --git a/widgets/XcaDialog.h b/widgets/XcaDialog.h index 00e96388..6d7af8ae 100644 --- a/widgets/XcaDialog.h +++ b/widgets/XcaDialog.h @@ -15,7 +15,7 @@ class XcaDialog : public QDialog, public Ui::XcaDialog { QWidget *widg; - public: + public: XcaDialog(QWidget *parent, enum pki_type type, QWidget *w, const QString &t, const QString &desc, const QString &help_ctx = QString()); diff --git a/widgets/XcaProgressGui.h b/widgets/XcaProgressGui.h index f766137a..e90f27f5 100644 --- a/widgets/XcaProgressGui.h +++ b/widgets/XcaProgressGui.h @@ -18,13 +18,13 @@ class XcaProgressGui : public XcaProgress_i { - private: - QMainWindow *mwin; - QProgressBar *bar; + private: + QMainWindow *mwin{}; + QProgressBar *bar{}; - public: + public: XcaProgressGui() = delete; - XcaProgressGui(QMainWindow *m) : XcaProgress_i(), mwin(m), bar() + XcaProgressGui(QMainWindow *m) : XcaProgress_i(), mwin(m) { bar = new QProgressBar(); bar->setMinimum(0); diff --git a/widgets/XcaProxyModel.h b/widgets/XcaProxyModel.h index 43f9cb8c..83465518 100644 --- a/widgets/XcaProxyModel.h +++ b/widgets/XcaProxyModel.h @@ -15,7 +15,7 @@ class XcaProxyModel: public QSortFilterProxyModel { Q_OBJECT - public: + public: XcaProxyModel(QWidget *parent = 0) :QSortFilterProxyModel(parent) { } bool lessThan(const QModelIndex &left, const QModelIndex &right) const; diff --git a/widgets/XcaTreeView.cpp b/widgets/XcaTreeView.cpp index c1c46862..8b994d17 100644 --- a/widgets/XcaTreeView.cpp +++ b/widgets/XcaTreeView.cpp @@ -31,7 +31,6 @@ XcaTreeView::XcaTreeView(QWidget *parent) :QTreeView(parent) { - mainwin = NULL; setHeader(new XcaHeaderView()); setAlternatingRowColors(true); setSelectionMode(QAbstractItemView::ExtendedSelection); @@ -45,7 +44,6 @@ XcaTreeView::XcaTreeView(QWidget *parent) setSortingEnabled(true); proxy->setDynamicSortFilter(true); sortByColumn(0, Qt::AscendingOrder); - basemodel = NULL; connect(header(), SIGNAL(sectionHandleDoubleClicked(int)), this, SLOT(resizeColumnToContents(int))); connect(this, SIGNAL(doubleClicked(const QModelIndex &)), @@ -409,8 +407,6 @@ void XcaTreeView::contextMenu(QContextMenuEvent *e, QMenu *parent, int col) if (curr_hd->id > 0) menu->addAction(tr("Details"), this, SLOT(headerDetails())); - } else { - curr_hd = NULL; } menu->addSeparator(); foreach(hd, allHeaders) { diff --git a/widgets/XcaTreeView.h b/widgets/XcaTreeView.h index a3843784..2f4ef227 100644 --- a/widgets/XcaTreeView.h +++ b/widgets/XcaTreeView.h @@ -29,16 +29,16 @@ class XcaTreeView: public QTreeView { Q_OBJECT - dbheader *curr_hd; - QTimer throttle; + dbheader *curr_hd{}; + QTimer throttle{}; - protected: - db_base *basemodel; - QSortFilterProxyModel *proxy; - MainWindow *mainwin; + protected: + db_base *basemodel{}; + QSortFilterProxyModel *proxy{}; + MainWindow *mainwin{}; - public: - XcaTreeView(QWidget *parent = 0); + public: + XcaTreeView(QWidget *parent = nullptr); virtual ~XcaTreeView(); void contextMenuEvent(QContextMenuEvent *e); void setModel(QAbstractItemModel *model); diff --git a/widgets/XcaWarning.h b/widgets/XcaWarning.h index e803513e..0d369eee 100644 --- a/widgets/XcaWarning.h +++ b/widgets/XcaWarning.h @@ -28,7 +28,7 @@ class xcaWarningGui : public QObject, public xcaWarning_i int showBox(const QString &txt, QMessageBox::Icon icn, QMessageBox::StandardButtons b); - public: + public: void information(const QString &msg); void warning(const QString &msg); void warningv3(const QString &msg, const extList &el); diff --git a/widgets/clicklabel.h b/widgets/clicklabel.h index d25698ef..3aaff6ee 100644 --- a/widgets/clicklabel.h +++ b/widgets/clicklabel.h @@ -16,7 +16,7 @@ class DoubleClickLabel : public QLabel { Q_OBJECT - QString clicktext; + QString clicktext{}; public: DoubleClickLabel(QWidget *parent) : QLabel(parent) { } void setClickText(QString s); diff --git a/widgets/distname.h b/widgets/distname.h index a89fa765..a5fcd687 100644 --- a/widgets/distname.h +++ b/widgets/distname.h @@ -26,8 +26,8 @@ class DistName : public QWidget void setX509name(const x509name &n); protected: - QGridLayout* DistNameLayout; - QLineEdit *rfc2253; - QLineEdit *namehash; + QGridLayout* DistNameLayout{}; + QLineEdit *rfc2253{}; + QLineEdit *namehash{}; }; #endif diff --git a/widgets/hashBox.h b/widgets/hashBox.h index c0f11c7f..a949f3d7 100644 --- a/widgets/hashBox.h +++ b/widgets/hashBox.h @@ -14,11 +14,13 @@ class hashBox: public QComboBox { Q_OBJECT - private: - QString wanted_md; - int backup; - int key_type; - public: + + private: + QString wanted_md{}; + int backup{}; + int key_type{}; + + public: hashBox(QWidget *parent); const digest current() const; void setCurrent(const digest &md); diff --git a/widgets/kvView.cpp b/widgets/kvView.cpp index d1dbe274..921cd18f 100644 --- a/widgets/kvView.cpp +++ b/widgets/kvView.cpp @@ -67,7 +67,7 @@ void lineDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, model->setData(index, l->text(), Qt::EditRole); } -kvmodel::kvmodel(QStringList &heads) +kvmodel::kvmodel(const QStringList &heads) { header = heads; myCols = heads.size(); @@ -240,6 +240,8 @@ void kvView::addKvRow() void kvView::deleteCurrentRow() { + if (!currentIndex().isValid()) + return; model()->removeRows(currentIndex().row(), 1, QModelIndex()); } diff --git a/widgets/kvView.h b/widgets/kvView.h index 21f58293..4f0a883d 100644 --- a/widgets/kvView.h +++ b/widgets/kvView.h @@ -20,7 +20,9 @@ class kvView; class kvDelegate : public QItemDelegate { -public: + Q_OBJECT + + public: kvDelegate(QObject *parent) :QItemDelegate(parent) { @@ -30,13 +32,14 @@ public: class comboDelegate : public kvDelegate { - QStringList keys; + Q_OBJECT -public: - comboDelegate(QStringList k, QObject *parent = 0) - :kvDelegate(parent) + QStringList keys{}; + + public: + comboDelegate(QStringList k, QObject *parent = nullptr) + :kvDelegate(parent), keys(k) { - keys = k; } void addKey(QString &key) { @@ -62,13 +65,11 @@ class lineDelegate : public kvDelegate { Q_OBJECT - QLabel *infoLabel; + QLabel *infoLabel{}; public: - lineDelegate(QLabel *lbl = 0, QObject *parent = 0) - :kvDelegate(parent) - { - infoLabel = lbl; - } + lineDelegate(QLabel *lbl = nullptr, QObject *parent = nullptr) + : kvDelegate(parent), infoLabel(lbl) + { } QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; @@ -77,9 +78,8 @@ public: const QModelIndex &index) const; void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, - const QModelIndex &index) const + const QModelIndex &) const { - (void)index; editor->setGeometry(option.rect); } signals: @@ -89,12 +89,12 @@ signals: class kvmodel: public QAbstractTableModel { - QStringList items; - QStringList header; - int myCols; + QStringList items{}; + QStringList header{}; + int myCols{}; public: - kvmodel(QStringList &heads); + kvmodel(const QStringList &heads); QStringList getRow(int i); void addRow(const QStringList &newrow); Qt::ItemFlags flags(const QModelIndex &index) const @@ -132,11 +132,11 @@ class kvView: public QTableView { Q_OBJECT - QStringList keys0; - QLabel *infoLabel; + QStringList keys0{}; + QLabel *infoLabel{}; public: - kvView(QWidget *parent = 0); + kvView(QWidget *parent = nullptr); ~kvView(); int rowCount() { @@ -149,7 +149,8 @@ public: void addRow(const QStringList &newrow); void deleteAllRows() { - model()->removeRows(0, rowCount(), QModelIndex()); + if (model()->rowCount() > 0) + model()->removeRows(0, rowCount(), QModelIndex()); } void setInfoLabel(QLabel *lbl, int col = 1) { diff --git a/widgets/pkcs12EncBox.h b/widgets/pkcs12EncBox.h index f0510541..4e8199c7 100644 --- a/widgets/pkcs12EncBox.h +++ b/widgets/pkcs12EncBox.h @@ -15,7 +15,7 @@ class pkcs12EncBox: public QComboBox { Q_OBJECT private: - QString wanted_encAlgo; + QString wanted_encAlgo{}; public: pkcs12EncBox(QWidget *parent); const encAlgo current() const; diff --git a/widgets/v3ext.cpp b/widgets/v3ext.cpp index ad20c214..925338b5 100644 --- a/widgets/v3ext.cpp +++ b/widgets/v3ext.cpp @@ -48,7 +48,7 @@ void v3ext::addInfo(QLineEdit *myle, const QStringList &sl, int n, copy_cn->hide(); } -void v3ext::addItem(QString list) +void v3ext::addItem(const QString &list) { int i; QStringList sl; @@ -107,10 +107,10 @@ void v3ext::setupLineEdit(const QString &s, QLineEdit *l) } /* for one TYPE:Content String */ -void v3ext::addEntry(QString line) +void v3ext::addEntry(const QString &l) { int idx; - QString type, value; + QString type, value, line(l); line = line.trimmed(); idx = line.indexOf(':'); diff --git a/widgets/v3ext.h b/widgets/v3ext.h index fe3145cd..81709111 100644 --- a/widgets/v3ext.h +++ b/widgets/v3ext.h @@ -22,20 +22,21 @@ class v3ext: public QDialog, public Ui::v3ext { Q_OBJECT private: - QLineEdit *le; - int nid; - X509V3_CTX *ext_ctx; + int nid{}; + QLineEdit *le{}; + X509V3_CTX *ext_ctx{}; + QStringList keys{}; + QString prefix{}; bool __validate(bool showSuccess); - QStringList keys; - QString prefix; + public: v3ext( QWidget *parent); - void addItem(QString list); - void addEntry(QString list); + void addItem(const QString &list); + void addEntry(const QString &list); QString toString(); void addInfo(QLineEdit *myle, const QStringList &sl, int n, X509V3_CTX *ctx); - void setPrefix(QString p) { + void setPrefix(const QString &p) { prefix = p; } diff --git a/widgets/validity.cpp b/widgets/validity.cpp index 2cac00a1..db1f9882 100644 --- a/widgets/validity.cpp +++ b/widgets/validity.cpp @@ -12,15 +12,13 @@ #include "lib/func.h" -Validity::Validity( QWidget* parent ) - : QDateTimeEdit( parent ) +Validity::Validity(QWidget *parent) : QDateTimeEdit(parent) { - endDate = false; setTimeSpec(Qt::UTC); setNow(); hideTime(false); connect(this, SIGNAL(timeChanged(const QTime &)), - this, SLOT(setMyTime(const QTime &))); + this, SLOT(setMyTime(const QTime &))); updateFormatString(); } diff --git a/widgets/validity.h b/widgets/validity.h index 93377d61..cbfcb1fc 100644 --- a/widgets/validity.h +++ b/widgets/validity.h @@ -15,11 +15,11 @@ class Validity : public QDateTimeEdit { Q_OBJECT - bool midnight, endDate; + bool midnight{}, endDate{}; void updateFormatString(); protected: - QTime mytime; + QTime mytime{}; public: Validity( QWidget* parent);