Re: [PATCH v2 1/8] rust: fs: add file::Offset type alias

Danilo Krummrich
2025-10-21T15:26:33Z

On Tue Oct 21, 2025 at 5:08 PM CEST, Miguel Ojeda wrote:
> On Tue, Oct 21, 2025 at 12:27 AM Danilo Krummrich <dakr@kernel.org> wrote:
>>
>> Add a type alias for file offsets, i.e. bindings::loff_t. Trying to
>> avoid using raw bindings types, this seems to be the better alternative
>> compared to just using i64.
>
> Would a newtype be too painful?
>
> Note: I didn't actually check if it is a sensible idea, but when I see
> an alias I tend to ask myself that so it would be nice to know the
> pros/cons (we could ideally mention why in the commit message in cases
> like this).

Yeah, I don't think there's any value making this a new type in this case. There
are no type invariants, useful methods, etc.

In fact, not even the type alias is strictly needed, as i64 would be sufficient
as well.

The main motivation for the type alias is that I think i64 is not super
intuitive for an offset value (people would rather expect usize or isize) and
it's nice to not have bindings::loff_t exposed to driver APIs.