Subject: duplicate members fix on Solaris Netatalk

From: Dejan Ilic <[email-masked]>
Date: Sat, 21 Jun 1997 01:39:27 +0200 (MET DST)

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.

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.

Also this prototype match is needed to get thru compilation on
Solaris_x86 2.5 :

--- libatalk/compat/strcasecmp.c.ORIG   Sat Jun 21 02:35:00 1997
+++ libatalk/compat/strcasecmp.c        Sat Jun 21 02:32:09 1997
@@ -70,7 +70,11 @@

 int
 strcasecmp(s1, s2)
+#ifdef SOLARIS
+       const char *s1, *s2;
+#else
        char *s1, *s2;
+#endif
 {
        register u_char *cm = charmap,
                        *us1 = (u_char *)s1,
@@ -84,7 +88,11 @@

 int
 strncasecmp(s1, s2, n)
+#ifdef SOLARIS
+       const char *s1, *s2;
+#else
        char *s1, *s2;
+#endif
        register size_t n;
 {
        if (n != 0) {

=====================================================================
Dejan Ilic, Tech Univ. of Linkoping, Sweden   Phone: +46-13-473 01 06
Email: [email-masked]   Web: http://www.lysator.liu.se/~svedja

"I may look like The Devil but i'm an angel deep down in my heart"
=====================================================================
[finger -l [email-masked] for public PGP key]

---

From: Bill Studenmund <[email-masked]>
Date: Fri, 20 Jun 1997 16:53:40 -0700 (PDT)

> 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.

> 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.

---

From: Dejan Ilic <[email-masked]>
Date: Sat, 21 Jun 1997 02:05:32 +0200 (MET DST)

> Shouldn't it actually be "BYTE_ORDER == BIG_ENDIAN" becomes " == " which

Well, GCC 2.7.2.2 passes that line as no error has happend. Maybe another
compiler would have triggered a error there but not GCC. I dont have
Sun-CC to check what happends on another compiler.

Anyway including "#include <endian.h>" makes the problem dissapear.

> got included anyway. I.E. if a file includes ddp.h, it should be including

As you can see it doesn't, at least no the "dpp.h" in solaris directory. I
complained about the existance of several files with the same name in
different directorys. It is maybe correct in another directory.

> Checking to make sure BYTE_ORDER is defined is better.

Agreed. That would be best.

---

From: Bill Studenmund <[email-masked]>
Date: Sat, 21 Jun 1997 16:25:46 -0700 (PDT)

> Sun-CC to check what happends on another compiler.

Weird.

> different directorys. It is maybe correct in another directory.

No. ddp.h isn't supposed to include endian.h. Any program file which
includes ddp.h is already supposed to be including endian.h.

I did a search on the files in libatalk, and of the five files which
include atalk/ddp.h, only one (libatalk/atp/atp_packet.c) doesn't also
include atalk/endian.h.

In bin, bin/aecho/aecho.c is fine (includes both). In /etc, only files in
atalkd include ddp.h. Of them, main.c, rtmp.c, and zip.c are fine, but
aep.c and nbp.c don't also include endian.h.

So rather than change ddp.h, I think the better fix is for all files which
include ddp.h to also be including endian.h. That means adding an include
line to three files. :-)

Take care,

Bill

---

From: [email-masked]
Date: Sat, 21 Jun 1997 21:37:28 -0400

> From:    Bill Studenmund <[email-masked]>
> To:      [email-masked]

> include atalk/ddp.h, only one (libatalk/atp/atp_packet.c) doesn't also

I think he's talking about the solaris stuff.

;wes

---

From: Dejan Ilic <[email-masked]>
Date: Sun, 22 Jun 1997 11:18:50 +0200 (MET DST)

> I think he's talking about the solaris stuff.

Yes, I was talking about Solaris part. The only that shoewed any
compilation-problem. But the same problem can maybe be found on other
places in the source.