tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: proposal: some pointer and arithmetic utilities

> I have something like this in mind (but with some better actual proof):

> typedef void (*work_done)(struct work *wk, void *dummy);

> static void
> physio_done(struct work *wk, struct buf *bp)
> {
>       ...
> }

If the pointer has a void * second argument, please give the actual
function a void * second argument!  Concealed type puns like this are
just _asking_ for trouble; void (*)(struct work *, void *) and
void (*)(struct work *, struct buf *) are not compatible types, so that
code is off in nasal demon territory - and on a word-addressed machine
(like the PDP-10 - or many DSP implementations, not that NetBSD is
likely to care about them) it is almost certain to explode.

Furthermore, the compiler is not capable of typechecking that the value
is actually a struct buf *, when using such an interface; making that
fact obvious to anyone reading the code, rather than hidden unless you
carefully compare prototypes, is a good thing.

Not, of course, that it's the only such offender.  Consider enodev()
and its relatives (unless of course that botch has been eliminated in
modern versions, though this suggestion makes me suspect not).

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML      
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

Home | Main Index | Thread Index | Old Index