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

Re: openntpd and ntpq



> Brett Lymn wrote:
> > 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.
> 
> Rubbish. Keeping things in a canonical wire format is a *very* common
> idiom.

In my past it was always a thing to decide on a case to case basis.

While auditing code about 5 years ago I came to the conclusion that it
definately weighs in the direction of "convert late", though.

Keep in network byte order until later.  Having structures which are
obviously on-the-wire order swap back and forth just creates more
chances for error.  You don't see people byte swapping IP addresses
in sockaddr's after getting them back from accept(), after all.