From: Daniel Almeida <daniel.almeida@collabora.com>
To: Andreas Hindborg <a.hindborg@kernel.org>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Joel Becker" <jlbec@evilplan.org>,
"Christoph Hellwig" <hch@lst.de>,
"Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>, "Will Deacon" <will@kernel.org>,
"Waiman Long" <longman@redhat.com>,
"Fiona Behrens" <me@kloenk.dev>,
"Charalampos Mitrodimas" <charmitro@posteo.net>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/4] rust: configfs: introduce rust support for configfs
Date: Tue, 25 Feb 2025 10:01:55 -0300 [thread overview]
Message-ID: <FD609CD0-D3A1-47D5-8D5C-E8DB57003932@collabora.com> (raw)
In-Reply-To: <8734g2w6ka.fsf@kernel.org>
>
>>
>>>
>>> [...]
>>>
>>>>> +
>>>>> +/// # Safety
>>>>> +///
>>>>> +/// `this` must be a valid pointer.
>>>>> +///
>>>>> +/// If `this` does not represent the root group of a `configfs` subsystem,
>>>>> +/// `this` must be a pointer to a `bindings::config_group` embedded in a
>>>>> +/// `Group<Parent>`.
>>>>> +///
>>>>> +/// Otherwise, `this` must be a pointer to a `bindings::config_group` that
>>>>> +/// is embedded in a `bindings::configfs_subsystem` that is embedded in a
>>>>> +/// `Subsystem<Parent>`.
>>>>> +unsafe fn get_group_data<'a, Parent>(this: *mut bindings::config_group) -> &'a Parent {
>>>>> + // SAFETY: `this` is a valid pointer.
>>>>> + let is_root = unsafe { (*this).cg_subsys.is_null() };
>>>>> +
>>>>> + if !is_root {
>>>>> + // SAFETY: By C API contact, `this` is a pointer to a
>>>>> + // `bindings::config_group` that we passed as a return value in from
>>>>> + // `make_group`. Such a pointer is embedded within a `Group<Parent>`.
>>>>
>>>> This phrase is confusing.
>>>
>>> I am not sure how to rephrase it to be less confusing. The pointer is
>>> the thing returned from `make_group`. `make_group` would only return a
>>> pointer into a `Group<Parent>`.
>>
>> The problem is this: "that we passed as a return value in from”, to pass something as a return value
>> is already hard to parse, and when you reach the “in from” part, it becomes even harder.
>>
>> Just say a variation of what you said above, that is perfectly understandable.
>>
>> What about:
>>
>> ```
>>
>> `this` is a pointer to a `bindings::config_group` that was returned from a call to `make_group`. The pointer is known
>> to be embedded within a `Group<Parent>`.
>>
>> ```
>
> How is this:
>
> // SAFETY: By C API contact,`this` was returned from a call to
> // `make_group`. The pointer is known to be embedded within a
> // `Group<Parent>`.
>
This is good.
— Daniel
next prev parent reply other threads:[~2025-02-25 13:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 13:21 [PATCH v4 0/4] rust: configfs abstractions Andreas Hindborg
2025-02-24 13:21 ` [PATCH v4 1/4] rust: sync: change `<Arc<T> as ForeignOwnable>::PointedTo` to `T` Andreas Hindborg
2025-02-24 21:22 ` Daniel Almeida
2025-02-24 13:21 ` [PATCH v4 2/4] rust: configfs: introduce rust support for configfs Andreas Hindborg
2025-02-24 22:30 ` Daniel Almeida
2025-02-25 10:11 ` Andreas Hindborg
2025-02-25 10:53 ` Daniel Almeida
2025-02-25 12:29 ` Andreas Hindborg
2025-02-25 13:01 ` Daniel Almeida [this message]
2025-02-24 13:21 ` [PATCH v4 3/4] rust: configfs: add a sample demonstrating configfs usage Andreas Hindborg
2025-02-25 9:37 ` Daniel Almeida
2025-02-25 10:23 ` Andreas Hindborg
2025-02-25 10:58 ` Daniel Almeida
2025-02-24 13:21 ` [PATCH v4 4/4] MAINTAINERS: add entry for configfs Rust abstractions Andreas Hindborg
2025-02-25 9:38 ` Daniel Almeida
2025-02-24 16:55 ` [PATCH v4 0/4] rust: configfs abstractions Daniel Almeida
2025-02-24 19:12 ` Andreas Hindborg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=FD609CD0-D3A1-47D5-8D5C-E8DB57003932@collabora.com \
--to=daniel.almeida@collabora.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=charmitro@posteo.net \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=hch@lst.de \
--cc=jlbec@evilplan.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=me@kloenk.dev \
--cc=mingo@redhat.com \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).