title: Declare variable as locally as possible
body: <p>I'm new to Linux kernel development.</p>
  
  <p>One thing that bothers me is a way a variables are declared and initialized.</p>
  
  <p>I'm under impression that code uses variable declaration placement rules for C89/ANSI C (variables are declared at the beginning of block), while  C99 relaxes the rule.</p>
  
  <p>My background is C++ and there many advises from "very clever people" to declare variable as locally as possible - better declare and initialize in the same instruction:</p>
  
  <ul>
  <li><a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Local_Variables#Local_Variables" rel="noreferrer">Google C++ Style Guide</a></li>
  <li><a href="https://rads.stackoverflow.com/amzn/click/com/0321113586" rel="noreferrer" rel="nofollow noreferrer">C++ Coding Standards: 101 Rules, Guidelines, and Best Practices</a> - item 18</li>
  <li>A good discussion about it <a href="https://rads.stackoverflow.com/amzn/click/com/0321113586" rel="noreferrer" rel="nofollow noreferrer">here</a>.</li>
  </ul>
  
  <p>What is the accepted way to initialize variables in Linux kernel?</p>