Re: [PATCH 2/8] rust: debugfs: Bind file creation for long-lived Display

Matthew Maurer
2025-04-30T15:12:23Z

On Wed, Apr 30, 2025 at 5:06 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Tue, Apr 29, 2025 at 11:15:56PM +0000, Matthew Maurer wrote:
> > + /// Create a file in a DebugFS directory with the provided name, and contents from invoking
> > + /// [`Display::fmt`] on the provided reference.
> > + ///
> > + /// # Example
> > + ///
> > + /// ```
> > + /// # use kernel::c_str;
> > + /// # use kernel::debugfs::Dir;
> > + /// let dir = Dir::new(c_str!("my_debugfs_dir"), None)?;
>
> Again, can never fail, so don't check it.
>
> > + /// let file = dir.display_file(c_str!("foo"), &200)?;
>
> Again, can never fail, so don't check it.
>
> And "200" is wrong, did you test these?

How is 200 wrong? This displays the number "200" in a file called
"foo" in the directory "my_debugfs_dir"?

>
>
> > + /// # Ok::<(), Error>(())
> > + /// ```
> > + pub fn display_file<T: Display + Sized>(
> > + &self,
> > + name: &CStr,
> > + data: &'static T,
> > + ) -> Result<ARef<Self>> {
>
> Again, will always succeed, you don't want any checking of Result<>
>
> thanks,
>
> greg k-h