Subject: Re: caddr_t removal Q
To: None <tech-kern@netbsd.org>
From: Allen Briggs <briggs@netbsd.org>
List: tech-kern
Date: 03/13/2007 14:26:26
On Tue, Mar 13, 2007 at 06:05:45PM +0000, Christos Zoulas wrote:
> >What's wrong with having a generic pointer type that it's safe to do
> >byte-wise arithmetic on (which is what I've considered caddr_t to be)?
> 
> That is the problem "char *" (caddr_t) is not a generic pointer. The API's
> that wanted generic pointers should have had "void *" not "caddr_t".

I see.  "char *" is not a generic pointer, but it's indistinguishable
from a generic pointer in the cases that I've used caddr_t.  And better
for those uses than void * since you left out the "that it's safe to do
byte-wise arithmetic on" qualifier from my question...

> "caddr_t" predates "void" in `c', so back then it was used as a generic
> pointer for the lack of something better. Now we have something better
> and we should be using it.

It does look like caddr_t was used in a variety of ways.  It still seems
that it would make sense to have a standard type for a pointer that you
can do byte-wise arithmetic with.  This might prevent people from casting
pointers to integers or accidentally using pointers to the wrong type or
(in the best case?) just using a mix of char * or u_int8_t * or int8_t *
or unsigned char * or uchar *.

I appreciate your quick answer.

-allen

-- 
Allen Briggs  |  http://www.ninthwonder.com/~briggs/  |  briggs@ninthwonder.com