Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Avoid in-band error indicators while designing interfaces. This practice is commonly used by C library functions but is not recommended. One example from the C Standard of a troublesome in-band error indicator is EOF. (See void FIO34-C. Use int to capture the return value of character IO functions that might be used to check for end of file and void FIO35-C. Use feof() and ferror() to detect end-of-file and file errors when sizeof(int) == sizeof(char).) Another problematic use of in-band error indicators from the C Standard involving the size_t and time_t types is described by VOID MSC31-C. Ensure that return values are compared against the proper type.

Noncompliant Code Example (sprintf())

...

Related Guidelines

...