A pointer to non-const char is made to point to a string literal
What it finds
char *name = "default";: the pointer lets code write into the literal, which is undefined. Declaring it const char * makes the compiler refuse such writes.
From the rule's source, string_literal_pointer.rs.
char *name = "default";tx0 reports: a pointer to non-const char points to a string literalconst char *kept = "default";char copy[] = "default"; 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:string-literal-pointer" = "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:string-literal-pointer] reason="..."tx0 explain tx0/c:string-literal-pointer shows the same in the terminal. Found a false positive? Report it.