Versions Compared

Key

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

...

This noncompliant code example calls puts() and fails to check whether a write error occurs.

Code Block
bgColor#ffcccc
langc
puts("foo");

However, puts() can fail and return EOF.

...

This compliant solution checks to make sure no output error occurred. (See recommendation FIO04-C. Detect and handle input and output errors.)

Code Block
bgColor#ccccff
langc
if (puts("foo") == EOF) {
  /* Handle error */
}

...

EXP12-EX2: If a function cannot fail or if the return value cannot signify an error condition, the return value may be ignored. Such functions should be added to a white list when automatic checkers are used.

Code Block
bgColor#ccccff
langc
strcpy(dst, src);

Risk Assessment

...