mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2026-01-08 20:57:35 +00:00
scmi: fix manual arithmetic check warning
clippy 0.1.83 (90b35a6 2024-11-26) emits a new warning:
warning: manual arithmetic check found
--> vhost-device-scmi/src/scmi.rs:471:41
|
471 | let remaining_sensors = if n_sensors > last_non_returned_se...
| _________________________________________^
472 | | n_sensors - last_non_returned_sensor
473 | | } else {
474 | | 0
475 | | };
| |_________________^ help: replace it with: `n_sensors.saturating_sub(last_non_returned_sensor)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#implicit_saturating_sub
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
This commit is contained in:
parent
0a5249b903
commit
b96475f788
@ -468,11 +468,7 @@ impl HandlerMap {
|
||||
let max_sensors_to_return = 256;
|
||||
let sensors_to_return = min(n_sensors - first_index, max_sensors_to_return);
|
||||
let last_non_returned_sensor = first_index + sensors_to_return;
|
||||
let remaining_sensors = if n_sensors > last_non_returned_sensor {
|
||||
n_sensors - last_non_returned_sensor
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let remaining_sensors = n_sensors.saturating_sub(last_non_returned_sensor);
|
||||
let mut values = vec![MessageValue::Unsigned(
|
||||
sensors_to_return as u32 | (remaining_sensors as u32) << 16,
|
||||
)];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user