Versions Compared

Key

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

...

This compliant solution enforces the contract by adding va_eol as the final argument.:

Code Block
bgColor#ccccff
langc
int avg = average(1, 4, 6, 4, 1, va_eol);

...

Another common mistake is to use more conversion specifiers than supplied arguments, as shown in this noncompliant code example.:

Code Block
bgColor#ffcccc
langc
const char *error_msg = "Resource not available to user.";
/* ... */
printf("Error (%s): %s", error_msg);

...

This compliant solution matches the number of format specifiers with the number of variable arguments.:

Code Block
bgColor#ccccff
langc
const char *error_msg = "Resource not available to user.";
/* ... */
printf("Error: %s", error_msg);

...

ISO/IEC TR 24772:2013Subprogram Signature Mismatch [OTR]
MISRA - C:2012Rule 1617.1 (required)
MITRE CWECWE-628, Function call with incorrectly specified arguments

...