title: Why do some kernel programmers use goto instead of simple while loops?
body: <p>When I learned C, teacher told me all day long: "Don't use goto, that's a bad habit, it's ugly, it's dangerous!" and so on.</p>
  
  <p>Why then, do some kernel programmers use <code>goto</code>, for example <a href="https://github.com/torvalds/linux/blob/391e43da797a96aeb65410281891f6d0b0e9611c/kernel/sched/clock.c#L141" rel="noreferrer">in this function</a>, where it could be replaced with a simple </p>
  
  <pre><code>while(condition) {} 
  </code></pre>
  
  <p>or </p>
  
  <pre><code>do {} while(condition);
  </code></pre>
  
  <p>I can't understand that. Is it better in some cases to use goto instead of <code>while</code>/<code>do</code>-<code>while</code>? And if so, why?</p>