Consolidate non cancellable openat call
[glibc.git] / manual / check-safety.sh
blobc0d93b0ba1f37bce6dbaf20342633b597b68645b
1 #!/bin/sh
3 # Copyright 2014-2017 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with the GNU C Library; if not, see
18 # <http://www.gnu.org/licenses/>.
21 # Check that the @safety notes are self-consistent, i.e., that they're
22 # in proper order (mt then as then ac), that remarks appear within
23 # corresponding sections (mt within mt, etc), that unsafety always has
24 # an explicit reason and when there's a reason for unsafety it's not
25 # safe, and that there aren't duplicates remarks.
28 success=:
30 # If no arguments are given, take all *.texi files in the current directory.
31 test $# != 0 || set *.texi
33 # FIXME: check that each @deftypefu?n is followed by a @safety note,
34 # with nothing but @deftypefu?nx and comment lines in between. (There
35 # might be more stuff too).
38 # Check that all safety remarks have entries for all of MT, AS and AC,
39 # in this order, with an optional prelim note before them.
40 grep -n '^@safety' "$@" |
41 grep -v ':@safety{\(@prelim{}\)\?@mt\(un\)\?safe{.*}'\
42 '@as\(un\)\?safe{.*}@ac\(un\)\?safe{.*}}' &&
43 success=false
45 # Check that @mt-started notes appear within @mtsafe or @mtunsafe,
46 # that @as-started notes appear within @assafe or @asunsafe, and that
47 # @ac-started notes appear within @acsafe or @acunsafe. Also check
48 # that @mt, @as and @ac are followed by an s (for safe) or u (for
49 # unsafe), but let @mt have as, ac or asc before [su], and let @as
50 # have a c (for cancel) before [su]. Also make sure blanks separate
51 # each of the annotations.
52 grep -n '^@safety' "$@" |
53 grep -v ':@safety{\(@prelim{}\)\?'\
54 '@mt\(un\)\?safe{\(@mt\(asc\?\|ac\)\?[su][^ ]*}\)\?'\
55 '\( @mt\(asc\?\|ac\)\?[su][^ ]*}\)*}'\
56 '@as\(un\)\?safe{\(@asc\?[su][^ ]*}\)\?'\
57 '\( @asc\?[su][^ ]*}\)*}'\
58 '@ac\(un\)\?safe{\(@ac[su][^ ]*}\)\?'\
59 '\( @ac[su][^ ]*}\)*}}' &&
60 success=false
62 # Make sure safety lines marked as @mtsafe do not contain any
63 # MT-Unsafe remark; that would be @mtu, but there could be as, ac or
64 # asc between mt and u.
65 grep -n '^@safety.*@mtsafe' "$@" |
66 grep '@mt\(asc\?\|ac\)?u' "$@" &&
67 success=false
69 # Make sure @mtunsafe lines contain at least one @mtu remark (with
70 # optional as, ac or asc between mt and u).
71 grep -n '^@safety.*@mtunsafe' "$@" |
72 grep -v '@mtunsafe{.*@mt\(asc\?\|ac\)\?u' &&
73 success=false
75 # Make sure safety lines marked as @assafe do not contain any AS-Unsafe
76 # remark, which could be @asu or @mtasu note (with an optional c
77 # between as and u in both cases).
78 grep -n '^@safety.*@assafe' "$@" |
79 grep '@\(mt\)\?asc\?u' &&
80 success=false
82 # Make sure @asunsafe lines contain at least one @asu remark (which
83 # could be @ascu, or @mtasu or even @mtascu).
84 grep -n '^@safety.*@asunsafe' "$@" |
85 grep -v '@mtasc\?u.*@asunsafe\|@asunsafe{.*@asc\?u' &&
86 success=false
88 # Make sure safety lines marked as @acsafe do not contain any
89 # AC-Unsafe remark, which could be @acu, @ascu or even @mtacu or
90 # @mtascu.
91 grep -n '^@safety.*@acsafe' "$@" |
92 grep '@\(mt\)\?as\?cu' &&
93 success=false
95 # Make sure @acunsafe lines contain at least one @acu remark (possibly
96 # implied by @ascu, @mtacu or @mtascu).
97 grep -n '^@safety.*@acunsafe' "$@" |
98 grep -v '@\(mtas\?\|as\)cu.*@acunsafe\|@acunsafe{.*@acu' &&
99 success=false
101 # Make sure there aren't duplicate remarks in the same safety note.
102 grep -n '^@safety' "$@" |
103 grep '[^:]\(@\(mt\|a[sc]\)[^ {]*{[^ ]*}\).*[^:]\1' &&
104 success=false
106 # Check that comments containing safety remarks do not contain {}s,
107 # that all @mt remarks appear before @as remarks, that in turn appear
108 # before @ac remarks, all properly blank-separated, and that an
109 # optional comment about exclusions is between []s at the end of the
110 # line.
111 grep -n '^@c \+[^@ ]\+\( dup\)\?'\
112 '\( @\(mt\|a[sc]\)[^ ]*\)*\( \[.*\]\)\?$' "$@" |
113 grep -v ':@c *[^@{}]*\( @mt[^ {}]*\)*'\
114 '\( @as[^ {}]*\)*\( @ac[^ {}]*\)*\( \[.*\]\)\?$' &&
115 success=false
117 # Check that comments containing safety remarks do not contain
118 # duplicate remarks.
119 grep -n '^@c \+[^@ ]\+\( dup\)\?'\
120 '\( @\(mt\|a[sc]\)[^ ]*\)*\( \[.*\]\)\?$' "$@" |
121 grep '[^:]\(@\(mt\|a[sc]\)[^ ]*\) \(.*[^:]\)\?\1\($\| \)' &&
122 success=false
124 $success