Subject: Re: tape drive instrumentation round 2
To: None <>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 03/06/2006 13:41:39
> dk->dk_iostats = blah;

> Which, to me, looks redundant compared to:

> dk->iostats = blah;

It is.

But it brings benefits.  One has already been mentioned (greppability);
another is namespace separation.  Consider:

	struct disk {
		union {
			struct foo dku_foo;
			struct bar dku_bar;
		} u;
	#define dk_foo u.dku_foo
	#define dk_bar u.dku_bar

as compared to

	struct disk {
		union {
			struct foo u_foo;
			struct bar u_bar;
		} u;
	#define foo u.u_foo
	#define bar u.u_bar

They look the same, maybe - until you see

	 int foo;

Of course, if you do add the prefix for nested members like this, you
usually want to do it for all the other members as well for uniformity.

Arguably this particular example would better be done with a
transparent union, but not all examples are that easy to patch up.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B