sys/time: appease gcc -Wtype-limits

In environments where time_t is 32 bits, including the 32-bit library
build on amd64, the overflow being tested for cannot happen, and gcc
complains with -Wtype-limits, causing the gcc build to fail.  Work
around this by ifdef'ing out the saturation code on i386.

Reviewed by:	imp, jfree
Discussed with:	markj
Fixes:	e3799530b3 ("sys/time: Add saturating sbt conversions")
Differential Revision:	https://reviews.freebsd.org/D56369
This commit is contained in:
Ryan Libby
2026-04-15 01:08:37 -07:00
parent 3e27114a7f
commit 00dccc3164
+4
View File
@@ -355,10 +355,12 @@ tstosbt(struct timespec _ts)
static __inline sbintime_t
tstosbt_sat(struct timespec _ts)
{
#ifndef __i386__
if (_ts.tv_sec > SBT_MAX >> 32)
return (SBT_MAX);
if (_ts.tv_sec < -(SBT_MAX >> 32) - 1)
return (-SBT_MAX - 1);
#endif
return (tstosbt(_ts));
}
@@ -382,10 +384,12 @@ tvtosbt(struct timeval _tv)
static __inline sbintime_t
tvtosbt_sat(struct timeval _tv)
{
#ifndef __i386__
if (_tv.tv_sec > SBT_MAX >> 32)
return (SBT_MAX);
if (_tv.tv_sec < -(SBT_MAX >> 32) - 1)
return (-SBT_MAX - 1);
#endif
return (tvtosbt(_tv));
}