Commit b3fbf9da79 for openssl.org
commit b3fbf9da7973e0c68727aa87d75a112c9e06c7fe
Author: Milan Broz <gmazyland@gmail.com>
Date: Wed Jan 14 13:31:39 2026 +0100
Add float-conversion to default strict warnings
As discussed, bad-function-cast and conversion produces strange results.
Add at least float-conversion - Warn for implicit conversions that reduce
the precision of a real value.
Also fix ct_test absolute value seconds calculation (without using math.h)
and then converts is to time_t.
(n.b. this is not stricly needed for the relaxed warnings, but it is more readable)
Fixes: https://github.com/openssl/project/issues/1816
Signed-off-by: Milan Broz <gmazyland@gmail.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jan 22 09:58:07 2026
(Merged from https://github.com/openssl/openssl/pull/29663)
diff --git a/Configure b/Configure
index 28c7b05c23..3e9385ea4e 100755
--- a/Configure
+++ b/Configure
@@ -182,6 +182,7 @@ my @gcc_devteam_warn = qw(
-Wstrict-prototypes
-Wdisabled-optimization
-Wpointer-arith
+ -Wfloat-conversion
);
# These are used in addition to $gcc_devteam_warn when the compiler is clang.
diff --git a/test/ct_test.c b/test/ct_test.c
index 183e7d8de6..6d970cbe20 100644
--- a/test/ct_test.c
+++ b/test/ct_test.c
@@ -479,10 +479,14 @@ static int test_default_ct_policy_eval_ctx_time_is_now(void)
int success = 0;
CT_POLICY_EVAL_CTX *ct_policy_ctx = CT_POLICY_EVAL_CTX_new();
const time_t default_time = (time_t)(CT_POLICY_EVAL_CTX_get_time(ct_policy_ctx) / 1000);
- const time_t time_tolerance = 600; /* 10 minutes */
+ const double time_tolerance = 600; /* 10 minutes */
+ double seconds;
- if (!TEST_time_t_le(abs((int)difftime(time(NULL), default_time)),
- time_tolerance))
+ seconds = difftime(time(NULL), default_time);
+ if (seconds < 0.0)
+ seconds = -seconds;
+
+ if (!TEST_double_le(seconds, time_tolerance))
goto end;
success = 1;