svn commit: r221645 - head/sys/geom/part

Bruce Evans brde at optusnet.com.au
Sun May 8 13:21:49 UTC 2011


On Sun, 8 May 2011, Kostik Belousov wrote:

> On Sun, May 08, 2011 at 11:20:27AM +0000, Andrey V. Elsukov wrote:
>> Log:
>>   Limit number of sectors that can be addressed.
>>
>>   MFC after:	1 week
>>
>> Modified:
>>   head/sys/geom/part/g_part_pc98.c
>>
>> Modified: head/sys/geom/part/g_part_pc98.c
>> ==============================================================================
>> --- head/sys/geom/part/g_part_pc98.c	Sun May  8 11:16:17 2011	(r221644)
>> +++ head/sys/geom/part/g_part_pc98.c	Sun May  8 11:20:27 2011	(r221645)
>> @@ -261,7 +261,7 @@ g_part_pc98_create(struct g_part_table *
>>
>>  	cyl = basetable->gpt_heads * basetable->gpt_sectors;
>>
>> -	msize = MIN(pp->mediasize / SECSIZE, 0xffffffff);
>> +	msize = MIN(pp->mediasize / SECSIZE, UINT_MAX);
> Shouldn't this be UINT32_MAX (consistently) ?

It was that before.  This was correct, since msize has type uint32_t.
Hard-coding the 0xffffffff for the limit is no different than hard-coding
32 for the type name or limit.

Use of MIN() in the kernel is a style bug.  MIN() in the kernel was
removed in 4.4BSD, but came back to support contrib'ed code and is now
used in non-contribed- code :-(.  Here min() could be used, but is
fragile.  There is no min32() or what there should be -- a type-generic
safe macro min().  Use of the unsafe macro MIN() gives different
fragility than use of the non-type-generic but safe (non-macro) min().
This style bug is not present in the top-level geom directory, but is
common in subdirectories (66 instances).

Bruce


More information about the svn-src-all mailing list