]> git.ipfire.org Git - thirdparty/glibc.git/blame - manual/check-safety.sh
Fix tst-sigcontext-get_pc rule name from a43565ac447b1
[thirdparty/glibc.git] / manual / check-safety.sh
CommitLineData
48d0341c 1#!/bin/sh
ee196e3c 2
04277e02 3# Copyright 2014-2019 Free Software Foundation, Inc.
ee196e3c
AO
4# This file is part of the GNU C Library.
5
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.
10
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.
15
16# You should have received a copy of the GNU Lesser General Public
17# License along with the GNU C Library; if not, see
5a82c748 18# <https://www.gnu.org/licenses/>.
ee196e3c
AO
19
20
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.
26
27
28success=:
29
30# If no arguments are given, take all *.texi files in the current directory.
31test $# != 0 || set *.texi
32
a2b581cb
AO
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).
36
37
ee196e3c
AO
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.
40grep -n '^@safety' "$@" |
41grep -v ':@safety{\(@prelim{}\)\?@mt\(un\)\?safe{.*}'\
42'@as\(un\)\?safe{.*}@ac\(un\)\?safe{.*}}' &&
43success=false
44
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.
52grep -n '^@safety' "$@" |
53grep -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][^ ]*}\)*}}' &&
60success=false
61
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.
65grep -n '^@safety.*@mtsafe' "$@" |
66grep '@mt\(asc\?\|ac\)?u' "$@" &&
67success=false
68
69# Make sure @mtunsafe lines contain at least one @mtu remark (with
70# optional as, ac or asc between mt and u).
71grep -n '^@safety.*@mtunsafe' "$@" |
72grep -v '@mtunsafe{.*@mt\(asc\?\|ac\)\?u' &&
73success=false
74
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).
78grep -n '^@safety.*@assafe' "$@" |
79grep '@\(mt\)\?asc\?u' &&
80success=false
81
82# Make sure @asunsafe lines contain at least one @asu remark (which
83# could be @ascu, or @mtasu or even @mtascu).
84grep -n '^@safety.*@asunsafe' "$@" |
85grep -v '@mtasc\?u.*@asunsafe\|@asunsafe{.*@asc\?u' &&
86success=false
87
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.
91grep -n '^@safety.*@acsafe' "$@" |
92grep '@\(mt\)\?as\?cu' &&
93success=false
94
95# Make sure @acunsafe lines contain at least one @acu remark (possibly
96# implied by @ascu, @mtacu or @mtascu).
97grep -n '^@safety.*@acunsafe' "$@" |
98grep -v '@\(mtas\?\|as\)cu.*@acunsafe\|@acunsafe{.*@acu' &&
99success=false
100
101# Make sure there aren't duplicate remarks in the same safety note.
102grep -n '^@safety' "$@" |
103grep '[^:]\(@\(mt\|a[sc]\)[^ {]*{[^ ]*}\).*[^:]\1' &&
104success=false
105
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.
111grep -n '^@c \+[^@ ]\+\( dup\)\?'\
112'\( @\(mt\|a[sc]\)[^ ]*\)*\( \[.*\]\)\?$' "$@" |
113grep -v ':@c *[^@{}]*\( @mt[^ {}]*\)*'\
114'\( @as[^ {}]*\)*\( @ac[^ {}]*\)*\( \[.*\]\)\?$' &&
115success=false
116
117# Check that comments containing safety remarks do not contain
118# duplicate remarks.
119grep -n '^@c \+[^@ ]\+\( dup\)\?'\
120'\( @\(mt\|a[sc]\)[^ ]*\)*\( \[.*\]\)\?$' "$@" |
121grep '[^:]\(@\(mt\|a[sc]\)[^ ]*\) \(.*[^:]\)\?\1\($\| \)' &&
122success=false
123
124$success