From owner-svn-src-projects@FreeBSD.ORG Tue Mar 5 09:43:44 2013 Return-Path: Delivered-To: svn-src-projects@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id A1E1B387; Tue, 5 Mar 2013 09:43:44 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail02.syd.optusnet.com.au (mail02.syd.optusnet.com.au [211.29.132.183]) by mx1.freebsd.org (Postfix) with ESMTP id 3CF3AE60; Tue, 5 Mar 2013 09:43:43 +0000 (UTC) Received: from c211-30-173-106.carlnfd1.nsw.optusnet.com.au (c211-30-173-106.carlnfd1.nsw.optusnet.com.au [211.30.173.106]) by mail02.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id r259hXaC006397 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 5 Mar 2013 20:43:35 +1100 Date: Tue, 5 Mar 2013 20:43:33 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: John Baldwin Subject: Re: svn commit: r247710 - projects/calloutng/sys/kern In-Reply-To: <201303041620.52100.jhb@freebsd.org> Message-ID: <20130305201211.M902@besplex.bde.org> References: <201303031339.r23DdsBU047737@svn.freebsd.org> <201303041521.06557.jhb@freebsd.org> <201303041620.52100.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.0 cv=DdhPMYRW c=1 sm=1 a=gRR7UNw4rV0A:10 a=kj9zAlcOel0A:10 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=Y4pc3zAY36oA:10 a=6I5d2MoRAAAA:8 a=8NX_ljeKmFfN72uQc9IA:9 a=CjuIK1q_8ugA:10 a=SV7veod9ZcQA:10 a=TEtd8y5WR3g2ypngnwZWYw==:117 Cc: attilio@FreeBSD.org, Davide Italiano , src-committers@FreeBSD.org, svn-src-projects@FreeBSD.org X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Mar 2013 09:43:44 -0000 On Mon, 4 Mar 2013, John Baldwin wrote: > On Monday, March 04, 2013 3:41:05 pm Attilio Rao wrote: >> On Mon, Mar 4, 2013 at 9:21 PM, John Baldwin wrote: >>> On Monday, March 04, 2013 3:17:30 pm Davide Italiano wrote: >>>> On Mon, Mar 4, 2013 at 4:40 PM, John Baldwin wrote: >>>>> On Sunday, March 03, 2013 8:39:54 am Davide Italiano wrote: >>>>>> Author: davide >>>>>> Date: Sun Mar 3 13:39:54 2013 >>>>>> New Revision: 247710 >>>>>> URL: http://svnweb.freebsd.org/changeset/base/247710 >>>>>> >>>>>> Log: >>>>>> - Use TRUE/FALSE in lieu of 0/1 for boolean_t variables. Style bug. >>>>> We have stdbool in the kernel. Why not use that instead of the Machish >>>>> boolean_t? Neither is BSDish. I like(d) bool_t and TRUE/FALSE, and in 1993 when I didn't know BSD style very well, I made the mistake of exposing the Machish boolean_t and TRUE/FALSE outside of vm. It is now used a bit. >>>> move to 'boolean_t'. >>>> Honestly, I didn't argue due to the relative little relevance of the >>>> change, but actually I find the type change more explicative. >>>> I have no strong objections to change it again (in particular because >>>> I think you're suggesting to use bool to be C99 compliant, feel free >>>> to correct me if I'm wrong). >>>> >>>> While here. After closer looking I realized boolean_t is widely used >>>> in the kernel (e.g. sys/kern/). Is this just a common error or is >>>> there something I'm missing? Not very widely used, especially in kern. There are only 17 boolean_t's in all of kern. There are 33 TRUE's and 24 FALSE's in kern. This is approxiately none. Since I like(d) bool_t, I used it in sio and there are 15 uses of it there now (10 TRUE's and 8 FALSE's). This uses my old spelling from pre-C90 and pre-BSD, with a private typedef so that it is portable. The uart driver has different style bugs but not the one of using bools. It has no instances of boolean_t under any spelling, 5 of TRUE and 3 of FALSE> This shows that it is an uncommon error to use boolean_t outside of vm. >>> No, it's just older and bool is C99 as you noticed. I had thought that >>> boolean_t was largely regulated to code from Mach (i.e. sys/vm) and that >>> we should use bool for new code. That would be a large change. BSD style doesn't even use the ! operator, buit uses comparison with 0. >> Actually boolean_t is much more widespread in our kernel than the C99 >> variant. Moreover style(9) doesn't advertise it either, neither the Since boolean_t escaped earlier, and C99 extensions are rarely used. >> necessity to conform to library defined C99 features (even if present >> in the C99 standard, _Bool is still defined in stdbool.h which is an >> header not present in our kernel). > > Err, I thought that mdf@ had proposed importing stdbool.h into our kernel > already? Ah, yes, the requisite bits are in , so 'bool' works > fine. Like boolean_t. I made the mistake of putting it in sys/types.h instead of in its own header so that it could be easily used. In 4.4BSD-Lite2, it is still only in the Machish header vm/vm_param.h. NetBSD moved it to sys/types.h in 2003. > I think for new code we should prefer C99's bool to boolean_t. Why? There is no existing practice for this in the kernel. There is some in the Linux kernel :-). Bruce