More coding style stuff. This time from commit r357:

[...]
    switch (data[0])
    {
    case TUX_CONNECTION_DISCONNECT:
        if (disconnect_from_tux() >= 0)
            result[1] = TUX_CONNECTION_ACK;
        else
            result[1] = TUX_CONNECTION_NACK;
        break;
    case TUX_CONNECTION_CONNECT:
    {
        union_uint16_t id;
        id.b[1] = data[1];
        id.b[0] = data[2];
        printf("coucou\n");
        if (connect_to_tux(id.w) >= 0)
            result[1] = TUX_CONNECTION_ACK;
        else
            result[1] = 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() >= 0)
            result[1] = TUX_CONNECTION_ACK;
        else
            result[1] = TUX_CONNECTION_NACK;
        break;
    case TUX_CONNECTION_CONNECT:
        {
            union_uint16_t id;

            id.b[1] = data[1];
            id.b[0] = data[2];

            printf("coucou\n");

            if (connect_to_tux(id.w) >= 0)
                result[1] = TUX_CONNECTION_ACK;
            else
                result[1] = 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

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
tux-droid-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-user

Reply via email to