✘integer overflow in expression

Eric S. Raymond esr at thyrsus.com
Thu Sep 29 03:58:39 UTC 2016


Gary E. Miller <gem at rellim.com>:
> Yo All!
> 
> I'm getting a new warning on the build:
> 
> [153/250] Compiling util/sht.c
> ../../util/hist.c: In function ‘main’:
> ../../util/hist.c:22:20: warning: integer overflow in expression [-Woverflow]
>  #define NCNT (600L * NANOSECONDS) /* sample interval (ns) */
>                     ^
> ../../util/hist.c:57:15: note: in expansion of macro ‘NCNT’
>    if (u - v > NCNT)
>                ^
> 
> I'm guessing this commit: d9024785b6c5a8b648b4f6a6982b6de1d2afa286

Yeah, I got that warning and fixed it by giving the NANOSECONDS value an 'L'
suffix so the expression is long-valued. Are you building on a 32-bit
machine?

The series of changes that produced this was, by the way, intended to do
two worthwhile things:

(1) Narrow the interface to the system clock so only the non-deprecated
POSIX clock_gettime and clock_gettime calls are used, eliminating gettimeofday
and settimeofday.

(2) Move us towards having all time computations being done at nanosecond
precision. Right now there is a mix of nanosecond- and microsecond-scale
computation which has already turned out to unnecessarily lose precision
in one stepping scenario; I strongly suspect there are others.

Note that this series did not actually change what ntpd does on
POSIX-conformant systems. ntpd was using clock_gettime and clock_settime
before and still does that now; the change away from settimeofday only
affected auxiliary programs.
-- 
		<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: not available
URL: <http://lists.ntpsec.org/pipermail/devel/attachments/20160928/bd0b19d1/attachment.bin>


More information about the devel mailing list