Thursday, April 17, 2014

Removing CamelCase warnings in code given by checkpatch.pl

Before pushing you kernel code to GIT you need to make the code error and warning free.There are some standard scripts in linux kernel repository to point out the errors and warnings.One of them is checkpatch.pl script.

My shell scripts will try to clean some of these pointed error and warnings.

Here's my first script to remove CamelCase from kernel code.

Please refer to the link for details on CamelCase: http://en.wikipedia.org/wiki/CamelCase

Shell Script for removing CamelCase from code:

#!/bin/bash
#Here, arg#1 is string whose CamelCase needs to be removed.
#arg2 is the file in which CamelCase needs to be removed.
var1=$1
var2=$(echo $var1 | tr [:upper:] [:lower:])
sed -i "s/\<$var1\>/$var2/g" $2

Above scripts actually converts the CamelCases in your file to lower cases so you will not get any warning now with checkpatch.pl

2 comments: