DemesneGH commented on code in PR #278:
URL:
https://github.com/apache/teaclave-trustzone-sdk/pull/278#discussion_r2785591083
##########
optee-utee/src/parameter.rs:
##########
@@ -185,3 +306,101 @@ impl From<u32> for ParamType {
}
}
}
+
+#[derive(Debug)]
+pub struct BiggerThanCapacityErr {
+ requested_size: usize,
+ capacity: usize,
+}
+
+impl Display for BiggerThanCapacityErr {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+ write!(
+ f,
+ "requested size {} but this is bigger than the capacity {}",
+ self.requested_size, self.capacity,
+ )
+ }
+}
+
+impl CoreError for BiggerThanCapacityErr {}
+
+impl From<BiggerThanCapacityErr> for crate::Error {
+ fn from(_value: BiggerThanCapacityErr) -> Self {
+ crate::Error::new(ErrorKind::Overflow)
+ }
+}
Review Comment:
Seems these new error types are only used for printing error messages before
being converted into a standard optee Error?
To keep the SDK simple, why not use `trace_println!` at the call site and
eliminate these extra types? I believe the code would be much clean and simple.
BTW, you can use `ErrorKind::Overflow.into()` to convert directly to the
OP-TEE Error.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]