
From dave@fly.cc.fer.hr Tue Oct  6 08:12:02 1998
Date: Mon, 5 Oct 1998 12:54:11 +0200
From: Drazen Kacar <dave@fly.cc.fer.hr>
To: d94-ebr@nada.kth.se
Subject: Re: Gentoo on Solaris

Emil Brink wrote:
> On Mon, 5 Oct 1998, Drazen Kacar wrote:
> 
> > My friend and I tried to compile gentoo 0.9.10 on Solaris 2.6.
> > It needed some tweaking and eventually we got the executable which
> 
> Cool! I would do that myself, if only I had GTK+ available on the
> Solaris machines I've got access to (at school).

:-) I've compiled it just before trying to compile gentoo. My host
is at the university, but I hapen to be admin.

> This is somewhat my fault - the config file in the archive is old.
> Sorry about that. If you have access to a Linux system, perhaps you
> could have used that to configure gentoo, then just copy the config
> to the Solaris box(en).

I do, but I try not to use it. It's not very stable.

> I don't think gentoo requires *GNU* file, any old version of file
> should work, provided it has the same output format as the one
> supplied with Linux (which is not, by the way) GNU. But you're right,
> the version of file supplied with Solaris doesn't seem to recognize
> the use of "-f -" to read stdin. That really is required, so I'm at a
> loss. Solaris sucks?

You're right. I didn't check the man page then. I'll have to install
something better soon. 

> Whoah. Big diff... Could you describe the nature of the changes done,
> so I can learn something without applying the patch and see what
> changed?

Heh. First of all, it was compiled with Sun cc. cc (without any
special flags) happens to be (in some areas, at least) stricter
with respect to ANSI than "gcc -Wall". In plain English, gcc
is buggy.

You have "(gpointer)pointer + 1" at several places. That should
not compile on *any* compiler. Gpointer is typedeffed to
void pointer and pointher arithmetic is undefined for void
pointers. You wanted to cast it to char pointer. That's your
worst mistake in C code, with a very simple fix, fortunatelly.

Now the portability issues. You #include <asm/types.h>.
You should #include <sys/types.h>. #ifdef linux if necessary,
because it won't work anywhere else. I think you needed it
for struct stat, among other things. You use umode_t as a 
type for a member in that structure. Use mode_t and #ifdef linux
if necessary.

You use NAME_MAX, which is a no-no. See /usr/include/limits.h on
Solaris for a reason. There's a big comment in there about it.
Use MAXNAMLEN (not MAXNAMeLEN). That should work everywhere.

Oh, there is one function (I don't remember which) that is declared
as void foo(bar), but it returns result from other (also void) 
function. That return should be deleted. I don't know how and
why gcc didn't complain about that.

In ANSI C, non-constant initialization is not allowed. That's
gcc extension and it's very nice to have it, but it won't
compile with any other compiler. For example, you can't do this:

int foo(void)
{

   char *bar[] = {var1, var2};

   ...
}

You have to write it like this:

int foo(void)
{
   char bar[2];
   ...
   bar[0] = var1;
   bar[1] = var2;
   ...
}

There was one function that had a function call (strlen) in initialization.
#include <alloca.h> and use alloca() for that. Search for alloca in diff
and you'll see what I mean.

You have a lot of problems with types. gcc -Wall doesn't complain
about that, but there should be some other option, like -strict or -pedantic.
Things like passing unsigned char * to a function whose argument
was declared as char *. That should yield warning in the best case.
Of course, you have more complex types in your source.
You could search for "(*)" in diff to find the best of. :-)
The star is not a regexp magic char here, so you should search for
\(\*\).

That covers everything, I think.

-- 
 .-.   .-.    Life is a sexually transmitted disease.
(_  \ /  _)
     |        dave@fly.cc.fer.hr
     |
