Subject: Re: Bluetooth protocol code
To: None <tech-kern@netbsd.org>
From: Valeriy E. Ushakov <uwe@ptc.spbu.ru>
List: tech-kern
Date: 12/20/2005 10:00:13
On Tue, Dec 20, 2005 at 09:38:58 +0300, Valeriy E. Ushakov wrote:
> The issue can arise with short integral types that are passed "as-is"
> for ANSI, and that are subject to widening conversion for K&R. To hit
> this bug, you also need to be on a platform, that passes e.g. shorts
> and ints diffrently, i.e. it should pass them via stack, and should
> not perform the widening *always* (as e.g. i386 does).
Actually, since we mandate prototypes, this should not happen either.
The issue would arise if the k&r definition was compiled w/out the
ANSI prototype, so the the function body would assume widening, and
callers (that only saw ANSI prototype) would assume no widening.
Anyway, by always using ANSI style you can just totally ignore all
those issues form 10+ years ago. ;)
On the readability side however, I encoutered few issues in our kernel
code like e.g:
int
foo(bar, dfg, fwd, ffg, nitems, nsize, alignment)
int bar;
int dfg;
int ffg;
int nsize;
int nitems;
int alignment;
{
...
}
Substitute longer variable and type names to make the problem even
less obvious.
SY, Uwe
--
uwe@ptc.spbu.ru | Zu Grunde kommen
http://snark.ptc.spbu.ru/~uwe/ | Ist zu Grunde gehen