anon unions are cool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now that the kernel requires a compiler that
supports anonymous unions, we can do some
really neat stuff.

For example, suppose we wanted to rename
a badly-named struct member. If the struct is
used all over the kernel, this becomes a giant
project with huge potential for patch conflicts.

Anonymous unions solve this. First, we replace
the badly-named struct member with an anonymous
union containing both the old name and the new
name. Second, we change much of the kernel
to use the new name. Third, we mark the old name
with the __depricated tag to generate warnings.
Fourth, we get the stragglers over days or months.
Fifth, we get rid of the anonymous union by replacing
it with the new name.

The struct evolves like so:

struct a {
  int foo;
  int bad;
  int bar;
};

struct a {
  int foo;
  union {
    int bad;
    int baz;
  };
  int bar;
};

struct a {
  int foo;
  union {
    int __deprecated bad;
    int baz;
  };
  int bar;
};

struct a {
  int foo;
  int baz;
  int bar;
};
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux