Re: typedefs and structs [was Re: [PATCH 16/42]: PCI: PCI Errorreporting callbacks]

From: Steven Rostedt
Date: Mon Nov 07 2005 - 20:12:45 EST


On Mon, 2005-11-07 at 14:41 -0600, linas wrote:

>
> > > Also, "grep typedef include/linux/*" shows that many kernel device
> > > drivers use this convention.
> >
> > They are wrong and should be fixed.
>
> What, precisely, is wrong?

I can't seem to find it on google, but IIRC Linus stated that he didn't
want any more structures defined with typedefs. If it is a structure,
simple keep it one, and don't use typedef to get rid of "struct".

This was for the simple reason, too many developers were passing
structures by value instead of by reference, just because they were
using a type that they didn't realize was a structure. And to make
things worse, these structures started to get bigger.

So in my every day programming, I switched to not typedef structures
anymore, and I even found some places that I passed structures by value
when it would have been much more efficient by reference.

The only exceptions that I can see where you typedef a structure is for
use with arch dependent types, like atomic_t.

-- Steve


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/