What good is C-EPERM?

Asked

Viewed 84 times

4

What is the purpose of the -EPERM, after comparing the pointer p is null

 if(p == NULL) return -EPERM ;

And I have to put these two libraries.

#include <errno.h>
#include <stddef.h>

1 answer

4


Documentation of this standard error library.

It says that this code represents an operation error not allowed, perhaps due to lack of privileges to execute.

in the specific case, or null occurs when there is something wrong that happened when you tried to perform an operation, or the code was used to indicate that the null there is wrong, what 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 its definition. There are the names of the errors which is a little better than using a number without meaning.

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

Otherwise I would need more code context to explain.

Further reading.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.