Merge pull request #1890 from LabNConsulting/working/master/checkpatch1

checkpatch minor tweaks
This commit is contained in:
Quentin Young 2018-03-16 23:20:01 -04:00 committed by GitHub
commit db4629b81f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 24 deletions

View File

@ -1249,11 +1249,6 @@ sub sanitise_line {
$res =~ s@(\#\s*(?:error|warning)\s+).*@$1$clean@; $res =~ s@(\#\s*(?:error|warning)\s+).*@$1$clean@;
} }
if ($allow_c99_comments && $res =~ m@(//.*$)@) {
my $match = $1;
$res =~ s/\Q$match\E/"$;" x length($match)/e;
}
return $res; return $res;
} }
@ -3612,14 +3607,19 @@ sub process {
# no C99 // comments # no C99 // comments
if ($line =~ m{//}) { if ($line =~ m{//}) {
if (ERROR("C99_COMMENTS", if (!$allow_c99_comments) {
"do not use C99 // comments\n" . $herecurr) && if(ERROR("C99_COMMENTS",
$fix) { "do not use C99 // comments\n" . $herecurr) &&
my $line = $fixed[$fixlinenr]; $fix) {
if ($line =~ /\/\/(.*)$/) { my $line = $fixed[$fixlinenr];
my $comment = trim($1); if ($line =~ /\/\/(.*)$/) {
$fixed[$fixlinenr] =~ s@\/\/(.*)$@/\* $comment \*/@; my $comment = trim($1);
$fixed[$fixlinenr] =~ s@\/\/(.*)$@/\* $comment \*/@;
}
} }
} else {
WARN("C99_COMMENTS",
"C99 // comments do not match recommendation\n" . $herecurr);
} }
} }
# Remove C99 comments. # Remove C99 comments.

View File

@ -8,6 +8,8 @@ ignore="ldpd\|babeld"
cwd=${PWD##*/} cwd=${PWD##*/}
dirty=0 dirty=0
stat=0 stat=0
tmp1=/tmp/f1-$$
tmp2=/tmp/f2-$$
if [[ -z "$1" || -z "$2" ]]; then if [[ -z "$1" || -z "$2" ]]; then
echo "$usage" echo "$usage"
@ -15,7 +17,7 @@ if [[ -z "$1" || -z "$2" ]]; then
fi fi
# remove temp directories # remove temp directories
rm -rf /tmp/f1 /tmp/f2 rm -rf ${tmp1} ${tmp2}
# save working tree # save working tree
if git -C $tree status --porcelain | egrep --silent '^(\?\?|.[DM])'; then if git -C $tree status --porcelain | egrep --silent '^(\?\?|.[DM])'; then
@ -38,7 +40,7 @@ fi
git -C $tree reset --hard git -C $tree reset --hard
git -C $tree apply < $patch git -C $tree apply < $patch
mkdir -p /tmp/f1 /tmp/f2 mkdir -p ${tmp1} ${tmp2}
mod=$(git -C $tree ls-files -m | grep ".*\.[ch]" | grep -v $ignore) mod=$(git -C $tree ls-files -m | grep ".*\.[ch]" | grep -v $ignore)
mod+=" $(git -C $tree ls-files --others --exclude-standard | grep '.*\.[ch]' | grep -v $ignore)" mod+=" $(git -C $tree ls-files --others --exclude-standard | grep '.*\.[ch]' | grep -v $ignore)"
echo $mod echo $mod
@ -47,32 +49,32 @@ if [ -z "$mod" ]; then
else else
echo "Copying source to temp directory..." echo "Copying source to temp directory..."
for file in $mod; do for file in $mod; do
echo "$tree/$file --> /tmp/f1/$file" echo "$tree/$file --> ${tmp1}/$file"
cp $tree/$file /tmp/f1/ cp $tree/$file ${tmp1}/
done done
git -C $tree reset --hard git -C $tree reset --hard
git -C $tree clean -fd git -C $tree clean -fd
for file in $mod; do for file in $mod; do
if [ -f $tree/$file ]; then if [ -f $tree/$file ]; then
echo "$tree/$file --> /tmp/f2/$file" echo "$tree/$file --> ${tmp2}/$file"
cp $tree/$file /tmp/f2/ cp $tree/$file ${tmp2}/
fi fi
done done
echo "Running style checks..." echo "Running style checks..."
for file in /tmp/f1/*; do for file in ${tmp1}/*; do
echo "$checkpatch $file > $file _cp" echo "$checkpatch $file > $file _cp"
$checkpatch $file > "$file"_cp 2> /dev/null $checkpatch $file > "$file"_cp 2> /dev/null
done done
for file in /tmp/f2/*; do for file in ${tmp2}/*; do
echo "$checkpatch $file > $file _cp" echo "$checkpatch $file > $file _cp"
$checkpatch $file > "$file"_cp 2> /dev/null $checkpatch $file > "$file"_cp 2> /dev/null
done done
echo "Done." echo "Done."
for file in /tmp/f1/*_cp; do for file in ${tmp1}/*_cp; do
if [ -a /tmp/f2/$(basename $file) ]; then if [ -a ${tmp2}/$(basename $file) ]; then
result=$(diff $file /tmp/f2/$(basename $file) | grep -A3 "ERROR\|WARNING" | grep -A2 -B2 '/tmp/f1') result=$(diff $file ${tmp2}/$(basename $file) | grep -A3 "ERROR\|WARNING" | grep -A2 -B2 "${tmp1}")
else else
result=$(cat $file | grep -A3 "ERROR\|WARNING" | grep -A2 -B2 '/tmp/f1') result=$(cat $file | grep -A3 "ERROR\|WARNING" | grep -A2 -B2 "${tmp1}")
fi fi
if [ "$?" -eq "0" ]; then if [ "$?" -eq "0" ]; then
echo "Report for $(basename $file _cp)" 1>&2 echo "Report for $(basename $file _cp)" 1>&2
@ -98,4 +100,7 @@ if [ $dirty -eq 1 ]; then
git -C $tree config --unset gc.auto; git -C $tree config --unset gc.auto;
fi fi
# remove temp directories
rm -rf ${tmp1} ${tmp2}
exit $stat exit $stat