mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2025-12-26 14:41:23 +00:00
scmi: run clippy --fix
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
This commit is contained in:
parent
46c8f93d87
commit
3d4dc8e05f
@ -666,17 +666,17 @@ mod tests {
|
||||
Err(DeviceError::MissingDeviceProperties(missing)) => {
|
||||
assert_eq!(missing, vec!["abc".to_owned(), "ghi".to_owned()])
|
||||
}
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
match properties.check(&["def"], &["foo", "baz"]) {
|
||||
Err(DeviceError::UnexpectedDeviceProperties(unexpected)) => {
|
||||
assert_eq!(unexpected, vec!["bar".to_owned()])
|
||||
}
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
match properties.check(&["def"], &["foo", "bar"]) {
|
||||
Ok(()) => (),
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -438,7 +438,7 @@ impl SensorT for IIOSensor {
|
||||
let signed = scan_type.sign == 's';
|
||||
let le_endian = scan_type.endianness == IioEndian::IioLe;
|
||||
if !signed || !le_endian {
|
||||
error!("Unsupported notification format: {:?}", scan_type);
|
||||
error!("Unsupported notification format: {scan_type:?}");
|
||||
return Err(ScmiDeviceError::GenericError);
|
||||
}
|
||||
|
||||
@ -489,7 +489,7 @@ impl SensorT for IIOSensor {
|
||||
fn notify_status_set(&self, enabled: bool) -> Result<(), DeviceError> {
|
||||
let path_split: Vec<_> = self.path.to_str().unwrap().split('/').collect();
|
||||
let iio_name = path_split[path_split.len() - 1];
|
||||
let buffer_enable = format!("/sys/bus/iio/devices/{}/buffer/enable", iio_name);
|
||||
let buffer_enable = format!("/sys/bus/iio/devices/{iio_name}/buffer/enable");
|
||||
let mut scan_enable = vec![];
|
||||
for i in 0..self.number_of_axes() {
|
||||
scan_enable.push(format!(
|
||||
@ -830,7 +830,7 @@ mod tests {
|
||||
Err(DeviceError::MissingDeviceProperties(missing)) => {
|
||||
assert_eq!(missing, vec!["channel".to_owned()])
|
||||
}
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -849,7 +849,7 @@ mod tests {
|
||||
Err(DeviceError::UnexpectedDeviceProperties(extra)) => {
|
||||
assert_eq!(extra, ["bar".to_owned(), "foo".to_owned()])
|
||||
}
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -870,7 +870,7 @@ mod tests {
|
||||
Err(DeviceError::IOError(path, std::io::Error { .. })) => {
|
||||
assert_eq!(path, "non-existent")
|
||||
}
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -883,11 +883,10 @@ mod tests {
|
||||
Err(DeviceError::GenericError(message)) => {
|
||||
assert!(
|
||||
message.starts_with("No \"in_accel\" channel found in \"./_test"),
|
||||
"Unexpected error: {}",
|
||||
message
|
||||
"Unexpected error: {message}"
|
||||
)
|
||||
}
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -177,7 +177,7 @@ impl ScmiResponse {
|
||||
};
|
||||
ret_bytes.append(&mut bytes)
|
||||
}
|
||||
debug!("ret bytes: {:?}", ret_bytes);
|
||||
debug!("ret bytes: {ret_bytes:?}");
|
||||
Self { header, ret_bytes }
|
||||
}
|
||||
|
||||
@ -221,10 +221,7 @@ impl ScmiRequest {
|
||||
0 => MessageType::Command,
|
||||
_ => MessageType::Unsupported,
|
||||
};
|
||||
debug!(
|
||||
"SCMI request: protocol id={}, message id={}, message_type={:?}, token={}",
|
||||
protocol_id, message_id, message_type, token
|
||||
);
|
||||
debug!("SCMI request: protocol id={protocol_id}, message id={message_id}, message_type={message_type:?}, token={token}");
|
||||
Self {
|
||||
header,
|
||||
message_id,
|
||||
@ -342,9 +339,7 @@ impl HandlerMap {
|
||||
) {
|
||||
assert!(
|
||||
self.get(protocol_id, message_id).is_none(),
|
||||
"Multiple handlers defined for SCMI message {}/{}",
|
||||
protocol_id,
|
||||
message_id
|
||||
"Multiple handlers defined for SCMI message {protocol_id}/{message_id}"
|
||||
);
|
||||
self.0.insert(
|
||||
(protocol_id, message_id),
|
||||
@ -843,7 +838,7 @@ impl ScmiHandler {
|
||||
ParameterType::_SignedInt32 => MessageValue::Signed(i32::from_le_bytes(slice)),
|
||||
ParameterType::UnsignedInt32 => MessageValue::Unsigned(u32::from_le_bytes(slice)),
|
||||
};
|
||||
debug!("SCMI parameter {}: {:?}", n, v);
|
||||
debug!("SCMI parameter {n}: {v:?}");
|
||||
values.push(v);
|
||||
}
|
||||
request.parameters = Some(values);
|
||||
@ -883,19 +878,19 @@ impl ScmiHandler {
|
||||
ScmiDeviceError::NoSuchDevice
|
||||
| ScmiDeviceError::NotEnabled
|
||||
| ScmiDeviceError::InvalidParameters => {
|
||||
info!("Invalid device access: {}, {}", device_index, error);
|
||||
info!("Invalid device access: {device_index}, {error}");
|
||||
Response::from(ReturnStatus::InvalidParameters)
|
||||
}
|
||||
ScmiDeviceError::UnsupportedRequest => {
|
||||
info!("Unsupported request for {}", device_index);
|
||||
info!("Unsupported request for {device_index}");
|
||||
Response::from(ReturnStatus::NotSupported)
|
||||
}
|
||||
ScmiDeviceError::UnsupportedNotify => {
|
||||
info!("Unsupported notify for {}", device_index);
|
||||
info!("Unsupported notify for {device_index}");
|
||||
Response::from(ReturnStatus::NotSupported)
|
||||
}
|
||||
ScmiDeviceError::GenericError => {
|
||||
warn!("Device error in {}", device_index);
|
||||
warn!("Device error in {device_index}");
|
||||
Response::from(ReturnStatus::GenericError)
|
||||
}
|
||||
},
|
||||
@ -935,7 +930,7 @@ impl ScmiHandler {
|
||||
.skip(skip)
|
||||
.collect();
|
||||
let n_protocols = protocols.len();
|
||||
debug!("Number of listed protocols after {}: {}", skip, n_protocols);
|
||||
debug!("Number of listed protocols after {skip}: {n_protocols}");
|
||||
let mut values: Vec<MessageValue> = vec![MessageValue::Unsigned(n_protocols as u32)];
|
||||
if n_protocols > 0 {
|
||||
let mut compressed: Vec<u32> = vec![0; 1 + (n_protocols - 1) / 4];
|
||||
@ -1559,7 +1554,7 @@ mod tests {
|
||||
let mut handler = ScmiHandler::new();
|
||||
for sensor_id in 0..2 {
|
||||
let properties =
|
||||
DeviceProperties::new(vec![("name".to_owned(), format!("fake{}", sensor_id))]);
|
||||
DeviceProperties::new(vec![("name".to_owned(), format!("fake{sensor_id}"))]);
|
||||
let fake_sensor = FakeSensor::new_device(&properties).unwrap();
|
||||
handler.register_device(fake_sensor);
|
||||
enable_sensor(sensor_id, true, &mut handler);
|
||||
|
||||
@ -86,7 +86,7 @@ pub enum VuScmiError {
|
||||
|
||||
impl From<VuScmiError> for io::Error {
|
||||
fn from(e: VuScmiError) -> Self {
|
||||
Self::new(io::ErrorKind::Other, e)
|
||||
Self::other(e)
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ impl VuScmiBackend {
|
||||
.map_err(|_| VuScmiError::DescriptorReadFailed)?;
|
||||
let mut scmi_request = ScmiRequest::new(header);
|
||||
let n_parameters = self.scmi_handler.number_of_parameters(&scmi_request);
|
||||
debug!("SCMI request with n parameters: {:?}", n_parameters);
|
||||
debug!("SCMI request with n parameters: {n_parameters:?}");
|
||||
let value_size = 4;
|
||||
if let Some(expected_parameters) = n_parameters {
|
||||
if expected_parameters > 0 {
|
||||
@ -227,7 +227,7 @@ impl VuScmiBackend {
|
||||
|
||||
debug!("Calling SCMI request handler");
|
||||
let mut response = self.scmi_handler.handle(scmi_request);
|
||||
debug!("SCMI response: {:?}", response);
|
||||
debug!("SCMI response: {response:?}");
|
||||
|
||||
let desc_response = descriptors[1];
|
||||
if !desc_response.is_write_only() {
|
||||
@ -284,7 +284,7 @@ impl VuScmiBackend {
|
||||
debug!("Notification sent");
|
||||
}
|
||||
Err(err) => {
|
||||
warn!("Failed SCMI request: {}", err);
|
||||
warn!("Failed SCMI request: {err}");
|
||||
return Err(err);
|
||||
}
|
||||
}
|
||||
@ -349,7 +349,7 @@ impl VuScmiBackend {
|
||||
debug!("Notification sent");
|
||||
}
|
||||
Err(err) => {
|
||||
warn!("Failed SCMI request: {}", err);
|
||||
warn!("Failed SCMI request: {err}");
|
||||
return Err(err);
|
||||
}
|
||||
}
|
||||
@ -452,7 +452,7 @@ impl VhostUserBackendMut for VuScmiBackend {
|
||||
|
||||
fn set_event_idx(&mut self, enabled: bool) {
|
||||
self.event_idx = enabled;
|
||||
debug!("Event idx set to: {}", enabled);
|
||||
debug!("Event idx set to: {enabled}");
|
||||
}
|
||||
|
||||
fn update_memory(&mut self, mem: GuestMemoryAtomic<GuestMemoryMmap>) -> IoResult<()> {
|
||||
@ -530,7 +530,7 @@ impl VhostUserBackendMut for VuScmiBackend {
|
||||
.enable_notification()
|
||||
.map_err(|error: virtio_queue::Error| std::io::Error::other(error))?;
|
||||
} else {
|
||||
warn!("unhandled device_event: {}", device_event);
|
||||
warn!("unhandled device_event: {device_event}");
|
||||
return Err(VuScmiError::HandleEventUnknownEvent.into());
|
||||
}
|
||||
}
|
||||
@ -652,10 +652,7 @@ mod tests {
|
||||
VRING_DESC_F_NEXT as u16
|
||||
};
|
||||
f |= p.flags;
|
||||
let offset = match p.addr {
|
||||
Some(addr) => addr,
|
||||
_ => 0x100,
|
||||
};
|
||||
let offset = p.addr.unwrap_or(0x100);
|
||||
let desc = RawDescriptor::from(SplitDescriptor::new(offset, p.len, f, (i + 1) as u16));
|
||||
vq.desc_table().store(i as u16, desc).unwrap();
|
||||
}
|
||||
@ -761,7 +758,7 @@ mod tests {
|
||||
.unwrap_err()
|
||||
{
|
||||
VuScmiError::UnexpectedDescriptorCount(1) => (),
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
|
||||
// Have three descriptors, expected two.
|
||||
@ -772,7 +769,7 @@ mod tests {
|
||||
.unwrap_err()
|
||||
{
|
||||
VuScmiError::UnexpectedDescriptorCount(3) => (),
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
|
||||
// Write only descriptors.
|
||||
@ -788,7 +785,7 @@ mod tests {
|
||||
.unwrap_err()
|
||||
{
|
||||
VuScmiError::UnexpectedWriteOnlyDescriptor(0) => (),
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
|
||||
// Invalid request address.
|
||||
@ -810,7 +807,7 @@ mod tests {
|
||||
.unwrap_err()
|
||||
{
|
||||
VuScmiError::DescriptorReadFailed => (),
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
|
||||
// Invalid request length (very small).
|
||||
@ -832,7 +829,7 @@ mod tests {
|
||||
.unwrap_err()
|
||||
{
|
||||
VuScmiError::UnexpectedMinimumDescriptorSize(4, 2) => (),
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
|
||||
// Invalid request length (too small).
|
||||
@ -842,7 +839,7 @@ mod tests {
|
||||
.unwrap_err()
|
||||
{
|
||||
VuScmiError::UnexpectedDescriptorSize(8, 4) => (),
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
|
||||
// Invalid request length (too large).
|
||||
@ -852,7 +849,7 @@ mod tests {
|
||||
.unwrap_err()
|
||||
{
|
||||
VuScmiError::UnexpectedDescriptorSize(4, 8) => (),
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
|
||||
// Read only descriptors.
|
||||
@ -868,7 +865,7 @@ mod tests {
|
||||
.unwrap_err()
|
||||
{
|
||||
VuScmiError::UnexpectedReadableDescriptor(1) => (),
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
|
||||
// Invalid response address.
|
||||
@ -890,7 +887,7 @@ mod tests {
|
||||
.unwrap_err()
|
||||
{
|
||||
VuScmiError::DescriptorWriteFailed => (),
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
|
||||
// Invalid response length.
|
||||
@ -912,7 +909,7 @@ mod tests {
|
||||
.unwrap_err()
|
||||
{
|
||||
VuScmiError::InsufficientDescriptorSize(8, 6) => (),
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -965,7 +962,7 @@ mod tests {
|
||||
.unwrap_err()
|
||||
{
|
||||
VuScmiError::UnexpectedDescriptorCount(2) => (),
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
|
||||
// Read only descriptor
|
||||
@ -980,7 +977,7 @@ mod tests {
|
||||
.unwrap_err()
|
||||
{
|
||||
VuScmiError::UnexpectedReadableDescriptor(0) => (),
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user