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)
-Wstrict-prototypes
-Wdisabled-optimization
-Wpointer-arith
+ -Wfloat-conversion
);
# These are used in addition to $gcc_devteam_warn when the compiler is clang.
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;