]>
iEval git - linux-seccomp.git/blob - libseccomp/tools/check-syntax
4 # libseccomp code syntax checking tool
6 # Copyright (c) 2013,2015 Red Hat <pmoore@redhat.com>
7 # Author: Paul Moore <paul@paul-moore.com>
11 # This library is free software; you can redistribute it and/or modify it
12 # under the terms of version 2.1 of the GNU Lesser General Public License as
13 # published by the Free Software Foundation.
15 # This library is distributed in the hope that it will be useful, but WITHOUT
16 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
20 # You should have received a copy of the GNU Lesser General Public License
21 # along with this library; if not, see <http://www.gnu.org/licenses>.
24 CHK_C_LIST
="include/seccomp.h.in \
34 # Dependency verification
37 # 1 Dependency to check for
39 function verify_deps
() {
40 [[ -z "$1" ]] && return
41 if ! which "$1" >& /dev
/null
; then
42 echo "error: install \"$1\" and include it in your \$PATH"
48 # Print out script usage details
52 usage: check-syntax [-h]
54 libseccomp code syntax checking tool
56 -h show this help message and exit
57 -f fix the file formatting
62 # Generate a properly formatted C source/header file
67 function tool_c_style
() {
68 astyle
--options=none
--lineend=linux
--mode=c \
70 --indent=force-tab
=8 \
71 --indent-preprocessor \
72 --indent-col1-comments \
73 --min-conditional-indent=0 \
74 --max-instatement-indent=80 \
76 --align-pointer=name \
77 --align-reference=name \
78 --max-code-length=80 \
79 --break-after-logical < "$1"
83 # Check the formatting on a C source/header file
88 function tool_c_style_check
() {
89 [[ -z "$1" ||
! -r "$1" ]] && return
91 tool_c_style
"$1" |
diff -pu --label="$1.orig" "$1" --label="$1" -
95 # Fix the formatting on a C source/header file
100 function tool_c_style_fix
() {
101 [[ -z "$1" ||
! -r "$1" ]] && return
103 tmp
="$(mktemp --tmpdir=$(dirname "$1"))"
104 tool_c_style
"$1" > "$tmp"
109 # Perform all known syntax checks for the configured C sources/headers
112 for i
in $CHK_C_LIST; do
113 echo "$CHK_C_EXCLUDE" |
grep -q "$i" && continue
114 echo "Differences for $i"
115 tool_c_style_check
"$i"
120 # Perform all known syntax fixess for the configured C sources/headers
123 for i
in $CHK_C_LIST; do
124 echo "$CHK_C_EXCLUDE" |
grep -q "$i" && continue
126 tool_c_style_fix
"$i"
137 while getopts "fh" opt
; do
149 # display the results
150 echo "=============== $(date) ==============="
151 echo "Code Syntax Check Results (\"check-syntax $*\")"
152 if [[ $opt_fix -eq 1 ]]; then
157 echo "============================================================"
This page took 0.057473 seconds and 5 git commands to generate.