From 1d31420650bfa7ca1d1503cc7431b3360e86022c Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Mon, 3 Dec 2018 12:20:33 +0100 Subject: qt,cpp: Consistently use nullptr and override * lang/cpp/src/Makefile.am, lang/qt/src/Makefile.am (AM_CPPFLAGS): Add suggest-override and zero-as-null-pointer-constant warnings. * lang/cpp/src/*, lang/qt/src/*: Consistenly use nullptr and override. -- This was especially important for the headers so that downstream users of GpgME++ or QGpgME do not get flooded by warnings if they have these warnings enabled. It also improves compiler errors/warnings in case of accidental mistakes. --- lang/cpp/src/Makefile.am | 3 +- lang/cpp/src/callbacks.cpp | 2 +- lang/cpp/src/configuration.cpp | 56 +++++----- lang/cpp/src/configuration.h | 4 +- lang/cpp/src/context.cpp | 139 ++++++++++++------------ lang/cpp/src/context.h | 4 +- lang/cpp/src/context_p.h | 2 +- lang/cpp/src/context_vanilla.cpp | 4 +- lang/cpp/src/data.cpp | 30 ++--- lang/cpp/src/data_p.h | 2 +- lang/cpp/src/decryptionresult.cpp | 18 +-- lang/cpp/src/defaultassuantransaction.h | 6 +- lang/cpp/src/editinteractor.cpp | 2 +- lang/cpp/src/encryptionresult.cpp | 6 +- lang/cpp/src/engineinfo.cpp | 12 +- lang/cpp/src/eventloopinteractor.cpp | 10 +- lang/cpp/src/global.h | 2 +- lang/cpp/src/gpgadduserideditinteractor.cpp | 4 +- lang/cpp/src/gpgadduserideditinteractor.h | 4 +- lang/cpp/src/gpgagentgetinfoassuantransaction.h | 8 +- lang/cpp/src/gpggencardkeyinteractor.cpp | 4 +- lang/cpp/src/gpggencardkeyinteractor.h | 4 +- lang/cpp/src/gpgsetexpirytimeeditinteractor.cpp | 4 +- lang/cpp/src/gpgsetexpirytimeeditinteractor.h | 4 +- lang/cpp/src/gpgsetownertrusteditinteractor.cpp | 4 +- lang/cpp/src/gpgsetownertrusteditinteractor.h | 4 +- lang/cpp/src/gpgsignkeyeditinteractor.cpp | 4 +- lang/cpp/src/gpgsignkeyeditinteractor.h | 4 +- lang/cpp/src/importresult.cpp | 8 +- lang/cpp/src/key.cpp | 58 +++++----- lang/cpp/src/keygenerationresult.cpp | 4 +- lang/cpp/src/scdgetinfoassuantransaction.h | 8 +- lang/cpp/src/signingresult.cpp | 12 +- lang/cpp/src/trustitem.cpp | 10 +- lang/cpp/src/trustitem.h | 2 +- lang/cpp/src/verificationresult.cpp | 46 ++++---- lang/cpp/src/vfsmountresult.cpp | 4 +- 37 files changed, 252 insertions(+), 250 deletions(-) (limited to 'lang/cpp/src') diff --git a/lang/cpp/src/Makefile.am b/lang/cpp/src/Makefile.am index 1e6bdc28..1b1de327 100644 --- a/lang/cpp/src/Makefile.am +++ b/lang/cpp/src/Makefile.am @@ -66,7 +66,8 @@ libgpgmepp_la_SOURCES = $(main_sources) $(gpgmepp_headers) context_vanilla.cpp \ $(interface_headers) $(private_gpgmepp_headers) AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@ @LIBASSUAN_CFLAGS@ \ - -DBUILDING_GPGMEPP + -DBUILDING_GPGMEPP -Wsuggest-override \ + -Wzero-as-null-pointer-constant libgpgmepp_la_LIBADD = ../../../src/libgpgme.la @LIBASSUAN_LIBS@ libgpgmepp_la_LDFLAGS = -no-undefined -version-info \ diff --git a/lang/cpp/src/callbacks.cpp b/lang/cpp/src/callbacks.cpp index f7692a03..21c2a813 100644 --- a/lang/cpp/src/callbacks.cpp +++ b/lang/cpp/src/callbacks.cpp @@ -76,7 +76,7 @@ gpgme_error_t passphrase_callback(void *opaque, const char *uid_hint, const char PassphraseProvider *provider = static_cast(opaque); bool canceled = false; gpgme_error_t err = GPG_ERR_NO_ERROR; - char *passphrase = provider ? provider->getPassphrase(uid_hint, desc, prev_was_bad, canceled) : 0 ; + char *passphrase = provider ? provider->getPassphrase(uid_hint, desc, prev_was_bad, canceled) : nullptr ; if (canceled) { err = make_error(GPG_ERR_CANCELED); } else { diff --git a/lang/cpp/src/configuration.cpp b/lang/cpp/src/configuration.cpp index 8ccc05e9..33c812f7 100644 --- a/lang/cpp/src/configuration.cpp +++ b/lang/cpp/src/configuration.cpp @@ -64,7 +64,7 @@ std::vector Component::load(Error &returnedError) // // 1. get a context: // - gpgme_ctx_t ctx_native = 0; + gpgme_ctx_t ctx_native = nullptr; if (const gpgme_error_t err = gpgme_new(&ctx_native)) { returnedError = Error(err); return std::vector(); @@ -74,7 +74,7 @@ std::vector Component::load(Error &returnedError) // // 2. load the config: // - gpgme_conf_comp_t conf_list_native = 0; + gpgme_conf_comp_t conf_list_native = nullptr; if (const gpgme_error_t err = gpgme_op_conf_load(ctx_native, &conf_list_native)) { returnedError = Error(err); return std::vector(); @@ -94,7 +94,7 @@ std::vector Component::load(Error &returnedError) } // now prevent double-free of next.get() and following: - head->next = 0; + head->next = nullptr; // now add a new Component to 'result' (may throw): result.resize(result.size() + 1); @@ -115,7 +115,7 @@ Error Component::save() const // // 1. get a context: // - gpgme_ctx_t ctx_native = 0; + gpgme_ctx_t ctx_native = nullptr; if (const gpgme_error_t err = gpgme_new(&ctx_native)) { return Error(err); } @@ -129,22 +129,22 @@ Error Component::save() const const char *Component::name() const { - return comp ? comp->name : 0 ; + return comp ? comp->name : nullptr; } const char *Component::description() const { - return comp ? comp->description : 0 ; + return comp ? comp->description : nullptr ; } const char *Component::programName() const { - return comp ? comp->program_name : 0 ; + return comp ? comp->program_name : nullptr ; } Option Component::option(unsigned int idx) const { - gpgme_conf_opt_t opt = 0; + gpgme_conf_opt_t opt = nullptr; if (comp) { opt = comp->options; } @@ -160,7 +160,7 @@ Option Component::option(unsigned int idx) const Option Component::option(const char *name) const { - gpgme_conf_opt_t opt = 0; + gpgme_conf_opt_t opt = nullptr; if (comp) { opt = comp->options; } @@ -177,7 +177,7 @@ Option Component::option(const char *name) const unsigned int Component::numOptions() const { unsigned int result = 0; - for (gpgme_conf_opt_t opt = comp ? comp->options : 0 ; opt ; opt = opt->next) { + for (gpgme_conf_opt_t opt = comp ? comp->options : nullptr ; opt ; opt = opt->next) { ++result; } return result; @@ -186,7 +186,7 @@ unsigned int Component::numOptions() const std::vector