File: check

package info (click to toggle)
labwc 0.9.1-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,856 kB
  • sloc: ansic: 32,546; perl: 5,834; xml: 886; sh: 162; python: 131; makefile: 12
file content (46 lines) | stat: -rwxr-xr-x 846 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

file=

usage_message="Usage: check [OPTIONS]
OPTIONS:
--file=<filename>          Specify file to check. If none specified, all
                           files in src/ and include/ will be checked.
"

run_checkpatch() {
	nice scripts/checkpatch.pl --terse --no-tree --strict --file "$1"
	return $?
}

run_checks () {
	if [ ! -z "$file" ]; then
		run_checkpatch "${file}"
		return $?
	fi

	find src/ include/ \( -name "*.c" -o -name "*.h" \) -type f -print0 |
	nice xargs -0 --max-args 1 --max-procs $(nproc) \
		scripts/checkpatch.pl --terse --no-tree --strict --file
	return $?
}

main () {
	for arg
	do
		opt=${arg%%=*}
		var=${arg#*=}
		case "$opt" in
		--file)
			file="$var" ;;
		-h|--help)
			printf '%b' "$usage_message"; exit 1 ;;
		*)
			printf '%b\n' "warn: unknown option $opt" >&2 ;;
		esac
	done

	run_checks
}

main "$@"