errno_t returns

I was browsing the CERT Secure Coding Standards webpage today and i noticed it made reference to errno.h, which is included in the standard library. It defines macros used for reporting error codes. Anyways, i have never used this in my functions before. i'll return an integer and declare it as doing that:

int someFunc (...) {

if (errorTest)
return 1 ; // return 1 on error

return 0 ;
}

but making use of errno.h, the intention of that return becomes self-documenting:

#include < errno.h >
...
errno_t someFunc(...) {

if (errorTest)
return errno ;

return 0 ;
}

Comments

Popular Posts