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