On Mon, 31 Oct 2011, Alexey Dokuchaev wrote:

On Sun, Oct 30, 2011 at 09:17:42PM +0000, Marius Strobl wrote:
Log:
  - Use device_t rather than the NetBSDish struct device.

Hmm, I though that style(9) advises against this practice:

   Avoid using typedefs for structure types.  Typedefs are problematic
   because they do not properly hide their underlying type; [...]

   When convention requires a typedef, make its name match the struct tag.
   Avoid typedefs ending in _t, except as specified in Standard C or by
   POSIX.

Does these rules not apply for struct device for some reason?

Yes (they don't apply here).  device_t is one of a few properly opaque
typedefs for struct pointers.  'struct device' is only (completely)
declared in kern/subr_bus.c.  Thus the implementation details of it
obviously cannot escape to drivers.  Most of the APIs in <sys/bus.h>
are supposed to be like this.  But `typedef struct kobj_class driver_t'
and `#define driver_method_t kobj_method_t' are gross exceptions.
<sys/bus.h> has to include <sys/kobj.h> for dereferencing these, and
kobj.h breaks the rule by providing both typedefs for struct pointers
and complete struct declarations.

Bruce
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to