Re: [PATCH v2 1/4] rust: debugfs: Bind DebugFS directory creation

From: Miguel Ojeda
Date: Thu May 01 2025 - 06:01:32 EST


On Thu, May 1, 2025 at 1:32 AM Matthew Maurer <mmaurer@xxxxxxxxxx> wrote:
>
> +// INVARIANT: The wrapped pointer will always be NULL, an error, or an owned DebugFS `dentry`

We do it the other way around, i.e. `# Invariants` section for the
type, and `// INVARIANT: ...` comments for the places that ensure the
type invariant.

+ /// // parent exists in DebugFS here.

Parent ...

> + // * If parent is None, parent accepts null pointers to mean create at root
> + // * If parent is Some, parent accepts live dentry debugfs pointers

`None`, `Some` (also please end sentences with periods)

> + /// Returns the pointer representation of the DebugFS directory.
> + ///
> + /// # Invariant
> + ///
> + /// The value returned from this function will always be an error code, NUL, or a live DebugFS

Hmm... so far we use `# Invariants` only for types. Perhaps you could
say something like "Thanks to the type invariant, the return value
will always be ..."

`NULL`?

Thanks!

Cheers,
Miguel