From owner-freebsd-hackers@FreeBSD.ORG Fri May 1 12:10:21 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 04C94106564A; Fri, 1 May 2009 12:10:21 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 4B2D68FC20; Fri, 1 May 2009 12:10:19 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.3/8.14.3/ALCHEMY.FRANKEN.DE) with ESMTP id n41CAIFT023708; Fri, 1 May 2009 14:10:18 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.3/8.14.3/Submit) id n41CAIu4023707; Fri, 1 May 2009 14:10:18 +0200 (CEST) (envelope-from marius) Date: Fri, 1 May 2009 14:10:18 +0200 From: Marius Strobl To: Christoph Mallon Message-ID: <20090501121018.GC2943@alchemy.franken.de> References: <49F4070C.2000108@gmx.de> <20090501112239.GA23199@alchemy.franken.de> <49FADEF3.5010106@gmx.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <49FADEF3.5010106@gmx.de> User-Agent: Mutt/1.4.2.3i Cc: FreeBSD Hackers , Roman Divacky , Ed Schouten , Warner Losh , Maxim Sobolev Subject: Re: C99: Suggestions for style(9) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 May 2009 12:10:21 -0000 On Fri, May 01, 2009 at 01:37:23PM +0200, Christoph Mallon wrote: > Marius Strobl schrieb: > >On Sun, Apr 26, 2009 at 09:02:36AM +0200, Christoph Mallon wrote: > >>return with parentheses: > >>Removed, because it does not improve maintainability in any way. There > >>is no source for confusion here, so the rule even contradicts the rule, > >>which states not to use redundant parentheses. Maybe, decades ago it was > >>just a workaround for a broken compiler, which does not exist anymore. > > > >FYI, the idea behind this rule is said to be to able to use > >a macro return(), f.e. for debugging you then can do: > >#define return(x) do { \ > > printf("returning from %s with %d\n", __func__, (x)); \ > > return (x); \ > >} while (0) > > > >Given the this is a nifty feature and parentheses around the > >return value don't hurt maintainability in any way IMO this > >rule should stay. > > This is mentioned nowhere in style(9) (in general it is lacking reasons > why something is some way or the other). I agree that style(9) lacks explanations, however this doesn't necessarily mean that non-obvious rules are "silly" and should be removed. > Also I consider this as gross abuse: Macro names shall be in all > uppercase, so it is clear that there is a macro at work. Therefore > "return" is not a candidate. So this would violate yet another rule in > style(9) (the original return already violates the no-redundant > parentheses rule). > Also I would not mention __func__: there were objections against using > it in the past (though I, logically, prefer its use). In general this is correct, a return() macro (in which case the parentheses are not redundant) would be for local debugging only and not ever hit the tree just like any other printf()- debugging should not, so neither is relevant here. Besides, a macro without side effects, which a return() macro typically shouldn't have, is fine to be named all lowercase according to style(9). Marius