IS_ERR() macro in Linux
Be careful for pitfall:
#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
#define MAX_ERRNO 4095
This covers -1 to -4095, which represents error code, not number below 4096, nor NULL (0). Every value from 0 to 4294963201 (0xfffff001) is considered no error. Do not use it to cover NULL checking.
If you want to know what the macro expands to, just compile your file using the -E
option of gcc, which will only do pre-processing. It will include all headers and expand all macros.
The macro does not "get executed" per se, it's just a "search and replace" type of thing.
Tests if the supplied pointer should be considered an error value.
It does not check if the pointer is valid.
In your code IS_ERR is used to check if class_create
succeded creating ebbcharClass
. If an error occurs unregister the char driver and signal the error.
You can find MACROs and inline funcs in err.h