Errno not reset
errno not reset before calling a function
that sets errno
Description
This defect occurs when
you do not reset errno before calling a function
that sets errno to indicate error conditions. However,
you check errno for those error conditions after
the function call.
Risk
An errno-setting function sets errno to nonzero values to indicate error conditions.
If you do not set errno to zero before calling an errno-setting function,a nonzero value of errno might be left over from a previous call to an errno-setting function. Using errno to check errors can then lead you to falsely conclude that an error occurred from the most recent call.
errno is set to 0 at program startup but is not automatically reset after an error occurs. You must explicitly set errno to 0 when required.
Fix
Before calling a function that sets errno to
indicate error conditions, reset errno to zero
explicitly.
Examples
Result Information
| Group: Programming |
| Language: C | C++ |
| Default: On for handwritten code, off for generated code |
Command-Line Syntax:
MISSING_ERRNO_RESET
|
| Impact: High |
PQL Name:
std.defects.MISSING_ERRNO_RESET
|
Version History
Introduced in R2017aSee Also
Find
defects (-checkers) | Returned
value of a sensitive function not checked | Misuse of
errno | Errno not
checked
Topics
- Interpret Polyspace Bug Finder Results in Polyspace Platform User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Polyspace Results Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)