[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: openntpd and ntpq



On Fri, Sep 03, 2004 at 01:16:46PM +0200, Henning Brauer wrote:
> 
> There is no point in transforming something to host byte order 
> that is never used on the host.
>

Currently never used, currently.  If someone decided to add to your
code then they may introduce an endian sensitive bug by assuming the
internal data is in host endian.  What you are doing violates the
principle of least surprise - by doing that you lay the way open for
bugs.
 
> maybe the ntohl is not where YOU would expect it, but it's actually in 
> a very logical place, in the function that converts from the ntp 
> timestamp format to a double used internally.

Of course, I disagree with that - the internal data structure should
be entirely in host native endian, the conversion done when the packet
is taken off or put onto the wire.  We are not talking a huge packet rate
here nor are we talking an excessive number of ntoh(s,l) calls, calls
that may compile to null code anyway depending on the architecture.  I
suspect that you spend more time calling arc4random to mangle the
transmit time than would be spent doing the conversions.

I doubt if any of this will cause any change at all.  Just allow me to
fill out an "I told you so" token that I can redeem on the occasion of
the first endian bug that bites openntpd.

-- 
Brett Lymn