Messages in this thread | | | Date | Tue, 25 Jul 2000 18:19:19 -0700 (PDT) | From | Linus Torvalds <> | Subject | Re: [broken] Re: [patch-2.4.0-test5-pre3] struct inode shortened |
| |
On Wed, 26 Jul 2000, Jamie Lokier wrote: > > 1. Make the name explicit: inode->i_union->bdev. > > 2. Change all the code that refers to the newly unioned fields. > It should be clear from the name i_union that no code should > read a field until it knows the type of the inode. > > 3. Do something similar for struct page. At least that would > remove the ugly overloading of page->next_hash fields on the Sparc.
I hate unions that have to do it this way.
Unions are imho only acceptable when they implicitly know their own type. The in-kernel example of this is the inode per-filesystem thing. An inode has a filesystem-specific part, and there is no way any other filesystem can access it except by a major bug somewhere.
Any union that needs code like
if (xxx->type == yyy).. ....
is a design mistake.
I don't think you'll find all that many unions in Linux. And I don't think we should add new ones..
Linus
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |