cvs commit: src/sys/dev/ata ata-all.c

Scott Long scottl at samsco.org
Mon Apr 21 22:38:35 UTC 2008


John-Mark Gurney wrote:
> Bjoern A. Zeeb wrote this message on Sun, Apr 20, 2008 at 17:45 +0000:
>> bz          2008-04-20 17:45:32 UTC
>>
>>   FreeBSD src repository
>>
>>   Modified files:
>>     sys/dev/ata          ata-all.c 
>>   Log:
>>   devclass_get_maxunit() returns n+1 with n starting at 0.
>>   So if we have channel 0..3  devclass_get_maxunit is 4.
>>   
>>   It's never been a problem as devclass_get_device() has
>>   catched a possibly bad input.
> 
> Any one object to changing:
> .Nm devclass_get_maxunit
> .Nd find the maximum unit number in the class
> 
> to:
> .Nm devclass_get_maxunit
> .Nd find the next free unit number in the class
> 

That's not what it actually returns though.  It returned the highest
allocated unit number plus 1.  The unit numbering can be sparse, with
the next available unit number being less than the highest allocated
unit number.

Most callers use this value as the limit in a for loop, hence why it's
convenient for it to return the +1.

Scott


More information about the cvs-src mailing list