This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2] time: Introduce function to check correctness of nanoseconds value


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]