A library function whose only effect is its result is called as a statement, so the call does nothing
What it finds
toupper(c); or strlen(name); as a statement: these functions change nothing and only return a value, so throwing the value away makes the call useless. Usually the result was meant to be assigned, as in c = toupper(c);.
Only the C library's functions count, called as a statement of their own; a cast to void says the call is meant and is left alone.
From the rule's source, result_only_call_discarded.rs.
#include <ctype.h>#include <string.h> void shout(char *s){ for (; *s; s++) toupper(*s);tx0 reports: the result of toupper is thrown away, and the call does nothing else (void)strlen(s);} 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:
[rules]
"tx0/c:result-only-call-discarded" = "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:result-only-call-discarded] reason="..."tx0 explain tx0/c:result-only-call-discarded shows the same in the terminal. Found a false positive? Report it.