> I see naddy@ already commited a fix for this from NetBSD. Thank
> you!
> 
> My patch fwiw was to cast second arg to std::max() to long.
> 
> $OpenBSD$
> --- src/Toolbar.cc.orig       Sat Aug 17 16:58:14 2013
> +++ src/Toolbar.cc    Sat Aug 17 17:08:12 2013
> @@ -44,7 +44,7 @@ long nextTimeout(int resolution)
>  {
>    timeval now;
>    gettimeofday(&now, 0);
> -  return (std::max(1000l, ((((resolution - (now.tv_sec % resolution)) * 
> 1000l))
> +  return (std::max(1000l, (long)((((resolution - (now.tv_sec %
> resolution)) * 1000l))
>                             - (now.tv_usec / 1000l))));
>  }

So basically, this takes a long long value, and casts it to a long.

So, on a 32 bit machine, that throws away the high bits.

Meaning it will make it compile today, but it will break in 2038.

So, let me summarize.  the transition to 'long long' exposes a real
problem.  The addition of this (long) cast now hides the problem; so
that sometime further into the future someone is going to have a
harder time fixing it right.

That is wrong.

Reply via email to