title: Are do-while-false loops common?
body: <p>A while back I switched the way I handled c style errors.</p>
  
  <p>I found a lot of my code looked like this:</p>
  
  <pre><code>int errorCode = 0;
  
  errorCode = doSomething();
  if (errorCode == 0)
  {
     errorCode = doSomethingElse();
  }
  
  ...
  
  if (errorCode == 0)
  {
     errorCode = doSomethingElseNew();
  }
  </code></pre>
  
  <p>But recently I've been writing it like this:</p>
  
  <pre><code>int errorCode = 0;
  
  do
  {       
     if (doSomething() != 0) break;
     if (doSomethingElse() != 0) break;
     ...
     if (doSomethingElseNew() != 0) break;
   } while(false);
  </code></pre>
  
  <p>I've seen a lot of code where nothing gets executed after there's an error, but it has always been written in the first style. Is there anyone else who uses this style, and if you don't, why?</p>
  
  <p><strong>Edit:</strong> just to clarify, usually this construct uses <code>errno</code> otherwise I will assign the value to an <code>int</code> before breaking. Also there's usually more code than just a single function call within the <code>if (error == 0 )</code> clauses. Lots of good points to think on, though.</p>