Subject: Re: CVS commit: syssrc/sys/kern
To: None <itojun@iijlab.net>
From: Matt Thomas <matt@3am-software.com>
List: source-changes
Date: 10/02/2002 22:14:37
At 10:06 PM 10/2/2002, itojun@iijlab.net wrote:
> >> Modified Files:
> >>         syssrc/sys/kern: kern_resource.c
> >>
> >> Log Message:
> >> check negative arg.  from openbsd
> >Due to the `(u_int)' cast -- which I added just about 5 years ago --
> >this code already handled negative arguments correctly.  Your change
> >is a noop.
>
>         ok, but isn't it better to explicitly check
>                 if (which < 0 || which >= MAX)
>                         return EINVAL
>         than
>                 if ((u_int)which >= MAX)
>                         return EINVAL
>         from readability/clarity?

No.  It's slower and not if you don't know about signedness/unsigness
of number, you shouldn't be doing kernel programming.


-- 
Matt Thomas               Internet:   matt@3am-software.com
3am Software Foundry      WWW URL:    http://www.3am-software.com/bio/matt/
Cupertino, CA             Disclaimer: I avow all knowledge of this message