]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add float-conversion to default strict warnings
authorMilan Broz <gmazyland@gmail.com>
Wed, 14 Jan 2026 12:31:39 +0000 (13:31 +0100)
committerNorbert Pocs <norbertp@openssl.org>
Thu, 22 Jan 2026 09:57:55 +0000 (10:57 +0100)
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)

Configure
test/ct_test.c

index 28c7b05c236c964a3c4a277dc8f31d76bb8b0cbb..3e9385ea4ef76bc49d67019ce646d83a0f5a1e00 100755 (executable)
--- 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.
index 183e7d8de6d2dfa821d394d97eed97dfc9192355..6d970cbe20223501f23b8165384d2193cd709a64 100644 (file)
@@ -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;