| 1 | #!/bin/sh |
| 2 | |
| 3 | file= |
| 4 | |
| 5 | usage_message="Usage: check [OPTIONS] |
| 6 | OPTIONS: |
| 7 | --file=<filename> Specify file to check. If none specified, all |
| 8 | files in src/ and include/ will be checked. |
| 9 | " |
| 10 | |
| 11 | run_checkpatch() { |
| 12 | nice scripts/checkpatch.pl --terse --no-tree --strict --file "$1" |
| 13 | return $? |
| 14 | } |
| 15 | |
| 16 | run_checks () { |
| 17 | if [ ! -z "$file" ]; then |
| 18 | run_checkpatch "${file}" |
| 19 | return $? |
| 20 | fi |
| 21 | |
| 22 | find src/ include/ clients/ t/ \( -name "*.c" -o -name "*.h" \) -type f -print0 | |
| 23 | nice xargs -0 --max-args 16 --max-procs $(nproc) \ |
| 24 | scripts/checkpatch.pl --terse --no-tree --strict --file |
| 25 | return $? |
| 26 | } |
| 27 | |
| 28 | main () { |
| 29 | for arg |
| 30 | do |
| 31 | opt=${arg%%=*} |
| 32 | var=${arg#*=} |
| 33 | case "$opt" in |
| 34 | --file) |
| 35 | file="$var" ;; |
| 36 | -h|--help) |
| 37 | printf '%b' "$usage_message"; exit 1 ;; |
| 38 | *) |
| 39 | printf '%b\n' "warn: unknown option $opt" >&2 ;; |
| 40 | esac |
| 41 | done |
| 42 | |
| 43 | run_checks |
| 44 | } |
| 45 | |
| 46 | main "$@" |