VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.3/util/check-format-test-positives.c@ 97138

最後變更 在這個檔案從97138是 94320,由 vboxsync 提交於 3 年 前

libs/openssl-3.0.1: Export to OSE and fix copyright headers in Makefiles, bugref:10128

檔案大小: 10.1 KB
 
1/*
2 * Copyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright Nokia 2007-2019
4 * Copyright Siemens AG 2015-2019
5 *
6 * Licensed under the Apache License 2.0 (the "License"). You may not use
7 * this file except in compliance with the License. You can obtain a copy
8 * in the file LICENSE in the source distribution or at
9 * https://www.openssl.org/source/license.html
10 */
11
12/*
13 * This demonstrates/tests cases where check-format.pl should report issues.
14 * Some of the reports are due to sanity checks for proper nesting of comment
15 * delimiters and parenthesis-like symbols, e.g., on unexpected/unclosed braces.
16 */
17
18/*
19 * The '@'s after '*' are used for self-tests: they mark lines containing
20 * a single flaw that should be reported. Normally it should be reported
21 * while handling the given line, but in case of delayed checks there is a
22 * following digit indicating the number of reports expected for this line.
23 */
24
25/* For each of the following set of lines the tool should complain once */
26/*@ tab character: */
27/*@ intra-line carriage return character:
28 */
29/*@ non-printable ASCII character: */
30/*@ non-ASCII character: ä */
31/*@ whitespace at EOL: */
32// /*@ end-of-line comment style not allowed (for C90 compatibility) */
33 /*@0 intra-line comment indent off by 1, reported unless sloppy-cmt */
34/*X */ /*@2 no space nor '*' after comment start, reported unless sloppy-spc */
35/* X*/ /*@ no space before comment end , reported unless sloppy-spc */
36/*@ comment starting delimiter: /* inside intra-line comment */
37 /*@0
38 *@ above multi-line comment start indent off by 1, reported unless sloppy-cmt; this comment line is too long
39 *@ multi-line comment indent further off by 1 relative to comment start
40 *@ multi-line comment ending with text on last line */
41/*@2 multi-line comment starting with text on first line
42 *@ comment starting delimiter: /* inside multi-line comment
43*@ multi-line comment indent off by -1
44 *X*@ no spc after leading '*' in multi-line comment, reported unless sloppy-spc
45 *@0 more than two spaces after . in comment, reported unless sloppy-spc
46 *@0 more than two spaces after ? in comment, reported unless sloppy-spc
47 *@0 more than two spaces after ! in comment, reported unless sloppy-spc
48*/ /*@ multi-line comment end indent off by -1 (relative to comment start) */
49*/ /*@ unexpected comment ending delimiter outside comment */
50/*@ comment line is 4 columns tooooooooooooooooo wide, reported unless sloppy-len */
51/*@ comment line is 5 columns toooooooooooooooooooooooooooooooooooooooooooooo wide */
52#define X 1 /*@0 extra space false negative due to coincidence */
53 #define Y 2 /*@ indent of preprocessor directive off by 1 (must be 0) */
54typedef struct { /*@0 extra space in code, reported unless sloppy-spc */
55 enum { /*@1 extra space in comment, reported unless sloppy-spc */
56 w = 0 /*@ hanging expr indent off by 1, or 3 for lines after '{' */
57 && 1, /*@ hanging expr indent off by 3, or -1 for leading '&&' */
58 x = 1, /*@ hanging expr indent off by -1 */
59 y,z /*@ no space after ',', reported unless sloppy-spc */
60 } e_member ; /*@ space before ';', reported unless sloppy-spc */
61 int v[1; /*@ unclosed bracket in type declaration */
62 union { /*@ statement/type declaration indent off by -1 */
63 struct{} s; /*@ no space before '{', reported unless sloppy-spc */
64 }u_member; /*@ no space after '}', reported unless sloppy-spc */
65 } s_type; /*@ statement/type declaration indent off by 4 */
66int* somefunc(); /*@ no space before '*' in type decl, r unless sloppy-spc */
67void main(int n) { /*@ opening brace at end of function definition header */
68 for (;;n++) { /*@ no space after ';', reported unless sloppy-spc */
69 return; /*@0 (1-line) single statement in braces */
70 }} /*@2 code after '}' outside expr */
71} /*@ unexpected closing brace (too many '}') outside expr */
72) /*@ unexpected closing paren outside expr */
73#endif /*@ unexpected #endif */
74int f (int a, /*@ space after fn before '(', reported unless sloppy-spc */
75 int b, /*@ hanging expr indent off by -1 */
76 long I) /*@ single-letter name 'I' */
77{ int /*@ code after '{' opening a block */
78 xx = 1) + /*@ unexpected closing parenthesis */
79 0L < /*@ constant on LHS of comparison operator */
80 a] - /*@ unexpected closing bracket */
81 3: * /*@ unexpected ':' (without preceding '?') within expr */
82 4}; /*@ unexpected closing brace within expression */
83 char y[] = { /*@0 unclosed brace within initializer/enum expression */
84 1* 1, /*@ no space etc. before '*', reported unless sloppy-spc */
85 2, /*@ hanging expr indent (for lines after '{') off by 1 */
86 (xx /*@0 unclosed parenthesis in expression */
87 ? y /*@0 unclosed '? (conditional expression) */
88 [0; /*@4 unclosed bracket in expression */
89 s_type s; /*@ local variable declaration indent off by -1 */
90 somefunc(a, /*@ statement indent off by -1 */
91 "aligned" /*@ expr indent off by -2 accepted if sloppy-hang */ "right"
92 , b, /*@ expr indent off by -1 */
93 b, /*@ expr indent as on line above, accepted if sloppy-hang */
94 b, /*@ expr indent off -8 but @ extra indent accepted if sloppy-hang */
95 "again aligned" /*@ expr indent off by -9 (left of stmt indent, */ "right",
96 abc == /*@ .. so reported also with sloppy-hang; this line is too long */ 456
97# define MAC(A) (A) /*@ nesting indent of preprocessor directive off by 1 */
98 ? 1 /*@ hanging expr indent off by 1 */
99 : 2); /*@ hanging expr indent off by 2, or 1 for leading ':' */
100 if(a /*@ no space after 'if', reported unless sloppy-spc */
101 /*@0 intra-line comment indent off by -1 (not: by 3 due to '&&') */
102 && ! 0 /*@2 space after '!', reported unless sloppy-spc */
103 || b == /*@ hanging expr indent off by 2, or -2 for leading '||' */
104 (xx+= 2) + /*@ no space before '+=', reported unless sloppy-spc */
105 (a^ 1) + /*@ no space before '^', reported unless sloppy-spc */
106 a %2 / /*@ no space after '%', reported unless sloppy-spc */
107 1 +/* */ /*@ no space before comment, reported unless sloppy-spc */
108 /* */+ /*@ no space after comment, reported unless sloppy-spc */
109 s. e_member) /*@ space after '.', reported unless sloppy-spc */
110 xx = a + b /*@ extra single-statement indent off by 1 */
111 + 0; /*@ two times extra single-statement indent off by 3 */
112 if (a ++) /*@ space before postfix '++', reported unless sloppy-spc */
113 { /*@ {' not on same line as preceding 'if' */
114 c; /*@0 single stmt in braces, reported on 1-stmt */
115 } else /*@ no '{' on same line after '} else' */
116 { /*@ statement indent off by 2 */
117 d; /*@0 single stmt in braces, reported on 1-stmt */
118 } /*@ statement indent off by 6 */
119 if (1) f(a, /*@ (non-brace) code after end of 'if' condition */
120 b); else /*@ (non-brace) code before 'else' */
121 do f(c, c); /*@ (non-brace) code after 'do' */
122 while ( 2); /*@ space after '(', reported unless sloppy-spc */
123 b; c; /*@ more than one statement per line */
124 outer: /*@ outer label special indent off by 1 */
125 do{ /*@ no space before '{', reported unless sloppy-spc */
126 inner: /*@ inner label normal indent off by 1 */
127 f (3, /*@ space after fn before '(', reported unless sloppy-spc */
128 4); /*@0 false negative: should report single stmt in braces */
129 } /*@0 'while' not on same line as preceding '}' */
130 while (a+ 0); /*@2 no space before '+', reported unless sloppy-spc */
131 switch (b ) { /*@ space before ')', reported unless sloppy-spc */
132 case 1: /*@ 'case' special statement indent off by -1 */
133 case(2): /*@ no space after 'case', reported unless sloppy-spc */
134 default: ; /*@ code after 'default:' */
135} /*@ statement indent off by -4 */
136 return( /*@ no space after 'return', reported unless sloppy-spc */
137 x); } /*@ code before block-level '}' */
138/* Here the tool should stop complaining apart from the below issues at EOF */
139
140void f_looong_body()
141{
142 ;
143 ;
144 ;
145 ;
146 ;
147 ;
148 ;
149 ;
150 ;
151 ;
152 ;
153 ;
154 ;
155 ;
156 ;
157 ;
158 ;
159 ;
160 ;
161 ;
162 ;
163 ;
164 ;
165 ;
166 ;
167 ;
168 ;
169 ;
170 ;
171 ;
172 ;
173 ;
174 ;
175 ;
176 ;
177 ;
178 ;
179 ;
180 ;
181 ;
182 ;
183 ;
184 ;
185 ;
186 ;
187 ;
188 ;
189 ;
190 ;
191 ;
192 ;
193 ;
194 ;
195 ;
196 ;
197 ;
198 ;
199 ;
200 ;
201 ;
202 ;
203 ;
204 ;
205 ;
206 ;
207 ;
208 ;
209 ;
210 ;
211 ;
212 ;
213 ;
214 ;
215 ;
216 ;
217 ;
218 ;
219 ;
220 ;
221 ;
222 ;
223 ;
224 ;
225 ;
226 ;
227 ;
228 ;
229 ;
230 ;
231 ;
232 ;
233 ;
234 ;
235 ;
236 ;
237 ;
238 ;
239 ;
240 ;
241 ;
242 ;
243 ;
244 ;
245 ;
246 ;
247 ;
248 ;
249 ;
250 ;
251 ;
252 ;
253 ;
254 ;
255 ;
256 ;
257 ;
258 ;
259 ;
260 ;
261 ;
262 ;
263 ;
264 ;
265 ;
266 ;
267 ;
268 ;
269 ;
270 ;
271 ;
272 ;
273 ;
274 ;
275 ;
276 ;
277 ;
278 ;
279 ;
280 ;
281 ;
282 ;
283 ;
284 ;
285 ;
286 ;
287 ;
288 ;
289 ;
290 ;
291 ;
292 ;
293 ;
294 ;
295 ;
296 ;
297 ;
298 ;
299 ;
300 ;
301 ;
302 ;
303 ;
304 ;
305 ;
306 ;
307 ;
308 ;
309 ;
310 ;
311 ;
312 ;
313 ;
314 ;
315 ;
316 ;
317 ;
318 ;
319 ;
320 ;
321 ;
322 ;
323 ;
324 ;
325 ;
326 ;
327 ;
328 ;
329 ;
330 ;
331 ;
332 ;
333 ;
334 ;
335 ;
336 ;
337 ;
338 ;
339 ;
340
341
342 ; /*@ 2 essentially empty lines before, if !sloppy-spc */
343} /*@ function body length > 200 lines */
344#if 0 /*@0 unclosed #if */
345struct t { /*@0 unclosed brace at decl/block level */
346 enum { /*@0 unclosed brace at enum/expression level */
347 v = (1 /*@0 unclosed parenthesis */
348 etyp /*@0 empty line follows just before EOF, if !sloppy-spc: */
349
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette