Versions Compared

Key

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

...

However, puts() can fail and return EOF. If the output were determined to be critical, then the return value should have been checked.

Compliant Solution

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

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

Exceptions

EXP12-EX1: If the return value is inconsequential or if any errors can be safely ignored, such as for functions called because of their side effects, the function should be explicitly cast to void to signify programmer intent. See the compliant solution for removing an existing destination file in FIO10-C. Take care when using the rename() function for an example of this exception.

...