[PATCH 2/3] rust_binder: store Option<Error> in TransactionInfo
From: Alice Ryhl
Date: Wed Oct 07 2026 - 10:45:01 EST
Store Option<Error> instead of a raw i32 errno in TransactionInfo so
that the Error value can be used directly when formatting transaction
failures without having to reconstruct it from the integer errno.
Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
---
drivers/android/binder/thread.rs | 6 +++---
drivers/android/binder/transaction.rs | 8 ++++++--
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/android/binder/thread.rs b/drivers/android/binder/thread.rs
index e5ae3b0e56c5..5bb7ae2f7920 100644
--- a/drivers/android/binder/thread.rs
+++ b/drivers/android/binder/thread.rs
@@ -1333,8 +1333,8 @@ fn transaction(self: &Arc<Self>, cmd: u32, reader: &mut UserSliceReader) -> Resu
if err.reply != BR_TRANSACTION_COMPLETE {
info.reply = err.reply;
info.error_line = Some(err.line);
- if let Some(source) = &err.source {
- info.errno = source.to_errno();
+ if let Some(source) = err.source {
+ info.errno = Some(source);
{
let mut inner = self.inner.lock();
@@ -1476,7 +1476,7 @@ fn reply_inner(self: &Arc<Self>, info: &mut TransactionInfo) -> BinderResult {
orig.from
.deliver_reply(Err(BR_FAILED_REPLY), &orig, Some(ee));
info.reply = BR_FAILED_REPLY;
- info.errno = param;
+ info.errno = err.source;
info.error_line = Some(err.line);
err.reply = BR_TRANSACTION_COMPLETE;
err
diff --git a/drivers/android/binder/transaction.rs b/drivers/android/binder/transaction.rs
index e627522141b8..d934c6821b15 100644
--- a/drivers/android/binder/transaction.rs
+++ b/drivers/android/binder/transaction.rs
@@ -136,7 +136,11 @@ fn new(info: &TransactionInfo, ctx: &crate::Context) -> Self {
offsets_size: info.offsets_size,
return_error_line: if failed { info.error_line } else { None },
return_error: if failed { info.reply } else { 0 },
- return_error_param: if failed { info.errno } else { 0 },
+ return_error_param: if failed {
+ info.errno.map_or(0, |e| e.to_errno())
+ } else {
+ 0
+ },
context_name,
}
}
@@ -254,7 +258,7 @@ pub(crate) struct TransactionInfo {
pub(crate) offsets_size: usize,
pub(crate) buffers_size: usize,
pub(crate) target_handle: u32,
- pub(crate) errno: i32,
+ pub(crate) errno: Option<Error>,
pub(crate) reply: u32,
pub(crate) error_line: Option<ErrorLocation>,
pub(crate) oneway_spam_suspect: bool,
--
2.56.0.rc1.315.gc6ed9934b7-goog