...
This compliant solution uses the POSIX strerror_r()
function, which has the same functionality as strerror()
but guarantees thread safety.:
Code Block | ||||
---|---|---|---|---|
| ||||
errno = 0; FILE* fd = fopen( filename, "r"); if (fd == NULL) { char errmsg[BUFSIZ]; if (strerror_r(errno, errmsg, BUFSIZ) != 0) { /* handle error */ } printf("Could not open file because of %s\n", errmsg); } |
...
Tool | Version | Checker | Description |
---|---|---|---|
Compass/ROSE |
|
| A module written in Compass/ROSE can detect violations of this rule. |
Related Guidelines
CERT C++ Secure Coding Standard | CON03-CPP. Avoid assuming functions are thread safe unless otherwise specified |
...