lkml.org 
[lkml]   [2000]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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/

\
 
 \ /
  Last update: 2005-03-22 13:57    [W:0.236 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site