summaryrefslogtreecommitdiff
path: root/v4l/scripts/check.pl
blob: 3e6eb6e47defdf6a01a2148e8cd709324162d4d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl

my $cmd=shift;

if ($cmd) {
	$cmd="diff -upr /dev/null $cmd";
} else {
	$cmd="hg diff";
}

$checkpatch=$ENV{CHECKPATCH};

if (!$checkpatch) {
	$checkpatch="/lib/modules/`uname -r`/build/scripts/checkpatch.pl";
}

my $cp_version;
open IN,"$checkpatch|";
while (<IN>) {
	tr/A-Z/a-z/;
	if (m/version\s*:\s*([\d\.]+)/) {
		$cp_version = $1;
	}
}
close IN;

my $intree_checkpatch = "scripts/checkpatch.pl --no-tree";
if (!open IN,"$intree_checkpatch|") {
	$intree_checkpatch = "v4l/".$intree_checkpatch;
	open IN,"$intree_checkpatch|";
}
while (<IN>) {
	tr/A-Z/a-z/;
	if (m/version\s*:\s*([\d\.]+)/) {
		if ($1 > $cp_version) {
			print "# WARNING: $checkpatch version $cp_version is\n"
			      ."#         older than $intree_checkpatch version"
			      ." $1.\n#          Using in-tree one.\n#\n";
			$cp_version = $1;
			$checkpatch = $intree_checkpatch;
		}
	}
}
close IN;

open IN,"$cmd | $checkpatch -q --nosignoff --emacs -|";
while (<IN>) {
	s|#[\d]+:\s*FILE:\s*|../|;
	print "$_";
}
close IN;