This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] time: Introduce function to check correctness of nanoseconds value
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: Lukasz Majewski <lukma at denx dot de>, Joseph Myers <joseph at codesourcery dot com>
- Cc: 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: Thu, 24 Oct 2019 14:41:48 -0700
- Subject: Re: [PATCH] time: Introduce function to check correctness of nanoseconds value
- References: <20191024211441.28722-1-lukma@denx.de>
On 10/24/19 2:14 PM, Lukasz Majewski wrote:
+static inline bool valid_nanoseconds (long ns)
+{
+ if (__glibc_likely (ns >= 0 && ns <= 999999999))
+ return true;
+
+ return false;
+}
The function name should be at the start of the line.
Doesn't glibc prefer 'long int' to 'long'?
The function body should simply be 'return __glibc_likely (0 <= ns && ns
< 1000000000);' (for range checks I prefer textual order to reflect
numeric order).