va_start is given a parameter other than the last named one, which is undefined

tx0/c:va-start-not-last-parameterdefaultwarningreliability/memory-safetydepth fastbug

What it finds

void log(int level, const char *fmt, ...) { va_start(ap, level); ...: the second argument of va_start must be the parameter right before the ...; with another one the variable arguments are read from the wrong place.

From the rule's source, va_start_not_last_parameter.rs.

Example from the rule's tests
#include <stdarg.h> int logf(int level, const char *fmt, ...){  va_list ap;  va_start(ap, level);tx0 reports: va_start is given level, but the last named parameter is fmt  int n = va_arg(ap, int);  va_end(ap);  return n + level + (fmt != 0);}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/c:va-start-not-last-parameter" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/c:va-start-not-last-parameter] reason="..."

tx0 explain tx0/c:va-start-not-last-parameter shows the same in the terminal. Found a false positive? Report it.