From owner-svn-src-head@FreeBSD.ORG Sun May 8 13:21:49 2011 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 32ED7106564A; Sun, 8 May 2011 13:21:49 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail01.syd.optusnet.com.au (mail01.syd.optusnet.com.au [211.29.132.182]) by mx1.freebsd.org (Postfix) with ESMTP id C57E58FC16; Sun, 8 May 2011 13:21:48 +0000 (UTC) Received: from c122-106-155-58.carlnfd1.nsw.optusnet.com.au (c122-106-155-58.carlnfd1.nsw.optusnet.com.au [122.106.155.58]) by mail01.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p48DLjYm004537 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 8 May 2011 23:21:46 +1000 Date: Sun, 8 May 2011 23:21:45 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Kostik Belousov In-Reply-To: <20110508113451.GY48734@deviant.kiev.zoral.com.ua> Message-ID: <20110508230559.Y1726@besplex.bde.org> References: <201105081120.p48BKRB7043544@svn.freebsd.org> <20110508113451.GY48734@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, "Andrey V. Elsukov" , svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r221645 - head/sys/geom/part X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 May 2011 13:21:49 -0000 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