What is -EPERM in C?

3

What is the -EPERM , after which compares if the p pointer is null

 if(p == NULL) return -EPERM ;

And I have to put these two libraries.

#include <errno.h>
#include <stddef.h>
    
asked by anonymous 23.04.2016 / 17:28

1 answer

3

Documentation of this default error library .

There it says that this code represents an operation error not allowed, perhaps for lack of privileges to execute.

In the specific case, the null occurs when there is something wrong that happened when you attempted to perform an operation, or else the code was used to indicate that the use of null is wrong there, which I think would be a wrong use of it, since these codes are for IO operations.

Obviously you have to add the library where it contains your definition. There are the names of the errors which is a bit better than using a meaningless number.

You may be wondering why you need to use the negative. The code is positive, but in many cases a positive number may indicate that it worked and the negatives indicate error. Several codes rely on the signal to determine if the action failed.

Otherwise it would need more code context to explain.

Further reading .

    
23.04.2016 / 17:36