From owner-freebsd-hackers Mon Oct 16 20:17:30 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id UAA06741 for hackers-outgoing; Mon, 16 Oct 1995 20:17:30 -0700 Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id UAA06715 ; Mon, 16 Oct 1995 20:17:22 -0700 Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.9/8.6.9) id NAA21632; Tue, 17 Oct 1995 13:12:33 +1000 Date: Tue, 17 Oct 1995 13:12:33 +1000 From: Bruce Evans Message-Id: <199510170312.NAA21632@godzilla.zeta.org.au> To: matt@lkg.dec.com, terry@lambert.org Subject: Re: suggested changes to mbuf routines Cc: hackers@freefall.freebsd.org, julian@freefall.freebsd.org Sender: owner-hackers@FreeBSD.org Precedence: bulk >> #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