A string is compared with "" through strcmp, where testing its first character says the same
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.
#include <string.h> int blank(const char *name){ return strcmp(name, "") == 0;tx0 reports: tests only the first character} 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:
[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.