Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 May 2011 23:21:45 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        svn-src-head@FreeBSD.org, "Andrey V. Elsukov" <ae@FreeBSD.org>, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org
Subject:   Re: svn commit: r221645 - head/sys/geom/part
Message-ID:  <20110508230559.Y1726@besplex.bde.org>
In-Reply-To: <20110508113451.GY48734@deviant.kiev.zoral.com.ua>
References:  <201105081120.p48BKRB7043544@svn.freebsd.org> <20110508113451.GY48734@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110508230559.Y1726>