lkml.org 
[lkml]   [2022]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [RFC PATCH v1 1/2] list: add type-safer list_head wrapper
On Thu, Mar 10, 2022 at 5:33 PM Barnabás Pőcze <pobrn@protonmail.com> wrote:
>
> The underlying idea is to define each list head using an anonymous struct:

Why struct? Union is much better, and doesn't pointlessly waste memory
for members that are only used for their type.

Anyway, as far as I can tell, your model is unworkable as-is, since it
only works for a list that is external to the types in question.

Which is not even remotely the interesting case. All serious list uses
are inside other types, and refer to each other.

So this seems to be fundamentally broken, in that it only works for
trivial things, and is not even as good as

https://lore.kernel.org/all/CAHk-=wiacQM76xec=Hr7cLchVZ8Mo9VDHmXRJzJ_EX4sOsApEA@mail.gmail.com/

that actually converted a real case.

That one didn't do the automatic offset thing, but see

https://lore.kernel.org/all/CAADWXX-Pr-D3wSr5wsqTEOBSJzB9k7bSH+7hnCAj0AeL0=U4mg@mail.gmail.com/

on the problems that has.

Again, you avoided those problems by making the use-case a narrow and
uninteresting one.

Linus

\
 
 \ /
  Last update: 2022-03-11 02:43    [W:0.263 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site