...
Code Block | ||
---|---|---|
| ||
const errno_t ESOMETHINGREALLYBAD = 1; void g(errno_t* err) { if (err == NULL) { /* handle nullNULL pointer */ } /* ... */ if (something_really_bad_happens) { *err = ESOMETHINGREALLYBAD; } else { /* ... */ *err = 0; } } void f(errno_t* err) { if (err == NULL) { /* handle nullNULL pointer */ } g(err); if (*err == 0) { /* ... do the rest of f ... */ } return 0; } |
...
- A return status can only be returned if the caller provides a valid pointer to an object of type
errno_t
. If this argument is nullNULL, there is no way to indicate this error. - Source code becomes even larger, due to the possibilities of receiving a null NULL pointer.
- All error indicators must be checked after calling functions.
- Any function that allocates resources must ensure they are freed incases where errors occur.
- Unlike return values, static analysis tools generally do not diagnose a failure to check error indicators passed as argument pointers.
...