public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* question on common error-handling idiom
@ 2004-11-02 20:08 Chris Friesen
  2004-11-02 20:58 ` Jan Engelhardt
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Chris Friesen @ 2004-11-02 20:08 UTC (permalink / raw)
  To: Linux kernel


There's something I've been wondering about for a while.  There is a lot of code 
in linux that looks something like this:


err = -ERRORCODE
if (error condition)
	goto out;


While nice to read, it would seem that it might be more efficient to do the 
following:

if (error condition) {
	err = -ERRORCODE;
	goto out;
}


Is there any particular reason why the former is preferred?  Is the compiler 
smart enough to optimize away the additional write in the non-error path?

Chris

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2004-11-04 19:58 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-02 20:08 question on common error-handling idiom Chris Friesen
2004-11-02 20:58 ` Jan Engelhardt
2004-11-02 21:12   ` linux-os
2004-11-03 10:45     ` Ross Kendall Axe
2004-11-02 21:12   ` Russell Miller
2004-11-02 21:16 ` Jesper Juhl
2004-11-02 21:21   ` Oliver Neukum
2004-11-02 21:29   ` Jan Engelhardt
2004-11-02 21:48     ` Jesper Juhl
2004-11-03 16:49       ` Chris Friesen
2004-11-03  8:11 ` GNicz
2004-11-04 19:52 ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox