Re: [patch]clarification of coding style regarding conditional statements with two branches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jiri Slaby <[email protected]> writes:

> Why, what's wrong with
> if (condition) {
> 	do_this();
> 	do_that();
> } else
> 	otherwise();
>
> ? It's more readable/nicer in my eyes than

I think so. And it means less lines #.

>> +if (condition) {
>> +	do_this();
>> +	do_that();
>> +} else {
>> +	otherwise();
>> +}

Exception:

if (x) {
	if (y)
		foo1();
	else
		foo2();
} else
	bar();

The braces after if(x) are needed so nobody thinks it's:

if (x)
	if (y)
		foo1();
else
	foo2();
else
	bar();

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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux