Re: [broken] Re: [patch-2.4.0-test5-pre3] struct inode shortened

From: Linus Torvalds (torvalds@transmeta.com)
Date: Tue Jul 25 2000 - 21:19:19 EDT

  • Next message: Mark Gray: "Re: Capabilities.."

    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/



    This archive was generated by hypermail 2b29 : Tue Jul 25 2000 - 21:36:53 EDT