This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: RFC on enforcing best-practice through wrappers? [PR15819, PR15722]
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Alexandre Oliva <aoliva at redhat dot com>
- Cc: <libc-alpha at sourceware dot org>
- Date: Wed, 5 Nov 2014 16:45:21 +0000
- Subject: Re: RFC on enforcing best-practice through wrappers? [PR15819, PR15722]
- Authentication-results: sourceware.org; auth=none
- References: <oroasm6pw9 dot fsf at free dot home>
On Wed, 5 Nov 2014, Alexandre Oliva wrote:
> + struct timeval __now;
> + (void) __gettimeofday (&__now, NULL);
> +
> + long int __end = __now.tv_sec * 1000 + __timeout
> + + (__now.tv_usec + 500) / 1000;
This multiplication by 1000 will overflow on 32-bit systems. Things may
in fact work OK if it wraps around, but it's not a good idea to rely on
that without explicit casts to unsigned and comments about why it's OK
even when things wrap around. (Pre-existing condition in the code you're
moving.)
--
Joseph S. Myers
joseph@codesourcery.com