Date: Fri, 28 Nov 2008 20:59:05 +1100 (EST) From: Bruce Evans <brde@optusnet.com.au> To: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, ivoras@gmail.com, "M. Warner Losh" <imp@bsdimp.com> Subject: Re: svn commit: r185356 - head/sys/dev/ixgbe Message-ID: <20081128204657.H1116@besplex.bde.org> In-Reply-To: <86ej0x112s.fsf@ds4.des.no> References: <9bbcef730811270220h1a7f812k2ba340737132ff82@mail.gmail.com> <8663m94g30.fsf@ds4.des.no> <9bbcef730811270238k61c3e59fqee7715f017d70ccf@mail.gmail.com> <20081127.105534.188222755.imp@bsdimp.com> <86ej0x112s.fsf@ds4.des.no>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 27 Nov 2008, [utf-8] Dag-Erling Smørgrav wrote:
> "M. Warner Losh" <imp@bsdimp.com> writes:
>> 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;
> }
Switch statements are 1 case (the only case?) where the braces needed for
non-C99 declarations don't require extra indentation. However, indent(1)
doesn't understand this and mangles the above to:
int
foo(struct sockaddr *sa)
{
switch (s->sa_family) {
case AF_INET:{
struct sockaddr_in *sin = (struct sockaddr_in *)sa;
/* ... */
break;
}
indent(1) has fixed a style bug in the above (the missing blank line after
the declarations) but it has introduced 2 (the missing space before "{"
and the unwanted indentation). Fixing the other style bug in the above
(the initialization in the declaration) is beyond the scope of indent(1).
gindent-2.2.9 -npro gives the same style bugs and 1 more (it misformats
the comment to a block one, but that may be due to a bad default).
Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081128204657.H1116>
