mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
devices: simplify TPM handling
The error is never propagated anywhere. Drop it. Avoid unwrapping unconditionally. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
15ace525be
commit
2b76e1d7ba
@ -22,8 +22,6 @@ pub enum Error {
|
|||||||
CheckCaps(#[source] anyhow::Error),
|
CheckCaps(#[source] anyhow::Error),
|
||||||
#[error("Failed to initialize tpm: {0}")]
|
#[error("Failed to initialize tpm: {0}")]
|
||||||
Init(#[source] anyhow::Error),
|
Init(#[source] anyhow::Error),
|
||||||
#[error("Failed to deliver tpm Command: {0}")]
|
|
||||||
DeliverRequest(#[source] anyhow::Error),
|
|
||||||
}
|
}
|
||||||
type Result<T> = anyhow::Result<T, Error>;
|
type Result<T> = anyhow::Result<T, Error>;
|
||||||
|
|
||||||
@ -483,15 +481,12 @@ impl BusDevice for Tpm {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut cmd = cmd.clone();
|
let mut cmd = cmd.clone();
|
||||||
let output = self.emulator.deliver_request(&mut cmd).map_err(|e| {
|
|
||||||
Error::DeliverRequest(anyhow!(
|
if let Ok(output) = self.emulator.deliver_request(&mut cmd) {
|
||||||
"Failed to deliver tpm request. Error :{:?}",
|
// TODO: drop the copy here
|
||||||
e
|
self.data_buff.fill(0);
|
||||||
))
|
self.data_buff.clone_from_slice(output.as_slice());
|
||||||
});
|
}
|
||||||
// TODO: drop the copy here
|
|
||||||
self.data_buff.fill(0);
|
|
||||||
self.data_buff.clone_from_slice(output.unwrap().as_slice());
|
|
||||||
|
|
||||||
self.request_completed(TPM_SUCCESS as isize);
|
self.request_completed(TPM_SUCCESS as isize);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user