memset is given a fill value that does not fit in a byte

tx0/cpp:memset-value-truncateddefaultwarningreliability/memory-safetydepth fastbug

What it finds

memset(buf, 1000, n) or memset(a, 0x1234, n): memset converts the value to unsigned char and fills every byte with it, so only the lowest byte is used. Filling an array of wider elements with a value takes a loop.

The value must be a constant written with literals, larger than 255 or smaller than -128.

From the rule's source, memset_value_truncated.rs.

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:

tx0.toml
[rules]
"tx0/cpp:memset-value-truncated" = "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/cpp:memset-value-truncated] reason="..."

tx0 explain tx0/cpp:memset-value-truncated shows the same in the terminal. Found a false positive? Report it.