A function is called that POSIX removed or marks as obsolete
What it finds
bzero(buf, n), index(s, c), usleep(100), inet_addr(text): functions that POSIX marked obsolete and removed, or never took from the systems they came from. They may be missing on other systems, and some have flaws their replacements fix: inet_addr cannot tell the address 255.255.255.255 from an error, and getpass reads into a static buffer of unspecified length.
Only calls of the C library's functions count: the file must include one of its headers, and a file that declares its own function of the name is left alone.
From the rule's source, obsolete_posix_function.rs.
#include <strings.h>#include <unistd.h>#include <string.h> void pause_and_clear(char *buf, int n){ bzero(buf, n);tx0 reports: bzero is obsolete in POSIX usleep(100);tx0 reports: usleep is obsolete memset(buf, 0, n);} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/c:obsolete-posix-function" = "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:obsolete-posix-function] reason="..."tx0 explain tx0/c:obsolete-posix-function shows the same in the terminal. Found a false positive? Report it.