Coda File System

Re: CODA 5.3.20 compilation under FreeBSD 5 (stat structure problem)

From: Jan Harkes <jaharkes_at_cs.cmu.edu>
Date: Wed, 5 Mar 2003 11:41:40 -0500
On Tue, Mar 04, 2003 at 11:18:30PM -0800, Tak Pui LOU wrote:
> Hi Jan,
> 
> > Couldn't find it in my local development tree, so I checked the CVS
> > logs. It is an unused function that can be removed completely.
> 
> Thanks for your reply. How about the following in coda-src/vice/srv.cc
> (line 1271)?
> 
>     count = scandir(".", &namelist, (int (*)(const dirent *)) xselect,
>                     (int (*)(const void *, const void *)) compar);

I hate casts, I wonder who came up with the bright idea to add all those
casts here, because they are only going to hide bugs when someone
accidently changes xselect or compar.

Ahh, I see

> And the manpage of scandir says:
> 
>      int
>      scandir(const char *dirname, struct dirent ***namelist,
>              int (*select)(struct dirent *),
>              int (*compar)(const void *, const void *));

I guess it's not a SuS or POSIX standard function, and various platforms
use different prototypes. My prototype looks like,

    int scandir(const char *dir, struct dirent ***namelist,
		int(*select)(const struct dirent *),
		int(*compar)(const struct dirent **, const struct dirent **));

> Can I take away the "const" here?

Yeah, sure. I'll try to come up with a more permanent solution.

Jan
Received on 2003-03-05 11:45:48