Ending the list_t scourge
[Posted September 4, 2002 by corbet]
Most people who dig through the kernel source eventually run into
struct list_head, the structure used for the management of
generic, doubly-linked lists in the kernel. The kernel list implementation
has some interesting features, including the fact that every entry in the
list is a "list head." The lists are circular, and no one node is special.
Recently, a typedef (list_t) was added as an equivalent name for
the list_head structure; rumor has it Ingo Molnar added the name
to help keep his source lines within 80 columns. One would think that
people would not get overly worked up about this addition, but this
is the kernel hacker community we are dealing with. The prevailing
opinion among kernel hackers has swung strongly against typedef in
recent times. Use of typedef is seen as a useless hiding of
information that programmers need to see. Defined types also complicate
include file dependencies. Structures can be "predeclared" with a line
like:
struct my_struct;
and references to that structure (pointers, in particular) can be used as
long as the internals of the structure are not accessed. Defined types can
not be predeclared in this way, making it harder to mix mutually-dependent
types across files.
So Rusty Russell posted a patch which removes
list_t from the kernel. Nobody really complained about that
change, but some wondered: why not rename the list_head structure
to struct list at the same time. As William Irwin rather
graphicly put it: "Throw the whole frog
in the blender, please, not just half."
In the end, a big renaming of struct list_head throughout the
kernel tree (and external code) wasn't to most peoples' taste. And Linus
isn't into blended frogs. So the patch
removing list_t went into Linus's BitKeeper tree (and will be in
2.5.34), but struct list_head remains.
(
Log in to post comments)