[ntp:hackers] Re: typos in ntpv4 code skeleton

David L. Mills mills at udel.edu
Thu Sep 14 15:27:10 PDT 2006


Folks,

In the enclosed message, Robert pointed out several typos/muffs in the 
code skeleton. I fixed them and found several more on my own. The 
updates are in the build directory linked from the NTP project page.

In my zest to make the code segments simple and easily understood, I 
omitted the nasty little details in the ntp_fp.h file in the 
distribution. So, I just declared the NTP timestamp tstamp typedef as an 
int64. I'm not sure what gcc does with this; but it complains about word 
overflow. If anyone has wisdom about a clean way to do this, 
contributions would be gladly accepted.

Dave

Robert R. Henry wrote:

> David:
>
> Per your suggestion "...designed to be compiled only in order to verify
> consistent ..." I compiled your ntpv4 code skeletons using gcc -Wall,
> and found a number of typos (which are also in your TR-06-6-1).
>
> If you compile this code with any modern gcc -Wall you'll see these:
>
> http://www.cis.udel.edu/~mills/database/brief/flow/main.c
> have:
> p->flags == flags;
> want(?):
> p->flags = flags;
>
> http://www.cis.udel.edu/~mills/database/brief/flow/poll.c
> have:
> p->reach << 1;
> want(?):
> p->reach <<= 1;
>
> http://www.cis.udel.edu/~mills/database/brief/flow/peer.c
> have:
> struct p *p; /* peer structure pointer
> int auth; /* authentication code */
> want (eg, close off the comment on the end of the decl for *p):
> struct p *p; /* peer structure pointer */
> int auth; /* authentication code */
>
> have:
> } else if (has_mac == 4) {
> auth == A_CRYPTO; /* crypto-NAK */
> want:
> } else if (has_mac == 4) {
> auth = A_CRYPTO; /* crypto-NAK */
>
> http://www.cis.udel.edu/~mills/database/brief/flow/system.c
> have:
> * system peer change, avoid it. We never use an old sample or
> * the same sample twice.
> *
> if (s.t >= p->t)
> return;
> want: (close off the comment)
> * system peer change, avoid it. We never use an old sample or
> * the same sample twice.
> */
> if (s.t >= p->t)
> return;
> function receive automatic (local) variable auth is declared 2 times
>
> There are also 5 places where gcc complains about comparision
> between signed and unsigned.
>
> In addition, if you compile g++, which is even stricter about things,
> you'll see warnings about implicit conversions between double and
> long or int.
>
> Robert Henry, PhD
> Cray, Inc




More information about the hackers mailing list