If clang format uses the compiler front end core libraries to parse and reformat (like it seems), than it is clearly better than a Perl script with regexes. But with checkpatch you can check your very own commit diff, while clang format would bark on the whole file(s). So to use that, you would need to apply clang format to the whole code base, to avoid your one liner patch to be barked upon, for unrelated format failures in the touched source files.
On Fri, Jan 29, 2016 at 9:29 AM, ron minnich <[email protected]> wrote: > Checkpatch has been a valuable tool but it has a fundamental limitation: > it attempts to parse a CFG with REs[1]. It's not happy accepting things > that are known to work. I did a little digging ... > > Here's one exchange: > "On Wed, Feb 22, 2012 at 11:21:44AM +0000, Andy Whitcroft wrote:> On Tue, > Feb 21, 2012 at 01:10:06AM +0530, Pradheep Shrinivasan wrote: > > > > Are you asking me if I'm going to NAK your patch? No. It's an > > > > unfortunate thing. Checkpatch.pl is going around telling people to > > > > add bogus parenthesis everywhere, and no one likes to redo their > > > > patches. And I feel like a jerk for telling people that they should > > > > redo their patches. And checkpatch.pl is a robot which has more > > > > energy than I do. > > > > In theory the number of things it gets right outweigh the things it gets > > wrong and you do save energy overall." > > or: > > "yeah, that's true, and we always just ignore checkpatch complaints when > it comes to TRACE_EVENT macros." > > I'm beginning to realize that checkpatch is great when you're checking > code *that's almost already in style*, and you have a good idea which > errors to ignore. Importing code from other kernels is not as smooth: I'm > importing the RNG code from Harvey, which started in BSD, and I'm seeing > bogus warnings. > > It was a very valuable tool for a long time but better alternatives exist: > true parsers that format code in a way we like automatically. > > Here's a clang-format file that fixed around a 1000 checkpatch.pl issues > with the fortuna/rijndael/devrandon RNG from Harvey. > > BasedOnStyle: LLVM > IndentWidth: 8 > UseTab: Always > BreakBeforeBraces: Linux > AllowShortIfStatementsOnASingleLine: false > IndentCaseLabels: false > > I'd like to propose we move to clang-format and get out of the business of > hand-formatting code based on checkpatch.pl. The clang-format step could > be a precommit hook. > > ron > [1] boiler plate CS impressive CS reference showing why you can't really > parse a CFG with REs: http://www.dfki.de/compling/pdfs/cfg-slides.pdf > > -- > You received this message because you are subscribed to the Google Groups > "Akaros" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
