Fix potential use-after-frees in FreeBSD getpages and setattr VOPs
[zfs.git] / scripts / mancheck.sh
blob6ae1fc5becffc15e9b20409c35edd3076d0887ba
1 #!/bin/sh
3 # Permission to use, copy, modify, and/or distribute this software for
4 # any purpose with or without fee is hereby granted.
6 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
7 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
8 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
9 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
10 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
11 # AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
12 # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 # shellcheck disable=SC2086
16 if [ "$#" -eq 0 ]; then
17 echo "Usage: $0 manpage-directory..."
18 exit 1
21 if ! command -v mandoc > /dev/null; then
22 echo "skipping mancheck because mandoc is not installed"
23 exit 0
26 IFS="
29 files="$(find "$@" -type f -name '*[1-9]*')" || exit 1
31 add_excl="$(awk '
32 /^.\\" lint-ok:/ {
33 print "-e"
34 $1 = "mandoc:"
35 $2 = FILENAME ":[[:digit:]]+:[[:digit:]]+:"
36 print
37 }' $files)"
39 # Redirect to file instead of 2>&1ing because mandoc flushes inconsistently(?) which tears lines
40 # https://github.com/openzfs/zfs/pull/12129/checks?check_run_id=2701608671#step:5:3
41 etmp="$(mktemp)"
42 ! { mandoc -Tlint $files 2>"$etmp"; cat "$etmp"; rm -f "$etmp"; } |
43 grep -vE -e 'mandoc: outdated mandoc.db' -e 'STYLE: referenced manual not found' $add_excl >&2