lkml.org 
[lkml]   [2023]   [Nov]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH RFC 03/20] rust_binder: add threading support
Date


On 1 Nov 2023, at 19:01, Alice Ryhl wrote:


> diff --git a/drivers/android/error.rs b/drivers/android/error.rs
> new file mode 100644
> index 000000000000..41fc4347ab55
> --- /dev/null
> +++ b/drivers/android/error.rs
> +
> +impl core::fmt::Debug for BinderError {
> + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
> + match self.reply {
> + BR_FAILED_REPLY => match self.source.as_ref() {
> + Some(source) => f
> + .debug_struct("BR_FAILED_REPLY")
> + .field("source", source)
> + .finish(),
> + None => f.pad("BR_FAILED_REPLY"),
> + },
> + BR_DEAD_REPLY => f.pad("BR_DEAD_REPLY"),
> + BR_TRANSACTION_COMPLETE => f.pad("BR_TRANSACTION_COMPLETE"),
> + _ => f
> + .debug_struct("BinderError")
> + .field("reply", &self.reply)
> + .finish(),
> + }
> + }
> +}
Renaming the debug_struct itself feels like it will make it harder to find later, as I would expect that a debug implementation names the struct its from.
Also this has the fallback in CamelCase and all defined cases as SCREAMING_SNAKE_CASE. Maybe rather in the defined cases something like f.debug_struct(‘BinderError’).field(‘reply’, “name”)?

\
 
 \ /
  Last update: 2023-11-20 13:47    [W:0.205 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site