udev: add assert to make coverity happy

Coverity says:
CID 1446387 (#1 of 1): Bad bit shift operation (BAD_SHIFT)
8. negative_shift: In expression 1U << (int)cmd, shifting by a negative amount
has undefined behavior. The shift amount, cmd, is -22.

I don't think there's any issue, unless we forget to set token->data
appropriately. Let's add an assert.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-02-11 09:17:46 +01:00
parent 372a5002dc
commit b5f1c0d88b
+1
View File
@@ -1773,6 +1773,7 @@ static int udev_rule_apply_token_to_event(
}
case TK_M_IMPORT_BUILTIN: {
UdevBuiltinCommand cmd = PTR_TO_UDEV_BUILTIN_CMD(token->data);
assert(cmd >= 0 && cmd < _UDEV_BUILTIN_MAX);
unsigned mask = 1U << (int) cmd;
if (udev_builtin_run_once(cmd)) {