Bit mask makes the expression a constant
ID |
rust.correctness.bad_bit_mask |
Severity |
low |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Suspicious Construct |
Language |
Rust |
Description
This bit mask makes the result independent of the operand: the expression always yields the same value, so the flag it is supposed to test is never really examined. Check the mask constant and the value compared against it.
Rationale
This bit mask makes the result independent of the operand: the expression always yields the same value, so the flag it is supposed to test is never really examined. Check the mask constant and the value compared against it.
The following code illustrates the pattern detected by this rule:
pub fn always_zero(flags: u32) -> u32 {
// FLAGGED: Bit mask makes the expression a constant
flags & 0
}