svn commit: r185356 - head/sys/dev/ixgbe

Dag-Erling Smørgrav des at des.no
Thu Nov 27 10:22:05 PST 2008


"M. Warner Losh" <imp at bsdimp.com> writes:
> This is a K&R level C construct.
>
> It is discouraged in style(9) because it makes it hard to find
> declarations.  However, it is used in the kernel in a number of
> places.
>
> I personally really dislike the style (and yes, I know all the
> arguments for it).  If you really want something that complex inside a
> block to need block scoped variables, then that really argues for a
> function oft times...

There is one particular situation where it is very convenient:

int
foo(struct sockaddr *sa)
{
        switch (s->sa_family) {
        case AF_INET: {
                struct sockaddr_in *sin = (struct sockaddr_in *)sa;
                /* ... */
                break;
        }
        case AF_INET6: {
                struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa;
                /* ... */
                break;
        }
        case AF_UNIX: {
                /* you get the idea */
        }
        default:
                /* ... */
        }
}

DES
-- 
Dag-Erling Smørgrav - des at des.no


More information about the svn-src-head mailing list