From cvs at cvs.gnupg.org Sat Dec 1 12:59:02 2018 From: cvs at cvs.gnupg.org (by Jussi Kivilinna) Date: Sat, 01 Dec 2018 12:59:02 +0100 Subject: [git] GnuPG - branch, master, updated. gnupg-2.2.7-293-g73e74de Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU Privacy Guard". The branch, master has been updated via 73e74de0e33bbb76300f96a4174024779047df06 (commit) via 654e353d9b20f10fa275e7ae10cc50480654f079 (commit) via 2a650772b4e1c78a4fd20bc88433930e5551fe9c (commit) from 3a90efb7cf13532cc82b45c11a7abdadfe0c81f1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 73e74de0e33bbb76300f96a4174024779047df06 Author: Jussi Kivilinna Date: Sat Dec 1 13:43:10 2018 +0200 g10/mainproc: disable hash contexts when --skip-verify is used * g10/mainproc.c (proc_plaintext): Do not enable hash contexts when opt.skip_verify is set. -- Signed-off-by: Jussi Kivilinna diff --git a/g10/mainproc.c b/g10/mainproc.c index 7eceb7e..dce3f37 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -862,7 +862,10 @@ proc_plaintext( CTX c, PACKET *pkt ) /* The onepass signature case. */ if (n->pkt->pkt.onepass_sig->digest_algo) { - gcry_md_enable (c->mfx.md, n->pkt->pkt.onepass_sig->digest_algo); + if (!opt.skip_verify) + gcry_md_enable (c->mfx.md, + n->pkt->pkt.onepass_sig->digest_algo); + any = 1; } } @@ -880,7 +883,8 @@ proc_plaintext( CTX c, PACKET *pkt ) * documents. */ clearsig = (*data == 0x01); for (data++, datalen--; datalen; datalen--, data++) - gcry_md_enable (c->mfx.md, *data); + if (!opt.skip_verify) + gcry_md_enable (c->mfx.md, *data); any = 1; break; /* Stop here as one-pass signature packets are not expected. */ @@ -888,7 +892,8 @@ proc_plaintext( CTX c, PACKET *pkt ) else if (n->pkt->pkttype == PKT_SIGNATURE) { /* The SIG+LITERAL case that PGP used to use. */ - gcry_md_enable ( c->mfx.md, n->pkt->pkt.signature->digest_algo ); + if (!opt.skip_verify) + gcry_md_enable (c->mfx.md, n->pkt->pkt.signature->digest_algo); any = 1; } } commit 654e353d9b20f10fa275e7ae10cc50480654f079 Author: Jussi Kivilinna Date: Sat Dec 1 13:43:10 2018 +0200 common/iobuf: fix memory wiping in iobuf_copy * common/iobuf.c (iobuf_copy): Wipe used area of buffer instead of first sizeof(char*) bytes. -- Signed-off-by: Jussi Kivilinna diff --git a/common/iobuf.c b/common/iobuf.c index 5eeba8f..0594425 100644 --- a/common/iobuf.c +++ b/common/iobuf.c @@ -2262,6 +2262,7 @@ iobuf_copy (iobuf_t dest, iobuf_t source) size_t nread; size_t nwrote = 0; + size_t max_read = 0; int err; assert (source->use == IOBUF_INPUT || source->use == IOBUF_INPUT_TEMP); @@ -2278,6 +2279,9 @@ iobuf_copy (iobuf_t dest, iobuf_t source) /* EOF. */ break; + if (nread > max_read) + max_read = nread; + err = iobuf_write (dest, temp, nread); if (err) break; @@ -2285,7 +2289,8 @@ iobuf_copy (iobuf_t dest, iobuf_t source) } /* Burn the buffer. */ - wipememory (temp, sizeof (temp)); + if (max_read) + wipememory (temp, max_read); xfree (temp); return nwrote; commit 2a650772b4e1c78a4fd20bc88433930e5551fe9c Author: Jussi Kivilinna Date: Sat Dec 1 13:43:09 2018 +0200 common/mischelp: use platform memory zeroing function for wipememory * common/mischelp.h (wipememory): Replace macro with function prototype. (wipememory2): Remove. * common/mischelp.c (wipememory): New. * configure.ac (AC_CHECK_FUNCS): Check for 'explicit_bzero'. -- In new wipememory function, memory is cleared through platform provided secure memory zeroing function, SecureZeroMemory or explicit_bzero. If none of these is available, memset is called through volatile function pointer to so that compiler won't optimize away the call. Signed-off-by: Jussi Kivilinna diff --git a/common/mischelp.c b/common/mischelp.c index 75ba607..81dd501 100644 --- a/common/mischelp.c +++ b/common/mischelp.c @@ -49,6 +49,22 @@ #include "mischelp.h" +void +wipememory (void *ptr, size_t len) +{ +#if defined(HAVE_W32_SYSTEM) && defined(SecureZeroMemory) + SecureZeroMemory (ptr, len); +#elif defined(HAVE_EXPLICIT_BZERO) + explicit_bzero (ptr, len); +#else + /* Prevent compiler from optimizing away the call to memset by accessing + memset through volatile pointer. */ + static void *(*volatile memset_ptr)(void *, int, size_t) = (void *)memset; + memset_ptr (ptr, 0, len); +#endif +} + + /* Check whether the files NAME1 and NAME2 are identical. This is for example achieved by comparing the inode numbers of the files. */ int diff --git a/common/mischelp.h b/common/mischelp.h index 18ec96e..bdee5a4 100644 --- a/common/mischelp.h +++ b/common/mischelp.h @@ -47,15 +47,9 @@ time_t timegm (struct tm *tm); #define DIM(v) (sizeof(v)/sizeof((v)[0])) #define DIMof(type,member) DIM(((type *)0)->member) -/* To avoid that a compiler optimizes certain memset calls away, these - macros may be used instead. */ -#define wipememory2(_ptr,_set,_len) do { \ - volatile char *_vptr=(volatile char *)(_ptr); \ - size_t _vlen=(_len); \ - while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \ - } while(0) -#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len) - +/* To avoid that a compiler optimizes certain memset calls away, + wipememory function may be used instead. */ +void wipememory(void *ptr, size_t len); /* Include hacks which are mainly required for Slowaris. */ #ifdef GNUPG_COMMON_NEED_AFLOCAL diff --git a/configure.ac b/configure.ac index 9d3eb41..89ef939 100644 --- a/configure.ac +++ b/configure.ac @@ -1400,16 +1400,16 @@ AC_FUNC_FSEEKO AC_FUNC_VPRINTF AC_FUNC_FORK AC_CHECK_FUNCS([atexit canonicalize_file_name clock_gettime ctermid \ - fcntl flockfile fsync ftello ftruncate funlockfile \ - getaddrinfo getenv getpagesize getpwnam getpwuid \ - getrlimit getrusage gettimeofday gmtime_r \ - inet_ntop inet_pton isascii lstat \ - memicmp memmove memrchr mmap nl_langinfo pipe \ - raise rand setenv setlocale setrlimit sigaction \ - sigprocmask stat stpcpy strcasecmp strerror strftime \ - stricmp strlwr strncasecmp strpbrk strsep \ - strtol strtoul strtoull tcgetattr timegm times \ - ttyname unsetenv wait4 waitpid ]) + explicit_bzero fcntl flockfile fsync ftello \ + ftruncate funlockfile getaddrinfo getenv getpagesize \ + getpwnam getpwuid getrlimit getrusage gettimeofday \ + gmtime_r inet_ntop inet_pton isascii lstat memicmp \ + memmove memrchr mmap nl_langinfo pipe raise rand \ + setenv setlocale setrlimit sigaction sigprocmask \ + stat stpcpy strcasecmp strerror strftime stricmp \ + strlwr strncasecmp strpbrk strsep strtol strtoul \ + strtoull tcgetattr timegm times ttyname unsetenv \ + wait4 waitpid ]) # On some systems (e.g. Solaris) nanosleep requires linking to librl. # Given that we use nanosleep only as an optimization over a select ----------------------------------------------------------------------- Summary of changes: common/iobuf.c | 7 ++++++- common/mischelp.c | 16 ++++++++++++++++ common/mischelp.h | 12 +++--------- configure.ac | 20 ++++++++++---------- g10/mainproc.c | 11 ++++++++--- 5 files changed, 43 insertions(+), 23 deletions(-) hooks/post-receive -- The GNU Privacy Guard http://git.gnupg.org From cvs at cvs.gnupg.org Sat Dec 1 13:01:32 2018 From: cvs at cvs.gnupg.org (by Jussi Kivilinna) Date: Sat, 01 Dec 2018 13:01:32 +0100 Subject: [git] GCRYPT - branch, master, updated. libgcrypt-1.8.1-133-g66d2b7f Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The GNU crypto library". The branch, master has been updated via 66d2b7fc17258f1424f4ca4adb1096e48b818bd0 (commit) via 168668228c7c49e70612cb4d602d6d603a2add2c (commit) from 9d9c4fd18b445ff414d11678285d54af3afdb222 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 66d2b7fc17258f1424f4ca4adb1096e48b818bd0 Author: Jussi Kivilinna Date: Sat Dec 1 12:21:14 2018 +0200 rijndael-aesni: interleave last CTR encryption round with xoring * cipher/rijndael-aesni.c (do_aesni_ctr_8): Interleave aesenclast with input xoring. -- Structure of 'aesenclast' instruction allows reordering last encryption round and xoring of input block for small ~0.5% improvement in performance. Intel i7-4790K @ 4.0 Ghz: AES | nanosecs/byte mebibytes/sec cycles/byte CTR enc | 0.159 ns/B 6002 MiB/s 0.636 c/B CTR dec | 0.159 ns/B 6001 MiB/s 0.636 c/B Signed-off-by: Jussi Kivilinna diff --git a/cipher/rijndael-aesni.c b/cipher/rijndael-aesni.c index 483387c..ec9f4d4 100644 --- a/cipher/rijndael-aesni.c +++ b/cipher/rijndael-aesni.c @@ -1657,14 +1657,6 @@ do_aesni_ctr_8 (const RIJNDAEL_context *ctx, "movdqa 0xe0(%[key]), %%xmm1\n" ".Lenclast%=:\n\t" - "aesenclast %%xmm1, %%xmm0\n\t" - "aesenclast %%xmm1, %%xmm2\n\t" - "aesenclast %%xmm1, %%xmm3\n\t" - "aesenclast %%xmm1, %%xmm4\n\t" - "aesenclast %%xmm1, %%xmm8\n\t" - "aesenclast %%xmm1, %%xmm9\n\t" - "aesenclast %%xmm1, %%xmm10\n\t" - "aesenclast %%xmm1, %%xmm11\n\t" : : [key] "r" (ctx->keyschenc), [rounds] "r" (ctx->rounds) @@ -1674,22 +1666,30 @@ do_aesni_ctr_8 (const RIJNDAEL_context *ctx, "movdqu 1*16(%[src]), %%xmm13\n\t" /* Get block 2. */ "movdqu 2*16(%[src]), %%xmm14\n\t" /* Get block 3. */ "movdqu 3*16(%[src]), %%xmm15\n\t" /* Get block 4. */ - "movdqu 4*16(%[src]), %%xmm1\n\t" /* Get block 5. */ - "pxor %%xmm12, %%xmm0\n\t" /* EncCTR-1 ^= input */ + "movdqu 4*16(%[src]), %%xmm7\n\t" /* Get block 5. */ + "pxor %%xmm1, %%xmm12\n\t" /* block1 ^= lastkey */ + "aesenclast %%xmm12, %%xmm0\n\t" "movdqu 5*16(%[src]), %%xmm12\n\t" /* Get block 6. */ - "pxor %%xmm13, %%xmm2\n\t" /* EncCTR-2 ^= input */ + "pxor %%xmm1, %%xmm13\n\t" /* block2 ^= lastkey */ + "aesenclast %%xmm13, %%xmm2\n\t" "movdqu 6*16(%[src]), %%xmm13\n\t" /* Get block 7. */ - "pxor %%xmm14, %%xmm3\n\t" /* EncCTR-3 ^= input */ + "pxor %%xmm1, %%xmm14\n\t" /* block3 ^= lastkey */ + "aesenclast %%xmm14, %%xmm3\n\t" "movdqu 7*16(%[src]), %%xmm14\n\t" /* Get block 8. */ - "pxor %%xmm15, %%xmm4\n\t" /* EncCTR-4 ^= input */ + "pxor %%xmm1, %%xmm15\n\t" /* block4 ^= lastkey */ + "aesenclast %%xmm15, %%xmm4\n\t" "movdqu %%xmm0, 0*16(%[dst])\n\t" /* Store block 1 */ - "pxor %%xmm1, %%xmm8\n\t" /* EncCTR-5 ^= input */ + "pxor %%xmm1, %%xmm7\n\t" /* block5 ^= lastkey */ + "aesenclast %%xmm7, %%xmm8\n\t" "movdqu %%xmm0, 0*16(%[dst])\n\t" /* Store block 1 */ - "pxor %%xmm12, %%xmm9\n\t" /* EncCTR-6 ^= input */ + "pxor %%xmm1, %%xmm12\n\t" /* block6 ^= lastkey */ + "aesenclast %%xmm12, %%xmm9\n\t" "movdqu %%xmm2, 1*16(%[dst])\n\t" /* Store block 2. */ - "pxor %%xmm13, %%xmm10\n\t" /* EncCTR-7 ^= input */ + "pxor %%xmm1, %%xmm13\n\t" /* block7 ^= lastkey */ + "aesenclast %%xmm13, %%xmm10\n\t" "movdqu %%xmm3, 2*16(%[dst])\n\t" /* Store block 3. */ - "pxor %%xmm14, %%xmm11\n\t" /* EncCTR-8 ^= input */ + "pxor %%xmm1, %%xmm14\n\t" /* block8 ^= lastkey */ + "aesenclast %%xmm14, %%xmm11\n\t" "movdqu %%xmm4, 3*16(%[dst])\n\t" /* Store block 4. */ "movdqu %%xmm8, 4*16(%[dst])\n\t" /* Store block 8. */ "movdqu %%xmm9, 5*16(%[dst])\n\t" /* Store block 9. */ commit 168668228c7c49e70612cb4d602d6d603a2add2c Author: Jussi Kivilinna Date: Tue Nov 13 22:08:50 2018 +0200 Use explicit_bzero for wipememory * configure.ac (AC_CHECK_FUNCS): Check for 'explicit_bzero'. * src/g10lib.h (wipememory2): Use _gcry_fast_wipememory if _SET is zero. (_gcry_fast_wipememory): New. (_gcry_wipememory2): Rename to... (_gcry_fast_wipememory2): ...this. * src/misc.c (_gcry_wipememory): New. (_gcry_wipememory2): Rename to... (_gcry_fast_wipememory2): ...this. (_gcry_fast_wipememory2) [HAVE_EXPLICIT_BZERO]: Use explicit_bzero if SET is zero. (_gcry_burn_stack): Use _gcry_fast_wipememory. -- Signed-off-by: Jussi Kivilinna diff --git a/configure.ac b/configure.ac index 9803d51..5843884 100644 --- a/configure.ac +++ b/configure.ac @@ -1772,6 +1772,7 @@ AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise) AC_CHECK_FUNCS(strerror rand mmap getpagesize sysconf waitpid wait4) AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime syslog) AC_CHECK_FUNCS(syscall fcntl ftruncate flockfile) +AC_CHECK_FUNCS(explicit_bzero) GNUPG_CHECK_MLOCK diff --git a/src/g10lib.h b/src/g10lib.h index 9b21478..694c2d8 100644 --- a/src/g10lib.h +++ b/src/g10lib.h @@ -334,15 +334,16 @@ void __gcry_burn_stack (unsigned int bytes); do { __gcry_burn_stack (bytes); \ __gcry_burn_stack_dummy (); } while(0) - /* To avoid that a compiler optimizes certain memset calls away, these macros may be used instead. For small constant length buffers, memory wiping is inlined. For non-constant or large length buffers, - memory is wiped with memset through _gcry_wipememory. */ -void _gcry_wipememory2(void *ptr, int set, size_t len); + memory is wiped with memset through _gcry_fast_wipememory. */ #define wipememory2(_ptr,_set,_len) do { \ if (!CONSTANT_P(_len) || _len > 64) { \ - _gcry_wipememory2((void *)_ptr, _set, _len); \ + if (CONSTANT_P(_set) && (_set) == 0) \ + _gcry_fast_wipememory((void *)_ptr, _len); \ + else \ + _gcry_fast_wipememory2((void *)_ptr, _set, _len); \ } else {\ volatile char *_vptr = (volatile char *)(_ptr); \ size_t _vlen = (_len); \ @@ -353,6 +354,9 @@ void _gcry_wipememory2(void *ptr, int set, size_t len); } while(0) #define wipememory(_ptr,_len) wipememory2(_ptr,0,_len) +void _gcry_fast_wipememory(void *ptr, size_t len); +void _gcry_fast_wipememory2(void *ptr, int set, size_t len); + #if defined(HAVE_GCC_ATTRIBUTE_PACKED) && \ defined(HAVE_GCC_ATTRIBUTE_ALIGNED) && \ defined(HAVE_GCC_ATTRIBUTE_MAY_ALIAS) diff --git a/src/misc.c b/src/misc.c index 420ce74..bb39e1c 100644 --- a/src/misc.c +++ b/src/misc.c @@ -32,6 +32,8 @@ static int verbosity_level = 0; +/* Prevent compiler from optimizing away the call to memset by accessing + memset through volatile pointer. */ static void *(*volatile memset_ptr)(void *, int, size_t) = (void *)memset; static void (*fatal_error_handler)(void*,int, const char*) = NULL; @@ -500,8 +502,37 @@ _gcry_strtokenize (const char *string, const char *delim) void -_gcry_wipememory2 (void *ptr, int set, size_t len) +_gcry_fast_wipememory (void *ptr, size_t len) { + /* Note: This function is called from wipememory/wipememory2 only if LEN + is large or unknown at compile time. New wipe function alternatives + need to be checked before adding to this function. New implementations + need to be faster than wipememory/wipememory2 macros in 'misc.h'. + + Following implementations were found to have suboptimal performance: + + - [_WIN32/mingw32] SecureZeroMemory; Inline function, equivalent to + volatile byte buffer set: while(buflen--) (volatile char *)(buf++)=set; + */ +#ifdef HAVE_EXPLICIT_BZERO + explicit_bzero (ptr, len); +#else + memset_ptr (ptr, 0, len); +#endif +} + + +void +_gcry_fast_wipememory2 (void *ptr, int set, size_t len) +{ +#ifdef HAVE_EXPLICIT_BZERO + if (set == 0) + { + explicit_bzero (ptr, len); + return; + } +#endif + memset_ptr (ptr, set, len); } @@ -514,11 +545,11 @@ __gcry_burn_stack (unsigned int bytes) unsigned int buflen = ((!bytes + bytes) + 63) & ~63; char buf[buflen]; - memset_ptr (buf, 0, buflen); + _gcry_fast_wipememory (buf, buflen); #else volatile char buf[64]; - wipememory (buf, sizeof buf); + _gcry_fast_wipememory (buf, sizeof buf); if (bytes > sizeof buf) _gcry_burn_stack (bytes - sizeof buf); ----------------------------------------------------------------------- Summary of changes: cipher/rijndael-aesni.c | 34 +++++++++++++++++----------------- configure.ac | 1 + src/g10lib.h | 12 ++++++++---- src/misc.c | 37 ++++++++++++++++++++++++++++++++++--- 4 files changed, 60 insertions(+), 24 deletions(-) hooks/post-receive -- The GNU crypto library http://git.gnupg.org From cvs at cvs.gnupg.org Mon Dec 3 10:41:08 2018 From: cvs at cvs.gnupg.org (by Werner Koch) Date: Mon, 03 Dec 2018 10:41:08 +0100 Subject: [git] GPGME - branch, master, updated. gpgme-1.12.0-85-g649b196 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GnuPG Made Easy". The branch, master has been updated via 649b19688132dd315e361c0f5b63ba6d8f45996d (commit) from 2e3a681d0c35bbf6db584fedc9d7f0a010430b51 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 649b19688132dd315e361c0f5b63ba6d8f45996d Author: Werner Koch Date: Mon Dec 3 10:40:52 2018 +0100 doc: Minor comment cleanups. -- Signed-off-by: Werner Koch diff --git a/doc/gpgme.texi b/doc/gpgme.texi index 7d410f8..e04c301 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -2461,9 +2461,9 @@ the context @var{ctx} to @var{proto}. All crypto operations will be performed by the crypto engine configured for that protocol. @xref{Protocols and Engines}. -Setting the protocol with @code{gpgme_set_protocol} does not check if -the crypto engine for that protocol is available and installed -correctly. @xref{Engine Version Check}. +Setting the protocol with @code{gpgme_set_protocol} does intentionally +not check if the crypto engine for that protocol is available and +installed correctly. @xref{Engine Version Check}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the protocol could be set successfully, and @code{GPG_ERR_INV_VALUE} if diff --git a/lang/python/doc/rst/gpgme-python-howto.rst b/lang/python/doc/rst/gpgme-python-howto.rst index d1cb3fd..71dd72a 100644 --- a/lang/python/doc/rst/gpgme-python-howto.rst +++ b/lang/python/doc/rst/gpgme-python-howto.rst @@ -8,16 +8,10 @@ Introduction +-----------------------------------+-----------------------------------+ | GPGME Version: | 1.12.1 | +-----------------------------------+-----------------------------------+ -| Author: | `Ben | -| | McGinnes `__ | -| | | +| Author: | Ben McGinnes | +-----------------------------------+-----------------------------------+ -| Author GPG Key: | `DB4724E6FA4286C92B4E55C4321E4E23 | -| | 73590E5D `__ | +| Author GPG Key: | DB4724E6FA4286C92B4E55C4321E4E23 | +| | 73590E5D | +-----------------------------------+-----------------------------------+ | Language: | Australian English, British | | | English | diff --git a/src/gpgme.c b/src/gpgme.c index a0a6c6b..65a2e30 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -320,6 +320,8 @@ _gpgme_release_result (gpgme_ctx_t ctx) } +/* Note that setting the protocol will intentionally not fail if the + * engine is not available. */ gpgme_error_t gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t protocol) { ----------------------------------------------------------------------- Summary of changes: doc/gpgme.texi | 6 +++--- lang/python/doc/rst/gpgme-python-howto.rst | 12 +++--------- src/gpgme.c | 2 ++ 3 files changed, 8 insertions(+), 12 deletions(-) hooks/post-receive -- GnuPG Made Easy http://git.gnupg.org From cvs at cvs.gnupg.org Mon Dec 3 12:25:03 2018 From: cvs at cvs.gnupg.org (by Andre Heinecke) Date: Mon, 03 Dec 2018 12:25:03 +0100 Subject: [git] GPGME - branch, master, updated. gpgme-1.12.0-86-g1d31420 Message-ID: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GnuPG Made Easy". The branch, master has been updated via 1d31420650bfa7ca1d1503cc7431b3360e86022c (commit) from 649b19688132dd315e361c0f5b63ba6d8f45996d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 1d31420650bfa7ca1d1503cc7431b3360e86022c Author: Andre Heinecke Date: Mon Dec 3 12:20:33 2018 +0100 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. diff --git a/lang/cpp/src/Makefile.am b/lang/cpp/src/Makefile.am index 1e6bdc2..1b1de32 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 f7692a0..21c2a81 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 8ccc05e..33c812f 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