[ntp:hackers] Re: get_systime renormalization
David L. Mills
mills at udel.edu
Thu Jan 6 11:42:52 PST 2005
Mark,
Absolutely correct and that "bug" has been there for several years,
although the chance it can happen is very, very small. In fact, it is
not strictly necessary to normalize the time value, since it washes out
in the subsequent difference computations. I fixed it anyway.
Dave
Mark Martinec wrote:
>The current libntp/systime.c contains the following code section:
>
>void
>get_systime(
>...
> now->l_i = ts.tv_sec + JAN_1970;
> dtemp = ts.tv_nsec / 1e9;
>...
> /*
> * Renormalize to seconds past 1900 and fraction.
> */
> dtemp += sys_residual;
> if (dtemp >= 1) {
> dtemp -= 1;
> now->l_i++;
> } else if (dtemp < -1) {
> dtemp += 1;
> now->l_i--;
> }
> dtemp *= FRAC;
> now->l_uf = (u_int32)dtemp;
>
>
>Shouldn't the "else if" be:
>
> } else if (dtemp < 0) {
>
>???
>
> Mark
>
More information about the hackers
mailing list