Re: duplicate members fix on Solaris Netatalk


Subject: Re: duplicate members fix on Solaris Netatalk
From: Bill Studenmund (skippy@macro.stanford.edu)
Date: Fri Jun 20 1997 - 19:53:40 EDT


On Sat, 21 Jun 1997, Dejan Ilic wrote:

> ddp.h is missing a "#include <endian.h>"
>
> and thus "BYTE_ORDER == BIG_ENDIAN" would mean "0 == 0" because non of
> them would be defined, and that is equal. Very dangerous and nasty bug.
> Same for little_endian check.

Shouldn't it actually be "BYTE_ORDER == BIG_ENDIAN" becomes " == " which
is a syntax error???

Also, I thought that all the include files were arranged so that endian.h
got included anyway. I.E. if a file includes ddp.h, it should be including
endian.h anyway.

> We are going to find more bugs like this in the future so I think we
> should avoid them. I propose that we just use simle checks like "#ifdef
> BIG_ENDIAN" to avoid problems like above.

The problem with that is that BIG_ENDIAN isn't defined only if you're on a
big-endian machine. It's the byte order tag which means big endian.

On NetBSD, on an i386, machine/endian.h says:

#define LITTLE_ENDIAN 1234
#define BIG_ENDIAN 4321
#define PDP_ENDIAN 3412

#define BYTE_ORDER LITTLE_ENDIAN

on an m68k NetBSD machine, only the last define is changed. So both
BIG_ENDIAN and LITTLE_ENDIAN are defined on both.

Checking to make sure BYTE_ORDER is defined is better.



This archive was generated by hypermail 2b28 : Sat Dec 18 1999 - 16:25:06 EST