From: Ian Jackson Subject: Re: [PATCH RFC v2 06/13] libxl: permit declaration after statement Date: Tue, 29 Nov 2011 14:04:35 +0000 Message-ID: <20180.58995.480262.215965@mariner.uk.xensource.com> References: <1319827031-15395-1-git-send-email-ian.jackson@eu.citrix.com> <1319827031-15395-2-git-send-email-ian.jackson@eu.citrix.com> <1319827031-15395-3-git-send-email-ian.jackson@eu.citrix.com> <1319827031-15395-4-git-send-email-ian.jackson@eu.citrix.com> <1319827031-15395-5-git-send-email-ian.jackson@eu.citrix.com> <1319827031-15395-6-git-send-email-ian.jackson@eu.citrix.com> <1319827031-15395-7-git-send-email-ian.jackson@eu.citrix.com> <1320054652.23193.28.camel@zakaz.uk.xensource.com> <20145.29085.278257.629473@mariner.uk.xensource.com> <1320263024.3084.61.camel@cthulhu.hellion.org.uk> <20179.47462.815671.301622@mariner.uk.xensource.com> <1322563538.20646.36.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1322563538.20646.36.camel@zakaz.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Campbell Cc: "xen-devel@lists.xensource.com" , Ian Jackson , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org Ian Campbell writes ("Re: [Xen-devel] [PATCH RFC v2 06/13] libxl: permit declaration after statement"): > Variable declarations should either be at the top of the function or > immediately before / as part of the block which uses them. e.g. this is > unhelpful: I agree.. > void a_func(void) > { > /* a bunch of code; */ > > int bar; > > /* a bunch more code not using bar */ > > bar = get_me_a_bar(); > > /* use bar lots */ > } Yes, but would anyone really write that ? I think the argument is about this: /* a bunch of code; */ int bar = get_me_a_bar(); /* use bar lots */ I think this is fine and I think Stefano objects. How about: Declarations of automatic variables should either be at the start of the relevant function (or block), or as late as reasonable; in the latter case they should be initialised in the declaration if possible. Ian.