First look at the macro definition of __user:
#ifdef __checker__# define __user __attribute__ (Noderef, Address_space (1))
As you can see from the macro definition, the __user macro definition is valid under the condition that you configure the __CHECKER__ macro, and it is obvious that the macro __checker__ appears as a checking mechanism, so we can infer that the macro __user should be used to check for error usage.
In fact, it is in order to compile the kernel/module with the Make C=1 option, open the static grammar checking tool sparse, to detect possible errors. You can also see that it has no effect on the generation of the file, just to check the syntax correctness.
Further research has found that sparse is a static C-grammar checker, Linux to compile the kernel or compile module, you can attach c=1 to invoke sparse check code.
In addition, sparse defines several memory spaces, sparse defines a few address spaces for the Linux kernel, kernel space is default, the user space is 1, and the IO interval is 2. This allows you to check if there is a problem with the code that accesses the address. including Address_space (1) refers to user space.
For example, in driver authoring, size_t hello_read (struct file *file, char __user *buff, size_t count, loff_t *OFFP)
{
return 0;
}
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/