Tool for automatic style of coding guidelines
Hi I have developed some kernel drivers and would like to send the patches for review. But i find that I have not followed the coding guideline for tabs and spaces properly, which can be easily corrected by using some tools like astyle. Can any body please help me with the proper commands string for the astyle tool? Or could any body please suggest me with any new tool like indent etc which you are using -- Regards, Prajosh Premdas
Hi Prajosh, On Fri, Jan 27, 2012 at 1:20 PM, Prajosh Premdas <premdas.prajosh@gmail.com> wrote:
Hi
I have developed some kernel drivers and would like to send the patches for review. But i find that I have not followed the coding guideline for tabs and spaces properly, which can be easily corrected by using some tools like astyle.
Can any body please help me with the proper commands string for the astyle tool? Or could any body please suggest me with any new tool like indent etc which you are using
there is a script called checkpatch.pl in the srcipts/ subdirectory. It will show you the problems with your code style among other things. The kernel maintainers strongly suggest to use the script before posting any patches so that any major (style) flaws like indent etc. can be fixed before posting the patch to the mailing list. Hope this helps! Philipp O
On Fri, Jan 27, 2012 at 9:18 AM, Philipp Ittershagen <p.ittershagen@googlemail.com> wrote:
Hi Prajosh,
On Fri, Jan 27, 2012 at 1:20 PM, Prajosh Premdas <premdas.prajosh@gmail.com> wrote:
Hi
I have developed some kernel drivers and would like to send the patches for review. But i find that I have not followed the coding guideline for tabs and spaces properly, which can be easily corrected by using some tools like astyle.
Can any body please help me with the proper commands string for the astyle tool? Or could any body please suggest me with any new tool like indent etc which you are using
there is a script called checkpatch.pl in the srcipts/ subdirectory. It will show you the problems with your code style among other things. The kernel maintainers strongly suggest to use the script before posting any patches so that any major (style) flaws like indent etc. can be fixed before posting the patch to the mailing list.
Hope this helps!
Philipp
And don't forget it has various options (see checkpatch -h). One is "-f" which allows you to check a normal source file, not a patch. BUT, can checkpatch actually modify the files? I think I've only used it to identify issues, not resolve them. Greg
On Fre, 2012-01-27 at 13:55 -0500, Greg Freemyer wrote: [...]
BUT, can checkpatch actually modify the files? I think I've only used it to identify issues, not resolve them.
Yup, and one wants actually no automatic repair in general because the main goal of (the) coding style guide(s) is to keep a common "layout" so that the code is easily readable and understandable and *not* to follow some hard-coded rules. Yes, for "spaces to tabs" one can do that (and actually emacsens can do it with "indent-region" etc. without much hassle and it shouldn't be that hard with global-find-and-replace in any decent editor). So it's OK to "break" rules if the source gets obscured by following it. The prime example is probably the line length where it doesn't get better in any way (au contraire IMHO - it gets much worse) if printk("this is a very long format string and it is here for good reason"); is split on 2 lines. And if (some_condition) x = 1; else { x = 4711; y = 45; } also hurts my eyes. Bernd -- Bernd Petrovitsch Email : bernd@petrovitsch.priv.at LUGA : http://www.luga.at
On Fri, Jan 27, 2012 at 05:50:30PM +0530, Prajosh Premdas wrote:
Hi
I have developed some kernel drivers and would like to send the patches for review. But i find that I have not followed the coding guideline for tabs and spaces properly, which can be easily corrected by using some tools like astyle.
Can any body please help me with the proper commands string for the astyle tool? Or could any body please suggest me with any new tool like indent etc which you are using
scripts/Lindent will give you a good start, but odds are you really want to do this by hand, it will be easier in the end as indent can do some strange things at times. good luck, greg k-h
On Fri, Jan 27, 2012 at 11:45 PM, Greg KH <greg@kroah.com> wrote:
On Fri, Jan 27, 2012 at 05:50:30PM +0530, Prajosh Premdas wrote:
Hi
I have developed some kernel drivers and would like to send the patches for review. But i find that I have not followed the coding guideline for tabs and spaces properly, which can be easily corrected by using some tools like astyle.
Can any body please help me with the proper commands string for the astyle tool? Or could any body please suggest me with any new tool like indent etc which you are using
scripts/Lindent will give you a good start, but odds are you really want to do this by hand, it will be easier in the end as indent can do some strange things at times.
good luck,
greg k-h
You can see this excellent video [1] where Greg has explained how to submit your first patch. [1] http://www.youtube.com/watch?v=LLBrBBImJt4 Regards, Adil
Thanks for the suggestions and video links Got the patches clean for review On Sun, Jan 29, 2012 at 12:05 AM, Adil Mujeeb <mujeeb.adil@gmail.com> wrote:
On Fri, Jan 27, 2012 at 11:45 PM, Greg KH <greg@kroah.com> wrote:
On Fri, Jan 27, 2012 at 05:50:30PM +0530, Prajosh Premdas wrote:
Hi
I have developed some kernel drivers and would like to send the patches for review. But i find that I have not followed the coding guideline for tabs and spaces properly, which can be easily corrected by using some tools like astyle.
Can any body please help me with the proper commands string for the astyle tool? Or could any body please suggest me with any new tool like indent etc which you are using
scripts/Lindent will give you a good start, but odds are you really want to do this by hand, it will be easier in the end as indent can do some strange things at times.
good luck,
greg k-h
You can see this excellent video [1] where Greg has explained how to submit your first patch.
[1] http://www.youtube.com/watch?v=LLBrBBImJt4
Regards, Adil
-- Regards, Prajosh Premdas
participants (6)
-
Adil Mujeeb -
Bernd Petrovitsch -
Greg Freemyer -
Greg KH -
Philipp Ittershagen -
Prajosh Premdas