Re: [PATCH] CodingStyle: Add a chapter on conditional compilation

From: Joe Perches
Date: Mon Nov 03 2014 - 13:39:27 EST


On Mon, 2014-11-03 at 10:05 -0800, Josh Triplett wrote:
> On Mon, Nov 03, 2014 at 09:47:40AM -0800, Joe Perches wrote:
[]
> "don't put an else after an if condition
> ending with break or return;

Maybe that's a bit _too_ simple.
Yes for a simple if, but not necessarily an else if

if (foo) {
...;
} else if (bar) {
more code...;
return;
} else {
...
}

still needs that last else.

checkpatch isn't very good at that code flow
interpretation so it emits a warning anyway.

> > Another thing that could go is the suggestion to
> > use Lindent.
> >
> > https://lkml.org/lkml/2013/2/11/390
>
> Agreed completely. We might consider coming up with settings for
> clang-format, which seems like a far more capable replacement that
> actually understands C.

Never used it.
It does seem to have a large number of options
(including a trivial linux-kernel style) though.

http://clang.llvm.org/docs/ClangFormatStyleOptions.html

Dunno how much work it would be to create a proper
linux-kernel style for clang-format.

It might work well, it might not.
Anyone have experience with it?


--
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/