4 ms·
I am glad that for Go there is `go fmt` which predefines some of the issues mentioned in the article. Thus there is "one global coding style for Go". It's anoth
by patrickg 12y ago
I am glad that for Go there is `go fmt` which predefines some of the issues mentioned in the article. Thus there is "one global coding style for Go". It's another matter if one likes it or not.
- Dewie 12y agoI don't see why there couldn't be a `kernel fmt` tool. In this day and age, we should really be beyond having to worry about things like hmm, what was the brace style in this project again, and should all if/while/for have mandatory braces?.
- DSMan195276 12y agoThe kernel has a perl script called 'checkpatch.pl'[0] which can check if code is formatted correctly. The Kernel coding style isn't actually enforced 100% though, which makes it a bit more iffy. Not all the code in the kernel actually follows the same style (IIRC, there's at least one sub-system that uses a slightly different style, I think 'net' maybe?), and so 'checkpatch' is recommended but may not be the be-all end-all in every situation. [0] https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl https://github.com/torvalds/linux/blob/master/scripts/checkp...
- qznc 12y agoThat would be "astyle --style=linux" for example.
- maxlybbert 12y agoOr lindent, which I think is mentioned in the kernel style guide (it's a shell script that calls indent with set parameters).
- dezgeg 12y agoSadly, running Lindent on almost any existing source file in the tree will produce dozens of spurious diff hunks due to most other people manually formatting their code, so Lindent is quite useless in practice. It really does bother me how much of the coders' and code reviewers' bandwidth in the kernel community is wasted due to these silly formatting issues. In most IDE-using communities these problems were solved a long time ago, by the IDE autoreformatting your code on commit, with no exceptions.
- qznc 12y agoLinus could easily do "lindent reformat" commit every once in a while or even automate it. It seems they do not care that much for the styleguide?
- adestefan 12y agoLinus shuns commits that do nothing by reformat code. However, if you go in and make a change, then you'll probably get marked down by the maintainer if you don't fix up the formatting at that time.