A value is masked with & 0, which is always 0
What it finds
flags & 0 is always 0, whatever flags holds, and flags &= 0 clears it. A mask of zero is a typo for another constant, or an | that became an &.
Reported is & or &= with the integer literal 0 as an operand, on integer operands.
From the rule's source, mask_with_zero.rs.
class Flags { int clear(int flags, long bits) { int a = flags & 0;tx0 reports: flags & 0 masks with 0 flags &= 0;tx0 reports: masks with 0 long b = 0 & bits;tx0 reports: masks with 0 int c = flags & 1; int d = flags | 0; return a + (int) b + c + d; }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/java:mask-with-zero" = "off"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/java:mask-with-zero] reason="..."tx0 explain tx0/java:mask-with-zero shows the same in the terminal. Found a false positive? Report it.