From: Ian Jackson Subject: RE: [PATCH] cpufreq.c: shut up compiler about cpufreq_dom Date: Thu, 30 Oct 2008 09:34:43 +0000 Message-ID: <18697.32691.152385.432371@mariner.uk.xensource.com> References: <18696.37682.162183.607991@mariner.uk.xensource.com> <706158FABBBA044BAD4FE898A02E4BC2140C865C@pdsmsx503.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <706158FABBBA044BAD4FE898A02E4BC2140C865C@pdsmsx503.ccr.corp.intel.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: "Liu, Jinsong" Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org Liu, Jinsong writes ("RE: [Xen-devel] [PATCH] cpufreq.c: shut up > What's the advantage of the above coding style? seems it saved a > flag but add 1 more jump. It's clearer, and the compiler can see what's going on. There isn't another jump `as written', since `break' is a jump too. Whether there is another jump after the compiler is done with it depends on a lot of factors, but generally I would expect the compiler to do a better job when information about the program's possible behaviours is represented directly in the control flow than when it is stored in a flag variable. For example, often the allocation of a new structure can be done directly at the point where we fall out of the loop, eg: > > for (...) { cpufreq_dom = dom; if (...) goto cpufreq_dom_found; } cpufreq_dom = xmalloc(...); cpufreq_dom->contents = value; ... > > cpufreq_dom_found: Ian.