"M. Warner Losh" <[EMAIL PROTECTED]> 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 - [EMAIL PROTECTED]
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to