Subject: Re: Bluetooth protocol code
To: Iain Hibbert <plunky@rya-online.net>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 12/19/2005 11:52:22
--envbJBWh7q8WU6mo
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Dec 12, 2005 at 10:22:26PM +0000, Iain Hibbert wrote:
> On Mon, 12 Dec 2005, Rui Paulo wrote:
>=20
> > On 2005.12.08 00:55:26 +0000, Iain Hibbert wrote:
> > |
> > | so, like I say - any comments welcomed..  this is not the end, or eve=
n the
> > | beginning of the end but its getting near the end of the beginning..
> >
> > Style:
>=20
> > 1) please use ANSI function declarations;
>=20
> on all functions? (grumble grumble..)

I realize you got a lot of response to this and that I'm a bit late. But=20
yes, this point is important.

The problem is that K&R prototypes won't work right if we pass in a=20
parameter that's larger than an int. Like a long or a pointer on an LP64=20
system.

In such a case, the caller will turn the parameter into an int, truncating=
=20
it. Worse yet, the caller will then pack other parameters in, not leaving=
=20
enough space for what the caller will expect the parameter to be. Thus the=
=20
callee will see two parameters mixed together in what it thinks is one=20
parameter (by our style guide, it will get the parameters right), and a=20
parameter at the end will be totally uninitialized.

This behavior is why we're moving away from K&R parameters & prototypes.

Take care,

Bill

--envbJBWh7q8WU6mo
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFDpw92Wz+3JHUci9cRAsR1AJ9+GtnSBeh6QUG5Oycv+90IzzsJHACdENtw
4RkL+Dq/iWQdMNqTsk//tfc=
=wBaL
-----END PGP SIGNATURE-----

--envbJBWh7q8WU6mo--