On 01/30/09 08:18, Kacheong Poon wrote:
> Michael Schuster wrote:
> 
>> I guess it would, but that's not what I expected after that email 
>> exchange I mentioned.
>> Conversely, is "port == 0 means 'all ports'" hard to implement?
> 
> 
> It is just code after all.  So the sanity check becomes
> more involved...
> 
>       if ((min_port == 0 && max_port != 0) ||

I'd say if min_port == 0, max_port can be ignored, so you can eliminate 
this clause.

>           (min_port != 0 && max_port == 0) ||

since ports are an unsigned integer, the above is covered by (min_port > 
max_port), isn't it?

>           (min_port > max_port) {

so just test whether min_port > max_port.
        
>               return (EINVAL);
>       }
>       if (min_port == 0) {
>               min_port = 1;
>               max_port = 65535;
>       }
> 
> If you think that the above is easier to read than the
> current simple check, feel free to change the code.

OK. will do.

Michael
-- 
Michael Schuster        http://blogs.sun.com/recursion
Recursion, n.: see 'Recursion'

Reply via email to