Linux macro _ user

Source: Internet
Author: User
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;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.