A string is compared with "" through strcmp, where testing its first character says the same

tx0/c:compare-with-empty-stringstrictwarningperformance/algorithmicdepth fastperformance

What it finds

strcmp(name, "") == 0 calls a function to find out whether name[0] is '\0', which the test name[0] == '\0' says directly.

From the rule's source, compare_with_empty_string.rs.

Example from the rule's tests
#include <string.h> int blank(const char *name){  return strcmp(name, "") == 0;tx0 reports: tests only the first character}
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 from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/c:compare-with-empty-string" = "warning"

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:compare-with-empty-string] reason="..."

tx0 explain tx0/c:compare-with-empty-string shows the same in the terminal. Found a false positive? Report it.