Messages in this thread | | | From | Linus Torvalds <> | Date | Thu, 10 Mar 2022 17:42:34 -0800 | Subject | Re: [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
| |