An integer literal starts with 0 and is octal, which reads like a decimal number
What it finds
int codes[] = { 010, 020, 100 };: a leading zero makes an integer literal octal, so 010 is eight. Written among decimal numbers, as padding, it is a different value than it looks.
File permissions are octal by convention and are left alone: literals given to functions whose name holds mod, open, mkdir, umask, creat, mkfifo or mknod, and literals stored in or compared with names that hold mode or perm. Literals from 00 to 07 mean the same in decimal and are left alone too.
From the rule's source, octal_literal.rs.
#include <sys/stat.h> static const int codes[] = { 10, 010, 100 };tx0 reports: 010 is octal, the number 8 void setup(const char *path){ int mode = 0644; chmod(path, 0755); mkdir(path, 0700); (void)mode;} 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:octal-literal" = "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:octal-literal] reason="..."tx0 explain tx0/c:octal-literal shows the same in the terminal. Found a false positive? Report it.