This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v5 1/2] Y2038: Add 64-bit time for all architectures
On 06/18/2018 12:14 PM, Albert ARIBAUD (3ADEV) wrote:
+/* Check whether a time64_t value fits in a time_t. */
+static inline bool
+fits_in_time_t (__time64_t t)
+{
+ return t == (time_t) t;
+}
This static function is used nowhere in this patch series. Shouldn't its
introduction be delayed to the first patch that actually needs it?
Also, looking at the two future uses of this function, they're both of
the form:
__time64_t t64 = [something];
if (fits_in_time_t (t64))
return (time_t) t64;
__set_errno (EOVERFLOW);
return -1;
Wouldn't it be better to have these uses do the following instead? This
would be just as clear, and would avoid the need for casts and for the
fits_in_time_t function.
__time64_t t64 = [something];
time_t t = t64;
if (t == t64)
return t;
__set_errno (EOVERFLOW);
return -1;