mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* anon unions are cool
@ 2006-01-23  0:36 Albert Cahalan
  2006-01-23  0:56 ` Kyle Moffett
  0 siblings, 1 reply; 6+ messages in thread
From: Albert Cahalan @ 2006-01-23  0:36 UTC (permalink / raw)
  To: linux-kernel

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;
};

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-01-24  6:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-23  0:36 anon unions are cool Albert Cahalan
2006-01-23  0:56 ` Kyle Moffett
2006-01-23  1:17   ` Albert Cahalan
2006-01-23 18:25     ` Eric W. Biederman
2006-01-24  3:39       ` Albert Cahalan
2006-01-24  6:04         ` Kyle Moffett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®