Subject: Re: getdirentries(2): argument doesn't match
To: None <itojun@iijlab.net>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 10/03/2002 10:09:15
On Thu, 3 Oct 2002 itojun@iijlab.net wrote:

> >>	it seems that signedness of getdirentries(2) does not meet up with
> >>	document.  does it make sense?  found by checking openbsd commit log.
> >istm that by using a u_int instead of an int (they are both always the
> >same size, right?) you can eliminate the two tests you have to add if
> >you make it an int.
> >less code to debug, audit, etc...
>
> 	in some portion system call argument type matches documentation (int),
> 	and checks are made using typecast to u_int (by typecasting negative
> 	number check is omitted).
>
> 	in some portion system call argument type differs from documentation
> 	(u_int), and checks are omitted for negative numbers.
>
> 	in some portion system call argument type matches documentation,
> 	and explicit checks are made - if (x < 0 || x >= MAX) return EINVAL;

I vote for choice 1. Let's have the syscall match the documents (and
userland prototype) but use the (uint) trick to nake it one check.

Take care,

Bill