A function declared to return void returns a value

tx0/c:return-value-in-void-functiondefaultwarningreliability/control-flowdepth fastbug

What it finds

void reset(struct s *p) { ... return p->count; }: the standard does not allow a value after return in a function returning void; compilers reject it or drop the value, and either the return type or the statement is wrong.

A call, a cast, a conditional or a comma expression may have type void, which GNU C accepts after return, and is left alone.

From the rule's source, return_value_in_void_function.rs.

Example from the rule's tests
struct counter { int n; }; void reset(struct counter *c){  if (!c)    return 0;tx0 reports: this function returns void but this return gives a value  c->n = 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:return-value-in-void-function" = "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:return-value-in-void-function] reason="..."

tx0 explain tx0/c:return-value-in-void-function shows the same in the terminal. Found a false positive? Report it.