Re: [PATCH 1/3] staging: panel: (coding style) Matching braces

From: Willy Tarreau
Date: Mon May 26 2014 - 10:28:40 EST


Hi Dominique,

On Wed, May 21, 2014 at 02:09:59PM +0200, Dominique van den Broeck wrote:
> Style-only modifications to comply with checkpatch.pl --strict --file.
> . Adds every missing brace in condition statements.
>
> Signed-off-by: Dominique van den Broeck <domdevlin@xxxxxxx>
> ---
> Apply on linux-next tree, above:
> commit 4151fa6adc65da14673ece623bbb2acc6936f8be
> "Add linux-next specific files for 20140516"
>
> diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
> index 136671a..1ac5e25 100644
> --- a/drivers/staging/panel/panel.c
> +++ b/drivers/staging/panel/panel.c
> @@ -711,10 +711,9 @@ static void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val)
> /* sleeps that many milliseconds with a reschedule */
> static void long_sleep(int ms)
> {
> -
> - if (in_interrupt())
> + if (in_interrupt()) {
> mdelay(ms);
> - else {
> + } else {

I don't want to be nit-picking, but since we're talking about style...
for me these "} else {" statements are harder to parse than having them
on two lines this way :

}
else {

That's especially more true with "else if" as below :

} else if (*esc >= 'A' && *esc <= 'Z') {
value |= (*esc - 'A' + 10) << shift;
} else if (*esc >= 'a' && *esc <= 'z') {
value |= (*esc - 'a' + 10) << shift;
} else {

I believe that most of the kernel code prefers the two-line format resluting
in this instead :

}
else if (*esc >= 'A' && *esc <= 'Z') {
value |= (*esc - 'A' + 10) << shift;
}
else if (*esc >= 'a' && *esc <= 'z') {
value |= (*esc - 'a' + 10) << shift;
}
else {

It's just a matter of taste I know, but for me they read easier, probably
because the braces do not affect alignment and the lines appear exactly
similar with or without the braces.

Thanks,
Willy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/