Re: [tuxdroid-user] Daemon to USB connection
Status: Beta
Brought to you by:
ks156
From: David B. <da...@ja...> - 2007-06-11 15:31:02
|
On Fri, 08 Jun 2007 20:06:46 +0200, neimad <ror...@gm...> wrote= : > > More coding style stuff. This time from commit r357: > > [...] > switch (data[0]) > { > case TUX_CONNECTION_DISCONNECT: > if (disconnect_from_tux() >=3D 0) > result[1] =3D TUX_CONNECTION_ACK; > else > result[1] =3D TUX_CONNECTION_NACK; > break; > case TUX_CONNECTION_CONNECT: > { > union_uint16_t id; > id.b[1] =3D data[1]; > id.b[0] =3D data[2]; > printf("coucou\n"); > if (connect_to_tux(id.w) >=3D 0) > result[1] =3D TUX_CONNECTION_ACK; > else > result[1] =3D TUX_CONNECTION_NACK; > break; > } > case TUX_CONNECTION_ID_REQUEST: > [...] > > I can't agree with the block indentation in TUX_CONNECTION_CONNECT: > the curly braces are at the same depth as the switch's braces, which > is badly readable. > > I'd indent it as follows: > > [...] > switch (data[0]) > { > case TUX_CONNECTION_DISCONNECT: > if (disconnect_from_tux() >=3D 0) > result[1] =3D TUX_CONNECTION_ACK; > else > result[1] =3D TUX_CONNECTION_NACK; > break; > case TUX_CONNECTION_CONNECT: > { > union_uint16_t id; > > id.b[1] =3D data[1]; > id.b[0] =3D data[2]; > > printf("coucou\n"); > > if (connect_to_tux(id.w) >=3D 0) > result[1] =3D TUX_CONNECTION_ACK; > else > result[1] =3D TUX_CONNECTION_NACK; > } > break; > > case TUX_CONNECTION_ID_REQUEST: > [...] > > (Note that I also spaced things out, most notably the variable > declaration, but that's another topic ;-)) > > The block is a sub-block of the switch()'s block and as such must be > indented. Yes, as a consequence the code within this case is indented > one depth level more than the code in other, block-less cases, but > that's a small price to pay for increased readability. > > I also moved the closing brace *before* the break, as in my view all > the code in a case should appear before the break (unless, of course > there are several places where break appears) just like in the > block-less cases. > > This last point is debatable, but I think the indentation level should= > *really* be as I pointed out above :-) > > Damien, coding-style integrist I was a bit surprised at the beginning, not being used to get switch and= = case on the same level. I must admit I didn't know what to do with the = curly braces. I changed in my code, it'll be soon on svn. Thanks for keeping attention= = to my commits :-) vi lovers can use that option to indent switch statements that way: :set cino=3D:0 David |