title: C - best practice for casting a void* to int, kernel
body: <p>I'm writing a module for Linux kernel, and I want to store a <code>int</code> value in the file private data.</p>
  
  <p>Essentially, what I do is: <code>file-&gt;private_data = (void*) x</code>
  where x is some <code>int</code> value.</p>
  
  <p>Now, I want to access the int back as a value.</p>
  
  <p>Using <code>int val = (int) file-&gt;private_data</code> gives out a <code>cast from pointer to integer of different size</code> warning during compilation, which is reasonable since it may cause problems on a 64bit systems.</p>
  
  <p>I also cannot use <code>uintptr_t</code> since I'm working in kernel and I do not have access to libraries.</p>
  
  <p>Using <code>double</code> seems inappropriate.</p>
  
  <p>My question is: What should be the best practice to do so? </p>