Commit 8087a560 authored by Cheah Kok Cheong's avatar Cheah Kok Cheong Committed by Linus Torvalds

scripts/checkincludes.pl: add exit message for no duplicates found

If no duplicates found, inform user.

Link: http://lkml.kernel.org/r/1486391275-2843-1-git-send-email-thrust73@gmail.comSigned-off-by: default avatarCheah Kok Cheong <thrust73@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0e5a47a8
...@@ -37,6 +37,8 @@ if ($#ARGV >= 1) { ...@@ -37,6 +37,8 @@ if ($#ARGV >= 1) {
} }
} }
my $dup_counter = 0;
foreach my $file (@ARGV) { foreach my $file (@ARGV) {
open(my $f, '<', $file) open(my $f, '<', $file)
or die "Cannot open $file: $!.\n"; or die "Cannot open $file: $!.\n";
...@@ -57,6 +59,7 @@ foreach my $file (@ARGV) { ...@@ -57,6 +59,7 @@ foreach my $file (@ARGV) {
foreach my $filename (keys %includedfiles) { foreach my $filename (keys %includedfiles) {
if ($includedfiles{$filename} > 1) { if ($includedfiles{$filename} > 1) {
print "$file: $filename is included more than once.\n"; print "$file: $filename is included more than once.\n";
++$dup_counter;
} }
} }
next; next;
...@@ -73,6 +76,7 @@ foreach my $file (@ARGV) { ...@@ -73,6 +76,7 @@ foreach my $file (@ARGV) {
if ($includedfiles{$filename} > 1) { if ($includedfiles{$filename} > 1) {
$includedfiles{$filename}--; $includedfiles{$filename}--;
$dups++; $dups++;
++$dup_counter;
} else { } else {
print {$f} $_; print {$f} $_;
} }
...@@ -87,3 +91,7 @@ foreach my $file (@ARGV) { ...@@ -87,3 +91,7 @@ foreach my $file (@ARGV) {
} }
close($f); close($f);
} }
if ($dup_counter == 0) {
print "No duplicate includes found.\n";
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment