From f59455d054a79068ebf480cd28f02993c1facf3b Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 27 Nov 2019 20:15:53 +0100 Subject: [PATCH] dirmngr: Replace no-strict-overflow pragma by wrapv pragma. * dirmngr/dirmngr.c (time_for_housekeeping_p): Build with --fwrapv. Replace protecting macro. -- I once replaced all JNLIB macros by GPGRT macros. However, I missed to get this right for the push pragma test and used GPGRT_GCC_HAVE_PUSH_PRAGMA instead of the correct GPGRT_HAVE_PRAGMA_GCC_PUSH Now after fixing this it turned out that no-strict-overflow is not anymore supported as oprimize pragma and thus I replaced that too according to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58454 . Tested with 32 bit Windows but the real test will be in 2038. Signed-off-by: Werner Koch --- dirmngr/dirmngr.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c index 7948e3f24..8f28fa43d 100644 --- a/dirmngr/dirmngr.c +++ b/dirmngr/dirmngr.c @@ -1984,9 +1984,14 @@ housekeeping_thread (void *arg) } -#if GPGRT_GCC_HAVE_PUSH_PRAGMA +/* We try to enable correct overflow handling for signed int (commonly + * used for time_t). With gcc 4.2 -fno-strict-overflow was introduced + * and used here as a pragma. Later gcc versions (gcc 6?) removed + * this as a pragma and -fwrapv was then suggested as a replacement + * for -fno-strict-overflow. */ +#if GPGRT_HAVE_PRAGMA_GCC_PUSH # pragma GCC push_options -# pragma GCC optimize ("no-strict-overflow") +# pragma GCC optimize ("wrapv") #endif static int time_for_housekeeping_p (time_t curtime) @@ -2004,7 +2009,7 @@ time_for_housekeeping_p (time_t curtime) } return 0; } -#if GPGRT_GCC_HAVE_PUSH_PRAGMA +#if GPGRT_HAVE_PRAGMA_GCC_PUSH # pragma GCC pop_options #endif