NULL is assigned to, compared with or returned as an integer rather than a pointer

tx0/c:null-as-integerrecommendedwarningreliability/null-safetydepth fastbug

What it finds

int count = NULL; or if (n == NULL): NULL is a null pointer constant, and where it is defined as ((void *)0) the code does not compile or converts a pointer to an integer. 0 is the integer meant.

The other side must be a variable declared with an integer type in the file, and NULL must not be defined in the file.

From the rule's source, null_as_integer.rs.

Example from the rule's tests
#include <stddef.h> int count(const int *items, int n){  int total = NULL;tx0 reports: NULL is a pointer constant but stands for an integer here  if (n == NULL)tx0 reports: stands for an integer here    return 0;  if (items == NULL)    return 0;  return total;}
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 recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/c:null-as-integer" = "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:null-as-integer] reason="..."

tx0 explain tx0/c:null-as-integer shows the same in the terminal. Found a false positive? Report it.