Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Oct 1995 13:12:33 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        matt@lkg.dec.com, terry@lambert.org
Cc:        hackers@freefall.freebsd.org, julian@freefall.freebsd.org
Subject:   Re: suggested changes to mbuf routines
Message-ID:  <199510170312.NAA21632@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>> #if     __STDC__
>>         void    (*ext_free)(caddr_t, u_long, caddr_t);
>> #else
>>         void    (*ext_free)();          /* free routine if not the usual */
>> #endif
>...
>>         void    (*ext_free)(caddr_t, u_long, caddr_t);

>Should be:

>>         void    (*ext_free) __P((caddr_t, u_long, caddr_t));

The __STDC__ test already does that, but I prefer __P(()) because it takes
1 line instead of 5 and the unportable conditional is easier to change.

The caddr_t's are bogus because free() takes a `void *' arg even in the
kernel.  The u_long is fairly bogus, but malloc() takes a u_long arg
instead of a size_t arg too.

We have been removing bogus casts to (caddr_t) for `void *' function args.
Perhaps that has gone a bit far.  There is no problem in ANSI C, but in
K&R C the following change is incorrect:

	void func __P((void *));
	int *foo;
from:
	func((caddr_t)foo);	/* works because addr_t has same
				 * representation as void *, but bogus */
to:
	func(foo);		/* works in ANSI C; fails in K&R C if
				 * void * has a different representation
				 * to int * */
"right":
	func((void *)foo);	/* "always" works; actually it only works
				 * if the K&R compiler is not krufty enough
				 * to be missing void *, and not braindamaged
				 * enough to use different representations
				 * for void * and caddr_t */

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199510170312.NAA21632>