Re: [IDEA+RFC] Possible solution for min()/max() war

Christopher Friesen (cfriesen@nortelnetworks.com)
Thu, 30 Aug 2001 12:41:07 -0400


Linus Torvalds wrote:

> For example, let's look at this perfectly natural code:
>
> static int unix_mkname(struct sockaddr_un * sunaddr, int len, unsigned *hashp)
> {
> if (len <= sizeof(short) || len > sizeof(*sunaddr))
> return -EINVAL;
> ...
>
> Would you agree that the above is _good_ code, and code that makes
> perfect sense, and code that does exactly the right thing in testing its
> arguments?

Wouldn't it have made more sense to make the 'len' parameter an unsigned int?
Presumably we can't have a negative length for a name. In this case the
warnings should just go away, no?

-- 
Chris Friesen                    | MailStop: 043/33/F10  
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: cfriesen@nortelnetworks.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/