This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2] time: Introduce function to check correctness of nanoseconds value
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Lukasz Majewski <lukma at denx dot de>
- Cc: Paul Eggert <eggert at cs dot ucla dot edu>, Alistair Francis <alistair23 at gmail dot com>, Alistair Francis <alistair dot francis at wdc dot com>, GNU C Library <libc-alpha at sourceware dot org>, Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, Florian Weimer <fweimer at redhat dot com>, Florian Weimer <fw at deneb dot enyo dot de>, Zack Weinberg <zackw at panix dot com>
- Date: Fri, 25 Oct 2019 21:25:47 +0000
- Subject: Re: [PATCH v2] time: Introduce function to check correctness of nanoseconds value
- Ironport-sdr: CTmvo6tgxsiGCbRp1HTPDigcdpTy92WwsMkxTCos8rjnxPVXprliUv0N+llkpCm3rrAQJHbtXd KUmXAi0a5dpHf8Sd+OUQdcZMQMHglQTChOT8Z3tYv5X8e98pMdI+ayaApyvD/TZrwT7KWdwSpJ 8F0/Bt2ZEOSupQlR8PRgMNAHEUDyM0zF7hHil+/B8+Ne5EVYq1g03ZIAe0tI/EIUflunzUQx52 m656PcMxQaOuIIrWWef6rG6tl1x2GbaHY/TnUNfK8c2Gpvv8mYHAXFjDiv7tU0dLc95+0xYjot 9O0=
- Ironport-sdr: W4pl2eeVmGgYzAPz88yVNzSeHcmMj9SF8FITH6a8JDXA0maIaTe6sNMYTOVImbF3c7d328HD9k TCq5T5raRSgO7SzwT6b0NuwmXn+9pYenLDGATZ2MzBz7pEgskwdr5V1XC3S986a6qDAlgmGYAv yHkHMggL46yKSuG92nuu+pZGTak+fKXpOOoEcmGfvhG21MQjh1GFTf+tAJ09yqu2SiHjPaFQWi CRZQUVY8lssdexVXM/lGCHaquPKzGqaaeuSAPpW/8alZFmxS7rZkWLAAFonPcSRRckZQ/0+8Ex EdA=
- References: <20191025132229.16703-1-lukma@denx.de>
On Fri, 25 Oct 2019, Lukasz Majewski wrote:
> diff --git a/include/time.h b/include/time.h
> index d93b16a781..68c6cc46cc 100644
> --- a/include/time.h
> +++ b/include/time.h
> @@ -236,5 +236,13 @@ valid_timespec64_to_timeval (const struct __timespec64 ts64)
>
> return tv;
> }
> +
> +/* Check if a value is in the valid nanoseconds range. Return true if
> + it is, false otherwise. */
> +static inline bool
> +valid_nanoseconds (long int ns)
Since we do, unfortunately, have x32 where tv_nsec is __syscall_slong_t
which is different from long int, I think __syscall_slong_t is what should
be used here to keep the checks consistent with how tv_nsec is declared.
If in future bug 16437 is fixed to make x32 use long int here (possibly by
relying on 5.1.5 or later kernels, if the fix there to handling of
timespec padding for compat tasks also applied to x32), this function
should be changed to use long int again at the same time.
The patch is OK with the change to use __syscall_slong_t.
--
Joseph S. Myers
joseph@codesourcery.com