scsi: run clippy --fix
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
This commit is contained in:
parent
e94925b7dd
commit
bf67559313
4 changed files with 32 additions and 31 deletions
|
|
@ -247,7 +247,7 @@ impl<T: BlockDeviceBackend> LogicalUnit for BlockDevice<T> {
|
|||
return Ok(CmdOutput::check_condition(sense::INVALID_FIELD_IN_CDB));
|
||||
}
|
||||
|
||||
debug!("Incoming command: {:?}", command);
|
||||
debug!("Incoming command: {command:?}");
|
||||
|
||||
match command {
|
||||
LunSpecificCommand::TestUnitReady => Ok(CmdOutput::ok()),
|
||||
|
|
@ -274,7 +274,7 @@ impl<T: BlockDeviceBackend> LogicalUnit for BlockDevice<T> {
|
|||
Ok(CmdOutput::ok())
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Error getting image size: {}", e);
|
||||
error!("Error getting image size: {e}");
|
||||
// TODO: Is this a reasonable sense code to send?
|
||||
Ok(CmdOutput::check_condition(sense::UNRECOVERED_READ_ERROR))
|
||||
}
|
||||
|
|
@ -309,7 +309,7 @@ impl<T: BlockDeviceBackend> LogicalUnit for BlockDevice<T> {
|
|||
Ok(CmdOutput::ok())
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Error getting image size: {}", e);
|
||||
error!("Error getting image size: {e}");
|
||||
// TODO: Is this a reasonable sense code to send?
|
||||
Ok(CmdOutput::check_condition(sense::UNRECOVERED_READ_ERROR))
|
||||
}
|
||||
|
|
@ -415,7 +415,7 @@ impl<T: BlockDeviceBackend> LogicalUnit for BlockDevice<T> {
|
|||
// is a bit blunt, but does the trick.
|
||||
|
||||
if let Err(e) = self.backend.sync() {
|
||||
error!("Error syncing file: {}", e);
|
||||
error!("Error syncing file: {e}");
|
||||
return Ok(CmdOutput::check_condition(sense::TARGET_FAILURE));
|
||||
}
|
||||
}
|
||||
|
|
@ -426,7 +426,7 @@ impl<T: BlockDeviceBackend> LogicalUnit for BlockDevice<T> {
|
|||
let size = match self.backend.size_in_blocks() {
|
||||
Ok(size) => size,
|
||||
Err(e) => {
|
||||
error!("Error getting image size for read: {}", e);
|
||||
error!("Error getting image size for read: {e}");
|
||||
return Ok(CmdOutput::check_condition(sense::UNRECOVERED_READ_ERROR));
|
||||
}
|
||||
};
|
||||
|
|
@ -448,7 +448,7 @@ impl<T: BlockDeviceBackend> LogicalUnit for BlockDevice<T> {
|
|||
Ok(CmdOutput::ok())
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Error reading image: {}", e);
|
||||
error!("Error reading image: {e}");
|
||||
Ok(CmdOutput::check_condition(sense::UNRECOVERED_READ_ERROR))
|
||||
}
|
||||
}
|
||||
|
|
@ -468,7 +468,7 @@ impl<T: BlockDeviceBackend> LogicalUnit for BlockDevice<T> {
|
|||
let size = match self.backend.size_in_blocks() {
|
||||
Ok(size) => size,
|
||||
Err(e) => {
|
||||
error!("Error getting image size for read: {}", e);
|
||||
error!("Error getting image size for read: {e}");
|
||||
return Ok(CmdOutput::check_condition(sense::TARGET_FAILURE));
|
||||
}
|
||||
};
|
||||
|
|
@ -486,7 +486,7 @@ impl<T: BlockDeviceBackend> LogicalUnit for BlockDevice<T> {
|
|||
|
||||
if fua {
|
||||
if let Err(e) = self.backend.sync() {
|
||||
error!("Error syncing file: {}", e);
|
||||
error!("Error syncing file: {e}");
|
||||
return Ok(CmdOutput::check_condition(sense::TARGET_FAILURE));
|
||||
}
|
||||
}
|
||||
|
|
@ -494,7 +494,7 @@ impl<T: BlockDeviceBackend> LogicalUnit for BlockDevice<T> {
|
|||
match write_result {
|
||||
Ok(()) => Ok(CmdOutput::ok()),
|
||||
Err(e) => {
|
||||
error!("Error writing to block device: {}", e);
|
||||
error!("Error writing to block device: {e}");
|
||||
Ok(CmdOutput::check_condition(sense::TARGET_FAILURE))
|
||||
}
|
||||
}
|
||||
|
|
@ -516,7 +516,7 @@ impl<T: BlockDeviceBackend> LogicalUnit for BlockDevice<T> {
|
|||
let size = match self.backend.size_in_blocks() {
|
||||
Ok(size) => size,
|
||||
Err(e) => {
|
||||
error!("Error getting image size for read: {}", e);
|
||||
error!("Error getting image size for read: {e}");
|
||||
return Ok(CmdOutput::check_condition(sense::UNRECOVERED_READ_ERROR));
|
||||
}
|
||||
};
|
||||
|
|
@ -537,7 +537,7 @@ impl<T: BlockDeviceBackend> LogicalUnit for BlockDevice<T> {
|
|||
];
|
||||
let read_result = data_out.read_exact(&mut buf);
|
||||
if let Err(e) = read_result {
|
||||
error!("Error reading from data_out: {}", e);
|
||||
error!("Error reading from data_out: {e}");
|
||||
return Ok(CmdOutput::check_condition(sense::TARGET_FAILURE));
|
||||
}
|
||||
|
||||
|
|
@ -546,7 +546,7 @@ impl<T: BlockDeviceBackend> LogicalUnit for BlockDevice<T> {
|
|||
match write_result {
|
||||
Ok(()) => Ok(CmdOutput::ok()),
|
||||
Err(e) => {
|
||||
error!("Error writing to block device: {}", e);
|
||||
error!("Error writing to block device: {e}");
|
||||
Ok(CmdOutput::check_condition(sense::TARGET_FAILURE))
|
||||
}
|
||||
}
|
||||
|
|
@ -768,7 +768,7 @@ impl<T: BlockDeviceBackend> LogicalUnit for BlockDevice<T> {
|
|||
match self.backend.sync() {
|
||||
Ok(()) => Ok(CmdOutput::ok()),
|
||||
Err(e) => {
|
||||
error!("Error syncing block device: {}", e);
|
||||
error!("Error syncing block device: {e}");
|
||||
Ok(CmdOutput::check_condition(sense::TARGET_FAILURE))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -543,8 +543,7 @@ impl Cdb {
|
|||
(0x3f, 0x0) => ModePageSelection::AllPageZeros,
|
||||
_ => {
|
||||
warn!(
|
||||
"Rejecting request for unknown mode page {:#2x}/{:#2x}.",
|
||||
page_code, subpage_code
|
||||
"Rejecting request for unknown mode page {page_code:#2x}/{subpage_code:#2x}."
|
||||
);
|
||||
return Err(ParseError::InvalidField);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ impl VhostUserScsiBackend {
|
|||
if e.kind() == ErrorKind::WriteZero {
|
||||
Response::error(ResponseCode::Overrun, 0)
|
||||
} else {
|
||||
error!("Error writing response to guest memory: {}", e);
|
||||
error!("Error writing response to guest memory: {e}");
|
||||
|
||||
// There's some chance the header and data in are on different
|
||||
// descriptors, and only the data in
|
||||
|
|
@ -148,11 +148,11 @@ impl VhostUserScsiBackend {
|
|||
Err(RequestParseError::CouldNotReadGuestMemory(e)) => {
|
||||
// See comment later about errors while writing to guest mem; maybe we at least
|
||||
// got functional write descriptors, so we can report an error
|
||||
error!("Error reading request from guest memory: {:?}", e);
|
||||
error!("Error reading request from guest memory: {e:?}");
|
||||
Response::error(ResponseCode::Failure, body_writer.residual())
|
||||
}
|
||||
Err(RequestParseError::FailedParsingLun(lun)) => {
|
||||
error!("Unable to parse LUN: {:?}", lun);
|
||||
error!("Unable to parse LUN: {lun:?}");
|
||||
Response::error(ResponseCode::Failure, body_writer.residual())
|
||||
}
|
||||
};
|
||||
|
|
@ -167,7 +167,7 @@ impl VhostUserScsiBackend {
|
|||
// silently fail or crash. There isn't too much sense in crashing, IMO, as
|
||||
// the guest could still recover by, say, installing a fixed kernel and
|
||||
// rebooting. So let's just log an error and do nothing.
|
||||
error!("Error writing response to guest memory: {:?}", e);
|
||||
error!("Error writing response to guest memory: {e:?}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ impl VhostUserScsiBackend {
|
|||
.get_mut()
|
||||
.get_queue_mut()
|
||||
.iter(self.mem.as_ref().unwrap().memory())
|
||||
.map_err(|e| io::Error::new(ErrorKind::Other, e))?
|
||||
.map_err(io::Error::other)?
|
||||
.collect();
|
||||
for dc in chains {
|
||||
let mut writer = DescriptorChainWriter::new(dc.clone());
|
||||
|
|
@ -186,12 +186,10 @@ impl VhostUserScsiBackend {
|
|||
|
||||
vring
|
||||
.add_used(dc.head_index(), writer.max_written())
|
||||
.map_err(|e| io::Error::new(ErrorKind::Other, e))?;
|
||||
.map_err(io::Error::other)?;
|
||||
}
|
||||
|
||||
vring
|
||||
.signal_used_queue()
|
||||
.map_err(|e| io::Error::new(ErrorKind::Other, e))?;
|
||||
vring.signal_used_queue().map_err(io::Error::other)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -272,7 +270,7 @@ impl VhostUserBackendMut for VhostUserScsiBackend {
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
error!("Ignoring descriptor on queue {}", device_event);
|
||||
error!("Ignoring descriptor on queue {device_event}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::{
|
|||
cmp::{max, min},
|
||||
convert::TryInto,
|
||||
io,
|
||||
io::{ErrorKind, Read, Write},
|
||||
io::{Read, Write},
|
||||
mem,
|
||||
ops::Deref,
|
||||
rc::Rc,
|
||||
|
|
@ -223,11 +223,15 @@ where
|
|||
.memory()
|
||||
.write(
|
||||
&buf[..(to_write as usize)],
|
||||
GuestAddress(current.addr().0.checked_add(u64::from(self.offset)).ok_or(
|
||||
io::Error::new(ErrorKind::Other, vm_memory::Error::InvalidGuestRegion),
|
||||
)?),
|
||||
GuestAddress(
|
||||
current
|
||||
.addr()
|
||||
.0
|
||||
.checked_add(u64::from(self.offset))
|
||||
.ok_or(io::Error::other(vm_memory::Error::InvalidGuestRegion))?,
|
||||
),
|
||||
)
|
||||
.map_err(|e| io::Error::new(ErrorKind::Other, e))?;
|
||||
.map_err(io::Error::other)?;
|
||||
|
||||
self.offset += written as u32;
|
||||
|
||||
|
|
@ -295,7 +299,7 @@ where
|
|||
&mut buf[..(to_read as usize)],
|
||||
GuestAddress(current.addr().0 + u64::from(self.offset)),
|
||||
)
|
||||
.map_err(|e| io::Error::new(ErrorKind::Other, e))?;
|
||||
.map_err(io::Error::other)?;
|
||||
|
||||
self.offset += read as u32;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue