First, let's take a look at the macro definition of _ user: ifdef _ CHECKER _ define _ user _ att
First, let's take a look at the macro definition of _ user:
# Ifdef _ CHECKER __ # Define _ user _ attribute _ (noderef, address_space (1 ))) |
We can see from the macro definition that the _ CHECKER _ macro configuration __user macro definition is valid, but obviously we can see that macro _ CHECKER _ is used as the check mechanism, therefore, we can infer that macro _ user should be used to check for incorrect use.
In fact, this is also true. it is used to compile the kernel/module and use the make C = 1 option to open the static syntax check tool sparse to detect possible errors. At the same time, it can be seen that it has no effect on file generation, but it is only used to check the correctness of the syntax.
Further research shows that sparse is a static C syntax check tool. when compiling the kernel or compiling the module in Linux, C = 1 can be appended to call sparse to check the code.
In addition, sparse defines several memory spaces. sparse defines several address spaces for the Linux kernel. the kernel space is default, the user space is 1, and the io interval is 2. in this way, you can check whether there is a problem with the access address code. Specifically, address_space (1) indicates the user space.
For example, in driver writing, size_t hello_read (struct file * file, char _ user * buff, size_t count, loff_t * offp)
{
Return 0;
}