Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Nov 2008 19:22:03 +0100
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        "M. Warner Losh" <imp@bsdimp.com>
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, ivoras@gmail.com
Subject:   Re: svn commit: r185356 - head/sys/dev/ixgbe
Message-ID:  <86ej0x112s.fsf@ds4.des.no>
In-Reply-To: <20081127.105534.188222755.imp@bsdimp.com> (M. Warner Losh's message of "Thu, 27 Nov 2008 10:55:34 -0700 (MST)")
References:  <9bbcef730811270220h1a7f812k2ba340737132ff82@mail.gmail.com> <8663m94g30.fsf@ds4.des.no> <9bbcef730811270238k61c3e59fqee7715f017d70ccf@mail.gmail.com> <20081127.105534.188222755.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
"M. Warner Losh" <imp@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 =3D (struct sockaddr_in *)sa;
                /* ... */
                break;
        }
        case AF_INET6: {
                struct sockaddr_in6 *sin6 =3D (struct sockaddr_in6 *)sa;
                /* ... */
                break;
        }
        case AF_UNIX: {
                /* you get the idea */
        }
        default:
                /* ... */
        }
}

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86ej0x112s.fsf>