xref: /freebsd/crypto/openssl/util/check-format-test-negatives.c (revision e7be843b4a162e68651d3911f0357ed464915629)
1e0c4386eSCy Schubert /*
2*e7be843bSPierre Pronchery  * Copyright 2007-2025 The OpenSSL Project Authors. All Rights Reserved.
3e0c4386eSCy Schubert  * Copyright Siemens AG 2015-2022
4e0c4386eSCy Schubert  *
5e0c4386eSCy Schubert  * Licensed under the Apache License 2.0 (the "License").  You may not use
6e0c4386eSCy Schubert  * this file except in compliance with the License.  You can obtain a copy
7e0c4386eSCy Schubert  * in the file LICENSE in the source distribution or at
8e0c4386eSCy Schubert  * https://www.openssl.org/source/license.html
9e0c4386eSCy Schubert  */
10e0c4386eSCy Schubert 
11e0c4386eSCy Schubert /*
12e0c4386eSCy Schubert  * A collection of test cases where check-format.pl should not report issues.
13*e7be843bSPierre Pronchery  * There are some known false positives, though, which are marked below using /*@
14e0c4386eSCy Schubert  */
15e0c4386eSCy Schubert 
16e0c4386eSCy Schubert #include <errno.h> /* should not report whitespace nits within <...> */
17e0c4386eSCy Schubert #define F                                       \
18e0c4386eSCy Schubert     void f()                                    \
19e0c4386eSCy Schubert     {                                           \
20e0c4386eSCy Schubert         int i;                                  \
21e0c4386eSCy Schubert         int j;                                  \
22e0c4386eSCy Schubert                                                 \
23e0c4386eSCy Schubert         return;                                 \
24e0c4386eSCy Schubert     }
25e0c4386eSCy Schubert 
26e0c4386eSCy Schubert /* allow extra  SPC in single-line comment */
27e0c4386eSCy Schubert /*
28e0c4386eSCy Schubert  * allow extra  SPC in regular multi-line comment
29e0c4386eSCy Schubert  */
30e0c4386eSCy Schubert /*-
31e0c4386eSCy Schubert  * allow extra  SPC in format-tagged multi-line comment
32e0c4386eSCy Schubert  */
33e0c4386eSCy Schubert /** allow extra '*' in comment opening */
34e0c4386eSCy Schubert /*! allow extra '!' in comment opening */
35e0c4386eSCy Schubert /*
36e0c4386eSCy Schubert  ** allow "**" as first non-space chars of a line within multi-line comment
37e0c4386eSCy Schubert  */
38e0c4386eSCy Schubert 
f(void)39e0c4386eSCy Schubert int f(void) /*
40e0c4386eSCy Schubert              * trailing multi-line comment
41e0c4386eSCy Schubert              */
42e0c4386eSCy Schubert {
43e0c4386eSCy Schubert     typedef int INT;
44e0c4386eSCy Schubert     void v;
45e0c4386eSCy Schubert     short b;
46e0c4386eSCy Schubert     char c;
47e0c4386eSCy Schubert     signed s;
48e0c4386eSCy Schubert     unsigned u;
49e0c4386eSCy Schubert     int i;
50e0c4386eSCy Schubert     long l;
51e0c4386eSCy Schubert     float f;
52e0c4386eSCy Schubert     double d;
53e0c4386eSCy Schubert     enum {} enu;
54e0c4386eSCy Schubert     struct {} stru;
55e0c4386eSCy Schubert     union {} un;
56e0c4386eSCy Schubert     auto a;
57e0c4386eSCy Schubert     extern e;
58e0c4386eSCy Schubert     static int stat;
59e0c4386eSCy Schubert     const int con;
60e0c4386eSCy Schubert     volatile int vola;
61e0c4386eSCy Schubert     register int reg;
62e0c4386eSCy Schubert     OSSL_x y, *p = params;
63e0c4386eSCy Schubert     int params[];
64e0c4386eSCy Schubert     OSSL_PARAM * (* params []) [MAX + 1];
65e0c4386eSCy Schubert     XY *(* fn)(int a, char b);
66e0c4386eSCy Schubert     /*
67e0c4386eSCy Schubert      * multi-line comment should not disturb detection of local decls
68e0c4386eSCy Schubert      */
69e0c4386eSCy Schubert     BIO1 ***b;
70e0c4386eSCy Schubert     /* intra-line comment should not disturb detection of local decls */
71e0c4386eSCy Schubert     unsigned k;
72e0c4386eSCy Schubert 
73e0c4386eSCy Schubert     /* intra-line comment should not disturb detection of end of local decls */
74e0c4386eSCy Schubert 
75e0c4386eSCy Schubert     {
76e0c4386eSCy Schubert         int x; /* just decls in block */
77e0c4386eSCy Schubert     }
78e0c4386eSCy Schubert     if (p != (unsigned char *)
79e0c4386eSCy Schubert         &(ctx->tmp[0])) {
80e0c4386eSCy Schubert         i -= (p - (unsigned char *) /* do not confuse with var decl */
81e0c4386eSCy Schubert               &(ctx->tmp[0]));
82e0c4386eSCy Schubert     }
83e0c4386eSCy Schubert     {
84e0c4386eSCy Schubert         ctx->buf_off = 0; /* do not confuse with var decl */
85e0c4386eSCy Schubert         return 0;
86e0c4386eSCy Schubert     }
87e0c4386eSCy Schubert     {
88e0c4386eSCy Schubert         ctx->buf_len = EVP_EncodeBlock((unsigned char *)ctx->buf,
89e0c4386eSCy Schubert                                        (unsigned char *)ctx->tmp, /* no decl */
90e0c4386eSCy Schubert                                        ctx->tmp_len);
91e0c4386eSCy Schubert     }
92e0c4386eSCy Schubert     {
93e0c4386eSCy Schubert         EVP_EncodeFinal(ctx->base64,
94e0c4386eSCy Schubert                         (unsigned char *)ctx->buf, &(ctx->len)); /* no decl */
95e0c4386eSCy Schubert         /* push out the bytes */
96e0c4386eSCy Schubert         goto again;
97e0c4386eSCy Schubert     }
98e0c4386eSCy Schubert     {
99e0c4386eSCy Schubert         f(1, (unsigned long)2); /* no decl */
100e0c4386eSCy Schubert         x;
101e0c4386eSCy Schubert     }
102e0c4386eSCy Schubert     {
103e0c4386eSCy Schubert         char *pass_str = get_passwd(opt_srv_secret, "x");
104e0c4386eSCy Schubert 
105e0c4386eSCy Schubert         if (pass_str != NULL) {
106e0c4386eSCy Schubert             cleanse(opt_srv_secret);
107e0c4386eSCy Schubert             res = OSSL_CMP_CTX_set1_secretValue(ctx, (unsigned char *)pass_str,
108e0c4386eSCy Schubert                                                 strlen(pass_str));
109e0c4386eSCy Schubert             clear_free(pass_str);
110e0c4386eSCy Schubert         }
111e0c4386eSCy Schubert     }
112e0c4386eSCy Schubert }
113e0c4386eSCy Schubert 
g(void)114e0c4386eSCy Schubert int g(void)
115e0c4386eSCy Schubert {
116e0c4386eSCy Schubert     if (ctx == NULL) {    /* non-leading end-of-line comment */
117e0c4386eSCy Schubert         if (/* comment after '(' */ pem_name != NULL /* comment before ')' */)
118e0c4386eSCy Schubert             /* entire-line comment indent usually like for the following line */
119e0c4386eSCy Schubert             return NULL; /* hanging indent also for this line after comment */
120e0c4386eSCy Schubert         /* leading comment has same indentation as normal code */ stmt;
121e0c4386eSCy Schubert         /* entire-line comment may have same indent as normal code */
122e0c4386eSCy Schubert     }
123e0c4386eSCy Schubert     for (i = 0; i < n; i++)
124e0c4386eSCy Schubert         for (; i < n; i++)
125e0c4386eSCy Schubert             for (i = 0; ; i++)
126e0c4386eSCy Schubert                 for (i = 0;; i++)
127e0c4386eSCy Schubert                     for (i = 0; i < n; )
128e0c4386eSCy Schubert                         for (i = 0; i < n;)
129e0c4386eSCy Schubert                             ;
130e0c4386eSCy Schubert     for (i = 0; ; )
131e0c4386eSCy Schubert         for (i = 0; ;)
132e0c4386eSCy Schubert             for (i = 0;; )
133e0c4386eSCy Schubert                 for (i = 0;;)
134e0c4386eSCy Schubert                     for (; i < n; )
135e0c4386eSCy Schubert                         for (; j < n;)
136e0c4386eSCy Schubert                             for (; ; i++)
137e0c4386eSCy Schubert                                 for (;; i++)
138e0c4386eSCy Schubert                                     ;
139e0c4386eSCy Schubert     for (;;) /* the only variant allowed in case of "empty" for (...) */
140e0c4386eSCy Schubert         ;
141e0c4386eSCy Schubert     for (;;) ; /* should not trigger: space before ';' */
142e0c4386eSCy Schubert  lab: ;  /* should not trigger: space before ';' */
143e0c4386eSCy Schubert 
144e0c4386eSCy Schubert #if X
145e0c4386eSCy Schubert     if (1) /* bad style: just part of control structure depends on #if */
146e0c4386eSCy Schubert #else
147e0c4386eSCy Schubert     if (2) /*@ resulting false positive */
148e0c4386eSCy Schubert #endif
149e0c4386eSCy Schubert         c; /*@ resulting false positive */
150e0c4386eSCy Schubert 
151e0c4386eSCy Schubert     if (1)
152e0c4386eSCy Schubert         if (2)
153e0c4386eSCy Schubert             c;
154e0c4386eSCy Schubert         else
155e0c4386eSCy Schubert             e;
156e0c4386eSCy Schubert     else
157e0c4386eSCy Schubert         f;
158e0c4386eSCy Schubert     do
159e0c4386eSCy Schubert         do
160e0c4386eSCy Schubert             2;
161e0c4386eSCy Schubert         while (1);
162e0c4386eSCy Schubert     while (2);
163e0c4386eSCy Schubert 
164*e7be843bSPierre Pronchery     if (pcrl != NULL) {
165*e7be843bSPierre Pronchery         1;
166*e7be843bSPierre Pronchery         2;
167*e7be843bSPierre Pronchery     } else if (pcrls != NULL) {
168*e7be843bSPierre Pronchery         1;
169*e7be843bSPierre Pronchery     }
170*e7be843bSPierre Pronchery 
171e0c4386eSCy Schubert     if (1)
172e0c4386eSCy Schubert         f(a, b);
173e0c4386eSCy Schubert     do
174e0c4386eSCy Schubert         1; while (2); /*@ more than one stmt just to construct case */
175e0c4386eSCy Schubert     if (1)
176e0c4386eSCy Schubert         f(a, b);
177e0c4386eSCy Schubert     else
178e0c4386eSCy Schubert         do
179e0c4386eSCy Schubert             1;
180e0c4386eSCy Schubert         while (2);
181e0c4386eSCy Schubert     if (1)
182e0c4386eSCy Schubert         f(a, b);
183e0c4386eSCy Schubert     else do /*@ (non-brace) code before 'do' just to construct case */
184e0c4386eSCy Schubert              1;
185e0c4386eSCy Schubert         while (2);
186e0c4386eSCy Schubert     f1234(a,
187e0c4386eSCy Schubert           b); do /*@ (non-brace) code before 'do' just to construct case */
188e0c4386eSCy Schubert                   1;
189e0c4386eSCy Schubert     while (2);
190e0c4386eSCy Schubert     if (1)
191e0c4386eSCy Schubert         f(a,
192e0c4386eSCy Schubert           b); do /*@ (non-brace) code before 'do' just to construct case */
193e0c4386eSCy Schubert                   1;
194e0c4386eSCy Schubert     while (2);
195e0c4386eSCy Schubert     if (1)
196e0c4386eSCy Schubert         f(a, b);
197e0c4386eSCy Schubert     else
198e0c4386eSCy Schubert         do f(c, c); /*@ (non-brace) code after 'do' just to construct case */
199e0c4386eSCy Schubert         while (2);
200e0c4386eSCy Schubert 
201e0c4386eSCy Schubert     if (1)
202e0c4386eSCy Schubert         f(a, b);
203e0c4386eSCy Schubert     else
204e0c4386eSCy Schubert         return;
205e0c4386eSCy Schubert     if (1)
206e0c4386eSCy Schubert         f(a,
207e0c4386eSCy Schubert           b); else /*@ (non-brace) code before 'else' just to construct case */
208e0c4386eSCy Schubert         do
209e0c4386eSCy Schubert             1;
210e0c4386eSCy Schubert         while (2);
211e0c4386eSCy Schubert 
212e0c4386eSCy Schubert     if (1)
213e0c4386eSCy Schubert     { /*@ brace after 'if' not on same line just to construct case */
214e0c4386eSCy Schubert         c;
215e0c4386eSCy Schubert         d;
216e0c4386eSCy Schubert     }
217e0c4386eSCy Schubert     /* this comment is correctly indented if it refers to the following line */
218e0c4386eSCy Schubert     d;
219e0c4386eSCy Schubert 
220e0c4386eSCy Schubert     if (1) {
221e0c4386eSCy Schubert         2;
222e0c4386eSCy Schubert     } else /*@ no brace after 'else' just to construct case */
223e0c4386eSCy Schubert         3;
224e0c4386eSCy Schubert     do {
225e0c4386eSCy Schubert     } while (x);
226e0c4386eSCy Schubert     if (1) {
227e0c4386eSCy Schubert         2;
228e0c4386eSCy Schubert     } else {
229e0c4386eSCy Schubert         3;
230e0c4386eSCy Schubert     }
231e0c4386eSCy Schubert     if (4)
232e0c4386eSCy Schubert         5;
233e0c4386eSCy Schubert     else
234e0c4386eSCy Schubert         6;
235e0c4386eSCy Schubert 
236e0c4386eSCy Schubert     if (1) {
237e0c4386eSCy Schubert         if (2) {
238e0c4386eSCy Schubert         case MAC_TYPE_MAC:
239e0c4386eSCy Schubert             {
240e0c4386eSCy Schubert                 EVP_MAC_CTX *new_mac_ctx;
241e0c4386eSCy Schubert 
242e0c4386eSCy Schubert                 if (ctx->pkey == NULL)
243e0c4386eSCy Schubert                     return 0;
244e0c4386eSCy Schubert             }
245e0c4386eSCy Schubert             break;
246*e7be843bSPierre Pronchery         case 1: {
247*e7be843bSPierre Pronchery             ;
248*e7be843bSPierre Pronchery         }
249e0c4386eSCy Schubert         default:
250e0c4386eSCy Schubert             /* This should be dead code */
251e0c4386eSCy Schubert             return 0;
252e0c4386eSCy Schubert         }
253e0c4386eSCy Schubert     }
254e0c4386eSCy Schubert     if (expr_line1
255e0c4386eSCy Schubert         == expr_line2
256e0c4386eSCy Schubert             && expr_line3) {
257e0c4386eSCy Schubert         c1;
258e0c4386eSCy Schubert     } else {
259e0c4386eSCy Schubert         c;
260e0c4386eSCy Schubert         d;
261e0c4386eSCy Schubert     }
262e0c4386eSCy Schubert     if (expr_line1
263e0c4386eSCy Schubert         == expr_line2
264e0c4386eSCy Schubert             && expr_line3)
265e0c4386eSCy Schubert         hanging_stmt;
266e0c4386eSCy Schubert }
267*e7be843bSPierre Pronchery 
268*e7be843bSPierre Pronchery #define m1                           \
269*e7be843bSPierre Pronchery     if (ctx == NULL)                 \
270*e7be843bSPierre Pronchery         return 0;                    \
271*e7be843bSPierre Pronchery     if (ossl_param_is_empty(params)) \
272*e7be843bSPierre Pronchery         return 1;                    \
273*e7be843bSPierre Pronchery 
274*e7be843bSPierre Pronchery #define m2                                                               \
275e0c4386eSCy Schubert     do { /* should not be confused with function header followed by '{' */ \
276e0c4386eSCy Schubert     } while (0)
277e0c4386eSCy Schubert 
278e0c4386eSCy Schubert /* should not trigger: constant on LHS of comparison or assignment operator */
279e0c4386eSCy Schubert X509 *x509 = NULL;
280e0c4386eSCy Schubert int y = a + 1 < b;
281e0c4386eSCy Schubert int ret, was_NULL = *certs == NULL;
282e0c4386eSCy Schubert 
283e0c4386eSCy Schubert /* should not trigger: missing space before ... */
284e0c4386eSCy Schubert float z = 1e-6 * (-1) * b[+6] * 1e+1 * (a)->f * (long)+1
285e0c4386eSCy Schubert     - (tmstart.tv_sec + tmstart.tv_nsec * 1e-9);
286e0c4386eSCy Schubert struct st = {-1, 0};
287e0c4386eSCy Schubert int x = (y <<= 1) + (z <= 5.0);
288e0c4386eSCy Schubert 
289e0c4386eSCy Schubert const OPTIONS passwd_options[] = {
290e0c4386eSCy Schubert     {"aixmd5", OPT_AIXMD5, '-', "AIX MD5-based password algorithm"},
291e0c4386eSCy Schubert #if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
292e0c4386eSCy Schubert     {"crypt", OPT_CRYPT, '-', "Standard Unix password algorithm (default)"},
293e0c4386eSCy Schubert #endif
294e0c4386eSCy Schubert     OPT_R_OPTIONS,
295e0c4386eSCy Schubert 
296e0c4386eSCy Schubert     {NULL}
297e0c4386eSCy Schubert };
298e0c4386eSCy Schubert 
299*e7be843bSPierre Pronchery typedef bool (*LOG_cb_t)(int lineno, severity level, const char *msg);
300e0c4386eSCy Schubert typedef * d(int)
301e0c4386eSCy Schubert     x;
302e0c4386eSCy Schubert typedef (int)
303e0c4386eSCy Schubert x;
304e0c4386eSCy Schubert typedef (int)*()
305e0c4386eSCy Schubert     x;
306e0c4386eSCy Schubert typedef *int *
307e0c4386eSCy Schubert x;
308e0c4386eSCy Schubert typedef OSSL_CMP_MSG *(*cmp_srv_process_cb_t)
309e0c4386eSCy Schubert     (OSSL_CMP_SRV_CTX *ctx, OSSL_CMP_MSG *msg)
310e0c4386eSCy Schubert     xx;
311e0c4386eSCy Schubert 
312e0c4386eSCy Schubert #define IF(cond) if (cond)
313e0c4386eSCy Schubert 
314e0c4386eSCy Schubert _Pragma("GCC diagnostic push")
315e0c4386eSCy Schubert _Pragma("GCC diagnostic pop")
316e0c4386eSCy Schubert 
317e0c4386eSCy Schubert #define CB_ERR_IF(cond, ctx, cert, depth, err) \
318e0c4386eSCy Schubert     if ((cond) && ((depth) < 0 || verify_cb_cert(ctx, cert, depth, err) == 0)) \
319e0c4386eSCy Schubert         return err
verify_cb_crl(X509_STORE_CTX * ctx,int err)320e0c4386eSCy Schubert static int verify_cb_crl(X509_STORE_CTX *ctx, int err)
321e0c4386eSCy Schubert {
322e0c4386eSCy Schubert     ctx->error = err;
323e0c4386eSCy Schubert     return ctx->verify_cb(0, ctx);
324e0c4386eSCy Schubert }
325e0c4386eSCy Schubert 
326e0c4386eSCy Schubert #ifdef CMP_FALLBACK_EST
327e0c4386eSCy Schubert # define CMP_FALLBACK_CERT_FILE "cert.pem"
328e0c4386eSCy Schubert #endif
329e0c4386eSCy Schubert 
330e0c4386eSCy Schubert #define X509_OBJECT_get0_X509(obj)                                      \
331e0c4386eSCy Schubert     ((obj) == NULL || (obj)->type != X509_LU_X509 ? NULL : (obj)->data.x509)
332e0c4386eSCy Schubert #define X509_STORE_CTX_set_current_cert(ctx, x) { (ctx)->current_cert = (x); }
333e0c4386eSCy Schubert #define X509_STORE_set_ex_data(ctx, idx, data) \
334e0c4386eSCy Schubert     CRYPTO_set_ex_data(&(ctx)->ex_data, (idx), (data))
335e0c4386eSCy Schubert 
336e0c4386eSCy Schubert typedef int (*X509_STORE_CTX_check_revocation_fn)(X509_STORE_CTX *ctx);
337e0c4386eSCy Schubert #define X509_STORE_CTX_set_error_depth(ctx, depth) \
338e0c4386eSCy Schubert     { (ctx)->error_depth = (depth); }
339e0c4386eSCy Schubert #define EVP_PKEY_up_ref(x) ((x)->references++)
340e0c4386eSCy Schubert /* should not report missing blank line: */
341e0c4386eSCy Schubert DECLARE_STACK_OF(OPENSSL_CSTRING)
342e0c4386eSCy Schubert bool UTIL_iterate_dir(int (*fn)(const char *file, void *arg), void *arg,
343e0c4386eSCy Schubert                       const char *path, bool recursive);
344e0c4386eSCy Schubert size_t UTIL_url_encode(
345e0c4386eSCy Schubert                        size_t *size_needed
346e0c4386eSCy Schubert                        );
347e0c4386eSCy Schubert size_t UTIL_url_encode(const char  *source,
348e0c4386eSCy Schubert                        char        *destination,
349e0c4386eSCy Schubert                        size_t      destination_len,
350e0c4386eSCy Schubert                        size_t      *size_needed);
351e0c4386eSCy Schubert #error well. oops.
352e0c4386eSCy Schubert 
f()353e0c4386eSCy Schubert int f()
354e0c4386eSCy Schubert {
355e0c4386eSCy Schubert     c;
356a7148ab3SEnji Cooper     if (1)
357e0c4386eSCy Schubert         c;
358e0c4386eSCy Schubert     c;
359e0c4386eSCy Schubert     if (1)
360e0c4386eSCy Schubert         if (2)
361e0c4386eSCy Schubert         { /*@ brace after 'if' not on same line just to construct case */
362e0c4386eSCy Schubert             c;
363e0c4386eSCy Schubert         }
364e0c4386eSCy Schubert     e;
365e0c4386eSCy Schubert     const usign = {
366e0c4386eSCy Schubert                    0xDF,
367e0c4386eSCy Schubert                    {
368e0c4386eSCy Schubert                     dd
369e0c4386eSCy Schubert                    },
370e0c4386eSCy Schubert                    dd
371e0c4386eSCy Schubert     };
372e0c4386eSCy Schubert     const unsign = {
373e0c4386eSCy Schubert                     0xDF, {
374e0c4386eSCy Schubert                            dd
375e0c4386eSCy Schubert                     },
376e0c4386eSCy Schubert                     dd
377e0c4386eSCy Schubert     };
378e0c4386eSCy Schubert }
379e0c4386eSCy Schubert const unsigned char trans_id[OSSL_CMP_TRANSACTIONID_LENGTH] = {
380e0c4386eSCy Schubert                                                                0xDF,
381e0c4386eSCy Schubert };
382e0c4386eSCy Schubert const unsigned char trans_id[OSSL_CMP_TRANSACTIONID_LENGTH] =
383e0c4386eSCy Schubert     {
384e0c4386eSCy Schubert      0xDF,
385e0c4386eSCy Schubert     };
386e0c4386eSCy Schubert typedef
387e0c4386eSCy Schubert int
388e0c4386eSCy Schubert a;
389e0c4386eSCy Schubert 
390e0c4386eSCy Schubert typedef
391e0c4386eSCy Schubert struct
392e0c4386eSCy Schubert {
393e0c4386eSCy Schubert     int a;
394e0c4386eSCy Schubert } b;
395e0c4386eSCy Schubert typedef enum {
396e0c4386eSCy Schubert               w = 0
397e0c4386eSCy Schubert } e_type;
398e0c4386eSCy Schubert typedef struct {
399e0c4386eSCy Schubert     enum {
400e0c4386eSCy Schubert           w = 0
401e0c4386eSCy Schubert     } e_type;
402e0c4386eSCy Schubert     enum {
403e0c4386eSCy Schubert           w = 0
404e0c4386eSCy Schubert     } e_type;
405e0c4386eSCy Schubert } e;
406e0c4386eSCy Schubert struct s_type {
407e0c4386eSCy Schubert     enum e_type {
408e0c4386eSCy Schubert                  w = 0
409e0c4386eSCy Schubert     };
410e0c4386eSCy Schubert };
411e0c4386eSCy Schubert struct s_type
412e0c4386eSCy Schubert {
413e0c4386eSCy Schubert     enum e_type {
414e0c4386eSCy Schubert                  w = 0
415e0c4386eSCy Schubert     };
416e0c4386eSCy Schubert     enum e2_type {
417e0c4386eSCy Schubert                   w = 0
418e0c4386eSCy Schubert     };
419e0c4386eSCy Schubert };
420e0c4386eSCy Schubert 
421e0c4386eSCy Schubert #define X  1          + 1
422e0c4386eSCy Schubert #define Y  /* .. */ 2 + 2
423e0c4386eSCy Schubert #define Z  3          + 3 * (*a++)
424e0c4386eSCy Schubert 
425e0c4386eSCy Schubert static varref cmp_vars[] = { /* comment.  comment?  comment!  */
426e0c4386eSCy Schubert     {&opt_config}, {&opt_section},
427e0c4386eSCy Schubert 
428e0c4386eSCy Schubert     {&opt_server}, {&opt_proxy}, {&opt_path},
429e0c4386eSCy Schubert };
430e0c4386eSCy Schubert 
431e0c4386eSCy Schubert #define SWITCH(x)                               \
432e0c4386eSCy Schubert     switch (x) {                                \
433e0c4386eSCy Schubert     case 0:                                     \
434e0c4386eSCy Schubert         break;                                  \
435e0c4386eSCy Schubert     default:                                    \
436e0c4386eSCy Schubert         break;                                  \
437e0c4386eSCy Schubert     }
438e0c4386eSCy Schubert 
439e0c4386eSCy Schubert #define DEFINE_SET_GET_BASE_TEST(PREFIX, SETN, GETN, DUP, FIELD, TYPE, ERR, \
440e0c4386eSCy Schubert                                  DEFAULT, NEW, FREE) \
441e0c4386eSCy Schubert     static int execute_CTX_##SETN##_##GETN##_##FIELD( \
442e0c4386eSCy Schubert                                                      TEST_FIXTURE *fixture) \
443e0c4386eSCy Schubert     { \
444e0c4386eSCy Schubert         CTX *ctx = fixture->ctx; \
445e0c4386eSCy Schubert         int (*set_fn)(CTX *ctx, TYPE) = \
446e0c4386eSCy Schubert             (int (*)(CTX *ctx, TYPE))PREFIX##_##SETN##_##FIELD; \
447e0c4386eSCy Schubert         /* comment */ \
448e0c4386eSCy Schubert     }
449e0c4386eSCy Schubert 
450e0c4386eSCy Schubert union un var; /* struct/union/enum in variable type */
f()451e0c4386eSCy Schubert struct provider_store_st *f() /* struct/union/enum in function return type */
452e0c4386eSCy Schubert {
453e0c4386eSCy Schubert }
f(struct pem_pass_data * data)454e0c4386eSCy Schubert static void f(struct pem_pass_data *data) /* struct/union/enum in arg list */
455e0c4386eSCy Schubert {
456e0c4386eSCy Schubert }
457e0c4386eSCy Schubert 
fun(void)458e0c4386eSCy Schubert static void *fun(void)
459e0c4386eSCy Schubert {
460e0c4386eSCy Schubert     if (pem_name != NULL)
461e0c4386eSCy Schubert         /* comment */
462e0c4386eSCy Schubert         return NULL;
463e0c4386eSCy Schubert 
464e0c4386eSCy Schubert label0:
465e0c4386eSCy Schubert  label1: /* allow special indent 1 for label at outermost level in body */
466e0c4386eSCy Schubert     do {
467e0c4386eSCy Schubert     label2:
468e0c4386eSCy Schubert         size_t available_len, data_len;
469e0c4386eSCy Schubert         const char *curr = txt, *next = txt;
470e0c4386eSCy Schubert         char *tmp;
471e0c4386eSCy Schubert 
472e0c4386eSCy Schubert         {
473e0c4386eSCy Schubert         label3:
474e0c4386eSCy Schubert         }
475e0c4386eSCy Schubert     } while (1);
476e0c4386eSCy Schubert 
477e0c4386eSCy Schubert     char *intraline_string_with_comment_delimiters_and_dbl_space = "1  /*1";
478e0c4386eSCy Schubert     char *multiline_string_with_comment_delimiters_and_dbl_space = "1  /*1\
479e0c4386eSCy Schubert 2222222\'22222222222222222\"222222222" "33333  /*3333333333" "44  /*44444444444\
480e0c4386eSCy Schubert 55555555555555\
481e0c4386eSCy Schubert 6666";
482e0c4386eSCy Schubert }
483e0c4386eSCy Schubert 
484e0c4386eSCy Schubert ASN1_CHOICE(OSSL_CRMF_POPO) = {
485e0c4386eSCy Schubert     ASN1_IMP(OSSL_CRMF_POPO, value.raVerified, ASN1_NULL, 0),
486e0c4386eSCy Schubert     ASN1_EXP(OSSL_CRMF_POPO, value.keyAgreement, OSSL_CRMF_POPOPRIVKEY, 3)
487e0c4386eSCy Schubert } ASN1_CHOICE_END(OSSL_CRMF_POPO)
488e0c4386eSCy Schubert IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_POPO)
489e0c4386eSCy Schubert 
490e0c4386eSCy Schubert ASN1_ADB(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) = {
491e0c4386eSCy Schubert     ADB_ENTRY(NID_id_regCtrl_regToken,
492e0c4386eSCy Schubert               ASN1_SIMPLE(OSSL_CRMF_ATTRIBUTETYPEANDVALUE,
493e0c4386eSCy Schubert                           value.regToken, ASN1_UTF8STRING)),
494e0c4386eSCy Schubert } ASN1_ADB_END(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, 0, type, 0,
495e0c4386eSCy Schubert                &attributetypeandvalue_default_tt, NULL);
496e0c4386eSCy Schubert 
ASN1_ITEM_TEMPLATE(OSSL_CRMF_MSGS)497e0c4386eSCy Schubert ASN1_ITEM_TEMPLATE(OSSL_CRMF_MSGS) =
498e0c4386eSCy Schubert     ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
499e0c4386eSCy Schubert                           OSSL_CRMF_MSGS, OSSL_CRMF_MSG)
500e0c4386eSCy Schubert ASN1_ITEM_TEMPLATE_END(OSSL_CRMF_MSGS)
501e0c4386eSCy Schubert 
502e0c4386eSCy Schubert void f_looong_body_200()
503e0c4386eSCy Schubert { /* function body length up to 200 lines accepted */
504e0c4386eSCy Schubert     ;
505e0c4386eSCy Schubert     ;
506e0c4386eSCy Schubert     ;
507e0c4386eSCy Schubert     ;
508e0c4386eSCy Schubert     ;
509e0c4386eSCy Schubert     ;
510e0c4386eSCy Schubert     ;
511e0c4386eSCy Schubert     ;
512e0c4386eSCy Schubert     ;
513e0c4386eSCy Schubert     ;
514e0c4386eSCy Schubert     ;
515e0c4386eSCy Schubert     ;
516e0c4386eSCy Schubert     ;
517e0c4386eSCy Schubert     ;
518e0c4386eSCy Schubert     ;
519e0c4386eSCy Schubert     ;
520e0c4386eSCy Schubert     ;
521e0c4386eSCy Schubert     ;
522e0c4386eSCy Schubert     ;
523e0c4386eSCy Schubert     ;
524e0c4386eSCy Schubert     ;
525e0c4386eSCy Schubert     ;
526e0c4386eSCy Schubert     ;
527e0c4386eSCy Schubert     ;
528e0c4386eSCy Schubert     ;
529e0c4386eSCy Schubert     ;
530e0c4386eSCy Schubert     ;
531e0c4386eSCy Schubert     ;
532e0c4386eSCy Schubert     ;
533e0c4386eSCy Schubert     ;
534e0c4386eSCy Schubert     ;
535e0c4386eSCy Schubert     ;
536e0c4386eSCy Schubert     ;
537e0c4386eSCy Schubert     ;
538e0c4386eSCy Schubert     ;
539e0c4386eSCy Schubert     ;
540e0c4386eSCy Schubert     ;
541e0c4386eSCy Schubert     ;
542e0c4386eSCy Schubert     ;
543e0c4386eSCy Schubert     ;
544e0c4386eSCy Schubert     ;
545e0c4386eSCy Schubert     ;
546e0c4386eSCy Schubert     ;
547e0c4386eSCy Schubert     ;
548e0c4386eSCy Schubert     ;
549e0c4386eSCy Schubert     ;
550e0c4386eSCy Schubert     ;
551e0c4386eSCy Schubert     ;
552e0c4386eSCy Schubert     ;
553e0c4386eSCy Schubert     ;
554e0c4386eSCy Schubert     ;
555e0c4386eSCy Schubert     ;
556e0c4386eSCy Schubert     ;
557e0c4386eSCy Schubert     ;
558e0c4386eSCy Schubert     ;
559e0c4386eSCy Schubert     ;
560e0c4386eSCy Schubert     ;
561e0c4386eSCy Schubert     ;
562e0c4386eSCy Schubert     ;
563e0c4386eSCy Schubert     ;
564e0c4386eSCy Schubert     ;
565e0c4386eSCy Schubert     ;
566e0c4386eSCy Schubert     ;
567e0c4386eSCy Schubert     ;
568e0c4386eSCy Schubert     ;
569e0c4386eSCy Schubert     ;
570e0c4386eSCy Schubert     ;
571e0c4386eSCy Schubert     ;
572e0c4386eSCy Schubert     ;
573e0c4386eSCy Schubert     ;
574e0c4386eSCy Schubert     ;
575e0c4386eSCy Schubert     ;
576e0c4386eSCy Schubert     ;
577e0c4386eSCy Schubert     ;
578e0c4386eSCy Schubert     ;
579e0c4386eSCy Schubert     ;
580e0c4386eSCy Schubert     ;
581e0c4386eSCy Schubert     ;
582e0c4386eSCy Schubert     ;
583e0c4386eSCy Schubert     ;
584e0c4386eSCy Schubert     ;
585e0c4386eSCy Schubert     ;
586e0c4386eSCy Schubert     ;
587e0c4386eSCy Schubert     ;
588e0c4386eSCy Schubert     ;
589e0c4386eSCy Schubert     ;
590e0c4386eSCy Schubert     ;
591e0c4386eSCy Schubert     ;
592e0c4386eSCy Schubert     ;
593e0c4386eSCy Schubert     ;
594e0c4386eSCy Schubert     ;
595e0c4386eSCy Schubert     ;
596e0c4386eSCy Schubert     ;
597e0c4386eSCy Schubert     ;
598e0c4386eSCy Schubert     ;
599e0c4386eSCy Schubert     ;
600e0c4386eSCy Schubert     ;
601e0c4386eSCy Schubert     ;
602e0c4386eSCy Schubert     ;
603e0c4386eSCy Schubert     ;
604e0c4386eSCy Schubert     ;
605e0c4386eSCy Schubert     ;
606e0c4386eSCy Schubert     ;
607e0c4386eSCy Schubert     ;
608e0c4386eSCy Schubert     ;
609e0c4386eSCy Schubert     ;
610e0c4386eSCy Schubert     ;
611e0c4386eSCy Schubert     ;
612e0c4386eSCy Schubert     ;
613e0c4386eSCy Schubert     ;
614e0c4386eSCy Schubert     ;
615e0c4386eSCy Schubert     ;
616e0c4386eSCy Schubert     ;
617e0c4386eSCy Schubert     ;
618e0c4386eSCy Schubert     ;
619e0c4386eSCy Schubert     ;
620e0c4386eSCy Schubert     ;
621e0c4386eSCy Schubert     ;
622e0c4386eSCy Schubert     ;
623e0c4386eSCy Schubert     ;
624e0c4386eSCy Schubert     ;
625e0c4386eSCy Schubert     ;
626e0c4386eSCy Schubert     ;
627e0c4386eSCy Schubert     ;
628e0c4386eSCy Schubert     ;
629e0c4386eSCy Schubert     ;
630e0c4386eSCy Schubert     ;
631e0c4386eSCy Schubert     ;
632e0c4386eSCy Schubert     ;
633e0c4386eSCy Schubert     ;
634e0c4386eSCy Schubert     ;
635e0c4386eSCy Schubert     ;
636e0c4386eSCy Schubert     ;
637e0c4386eSCy Schubert     ;
638e0c4386eSCy Schubert     ;
639e0c4386eSCy Schubert     ;
640e0c4386eSCy Schubert     ;
641e0c4386eSCy Schubert     ;
642e0c4386eSCy Schubert     ;
643e0c4386eSCy Schubert     ;
644e0c4386eSCy Schubert     ;
645e0c4386eSCy Schubert     ;
646e0c4386eSCy Schubert     ;
647e0c4386eSCy Schubert     ;
648e0c4386eSCy Schubert     ;
649e0c4386eSCy Schubert     ;
650e0c4386eSCy Schubert     ;
651e0c4386eSCy Schubert     ;
652e0c4386eSCy Schubert     ;
653e0c4386eSCy Schubert     ;
654e0c4386eSCy Schubert     ;
655e0c4386eSCy Schubert     ;
656e0c4386eSCy Schubert     ;
657e0c4386eSCy Schubert     ;
658e0c4386eSCy Schubert     ;
659e0c4386eSCy Schubert     ;
660e0c4386eSCy Schubert     ;
661e0c4386eSCy Schubert     ;
662e0c4386eSCy Schubert     ;
663e0c4386eSCy Schubert     ;
664e0c4386eSCy Schubert     ;
665e0c4386eSCy Schubert     ;
666e0c4386eSCy Schubert     ;
667e0c4386eSCy Schubert     ;
668e0c4386eSCy Schubert     ;
669e0c4386eSCy Schubert     ;
670e0c4386eSCy Schubert     ;
671e0c4386eSCy Schubert     ;
672e0c4386eSCy Schubert     ;
673e0c4386eSCy Schubert     ;
674e0c4386eSCy Schubert     ;
675e0c4386eSCy Schubert     ;
676e0c4386eSCy Schubert     ;
677e0c4386eSCy Schubert     ;
678e0c4386eSCy Schubert     ;
679e0c4386eSCy Schubert     ;
680e0c4386eSCy Schubert     ;
681e0c4386eSCy Schubert     ;
682e0c4386eSCy Schubert     ;
683e0c4386eSCy Schubert     ;
684e0c4386eSCy Schubert     ;
685e0c4386eSCy Schubert     ;
686e0c4386eSCy Schubert     ;
687e0c4386eSCy Schubert     ;
688e0c4386eSCy Schubert     ;
689e0c4386eSCy Schubert     ;
690e0c4386eSCy Schubert     ;
691e0c4386eSCy Schubert     ;
692e0c4386eSCy Schubert     ;
693e0c4386eSCy Schubert     ;
694e0c4386eSCy Schubert     ;
695e0c4386eSCy Schubert     ;
696e0c4386eSCy Schubert     ;
697e0c4386eSCy Schubert     ;
698e0c4386eSCy Schubert     ;
699e0c4386eSCy Schubert     ;
700e0c4386eSCy Schubert     ;
701e0c4386eSCy Schubert     ;
702e0c4386eSCy Schubert     ;
703e0c4386eSCy Schubert     ;
704e0c4386eSCy Schubert }
705e0c4386eSCy Schubert 
f_looong_body_201()706e0c4386eSCy Schubert void f_looong_body_201()
707e0c4386eSCy Schubert { /* function body length > 200 lines, but LONG BODY marker present */
708e0c4386eSCy Schubert     ;
709e0c4386eSCy Schubert     ;
710e0c4386eSCy Schubert     ;
711e0c4386eSCy Schubert     ;
712e0c4386eSCy Schubert     ;
713e0c4386eSCy Schubert     ;
714e0c4386eSCy Schubert     ;
715e0c4386eSCy Schubert     ;
716e0c4386eSCy Schubert     ;
717e0c4386eSCy Schubert     ;
718e0c4386eSCy Schubert     ;
719e0c4386eSCy Schubert     ;
720e0c4386eSCy Schubert     ;
721e0c4386eSCy Schubert     ;
722e0c4386eSCy Schubert     ;
723e0c4386eSCy Schubert     ;
724e0c4386eSCy Schubert     ;
725e0c4386eSCy Schubert     ;
726e0c4386eSCy Schubert     ;
727e0c4386eSCy Schubert     ;
728e0c4386eSCy Schubert     ;
729e0c4386eSCy Schubert     ;
730e0c4386eSCy Schubert     ;
731e0c4386eSCy Schubert     ;
732e0c4386eSCy Schubert     ;
733e0c4386eSCy Schubert     ;
734e0c4386eSCy Schubert     ;
735e0c4386eSCy Schubert     ;
736e0c4386eSCy Schubert     ;
737e0c4386eSCy Schubert     ;
738e0c4386eSCy Schubert     ;
739e0c4386eSCy Schubert     ;
740e0c4386eSCy Schubert     ;
741e0c4386eSCy Schubert     ;
742e0c4386eSCy Schubert     ;
743e0c4386eSCy Schubert     ;
744e0c4386eSCy Schubert     ;
745e0c4386eSCy Schubert     ;
746e0c4386eSCy Schubert     ;
747e0c4386eSCy Schubert     ;
748e0c4386eSCy Schubert     ;
749e0c4386eSCy Schubert     ;
750e0c4386eSCy Schubert     ;
751e0c4386eSCy Schubert     ;
752e0c4386eSCy Schubert     ;
753e0c4386eSCy Schubert     ;
754e0c4386eSCy Schubert     ;
755e0c4386eSCy Schubert     ;
756e0c4386eSCy Schubert     ;
757e0c4386eSCy Schubert     ;
758e0c4386eSCy Schubert     ;
759e0c4386eSCy Schubert     ;
760e0c4386eSCy Schubert     ;
761e0c4386eSCy Schubert     ;
762e0c4386eSCy Schubert     ;
763e0c4386eSCy Schubert     ;
764e0c4386eSCy Schubert     ;
765e0c4386eSCy Schubert     ;
766e0c4386eSCy Schubert     ;
767e0c4386eSCy Schubert     ;
768e0c4386eSCy Schubert     ;
769e0c4386eSCy Schubert     ;
770e0c4386eSCy Schubert     ;
771e0c4386eSCy Schubert     ;
772e0c4386eSCy Schubert     ;
773e0c4386eSCy Schubert     ;
774e0c4386eSCy Schubert     ;
775e0c4386eSCy Schubert     ;
776e0c4386eSCy Schubert     ;
777e0c4386eSCy Schubert     ;
778e0c4386eSCy Schubert     ;
779e0c4386eSCy Schubert     ;
780e0c4386eSCy Schubert     ;
781e0c4386eSCy Schubert     ;
782e0c4386eSCy Schubert     ;
783e0c4386eSCy Schubert     ;
784e0c4386eSCy Schubert     ;
785e0c4386eSCy Schubert     ;
786e0c4386eSCy Schubert     ;
787e0c4386eSCy Schubert     ;
788e0c4386eSCy Schubert     ;
789e0c4386eSCy Schubert     ;
790e0c4386eSCy Schubert     ;
791e0c4386eSCy Schubert     ;
792e0c4386eSCy Schubert     ;
793e0c4386eSCy Schubert     ;
794e0c4386eSCy Schubert     ;
795e0c4386eSCy Schubert     ;
796e0c4386eSCy Schubert     ;
797e0c4386eSCy Schubert     ;
798e0c4386eSCy Schubert     ;
799e0c4386eSCy Schubert     ;
800e0c4386eSCy Schubert     ;
801e0c4386eSCy Schubert     ;
802e0c4386eSCy Schubert     ;
803e0c4386eSCy Schubert     ;
804e0c4386eSCy Schubert     ;
805e0c4386eSCy Schubert     ;
806e0c4386eSCy Schubert     ;
807e0c4386eSCy Schubert     ;
808e0c4386eSCy Schubert     ;
809e0c4386eSCy Schubert     ;
810e0c4386eSCy Schubert     ;
811e0c4386eSCy Schubert     ;
812e0c4386eSCy Schubert     ;
813e0c4386eSCy Schubert     ;
814e0c4386eSCy Schubert     ;
815e0c4386eSCy Schubert     ;
816e0c4386eSCy Schubert     ;
817e0c4386eSCy Schubert     ;
818e0c4386eSCy Schubert     ;
819e0c4386eSCy Schubert     ;
820e0c4386eSCy Schubert     ;
821e0c4386eSCy Schubert     ;
822e0c4386eSCy Schubert     ;
823e0c4386eSCy Schubert     ;
824e0c4386eSCy Schubert     ;
825e0c4386eSCy Schubert     ;
826e0c4386eSCy Schubert     ;
827e0c4386eSCy Schubert     ;
828e0c4386eSCy Schubert     ;
829e0c4386eSCy Schubert     ;
830e0c4386eSCy Schubert     ;
831e0c4386eSCy Schubert     ;
832e0c4386eSCy Schubert     ;
833e0c4386eSCy Schubert     ;
834e0c4386eSCy Schubert     ;
835e0c4386eSCy Schubert     ;
836e0c4386eSCy Schubert     ;
837e0c4386eSCy Schubert     ;
838e0c4386eSCy Schubert     ;
839e0c4386eSCy Schubert     ;
840e0c4386eSCy Schubert     ;
841e0c4386eSCy Schubert     ;
842e0c4386eSCy Schubert     ;
843e0c4386eSCy Schubert     ;
844e0c4386eSCy Schubert     ;
845e0c4386eSCy Schubert     ;
846e0c4386eSCy Schubert     ;
847e0c4386eSCy Schubert     ;
848e0c4386eSCy Schubert     ;
849e0c4386eSCy Schubert     ;
850e0c4386eSCy Schubert     ;
851e0c4386eSCy Schubert     ;
852e0c4386eSCy Schubert     ;
853e0c4386eSCy Schubert     ;
854e0c4386eSCy Schubert     ;
855e0c4386eSCy Schubert     ;
856e0c4386eSCy Schubert     ;
857e0c4386eSCy Schubert     ;
858e0c4386eSCy Schubert     ;
859e0c4386eSCy Schubert     ;
860e0c4386eSCy Schubert     ;
861e0c4386eSCy Schubert     ;
862e0c4386eSCy Schubert     ;
863e0c4386eSCy Schubert     ;
864e0c4386eSCy Schubert     ;
865e0c4386eSCy Schubert     ;
866e0c4386eSCy Schubert     ;
867e0c4386eSCy Schubert     ;
868e0c4386eSCy Schubert     ;
869e0c4386eSCy Schubert     ;
870e0c4386eSCy Schubert     ;
871e0c4386eSCy Schubert     ;
872e0c4386eSCy Schubert     ;
873e0c4386eSCy Schubert     ;
874e0c4386eSCy Schubert     ;
875e0c4386eSCy Schubert     ;
876e0c4386eSCy Schubert     ;
877e0c4386eSCy Schubert     ;
878e0c4386eSCy Schubert     ;
879e0c4386eSCy Schubert     ;
880e0c4386eSCy Schubert     ;
881e0c4386eSCy Schubert     ;
882e0c4386eSCy Schubert     ;
883e0c4386eSCy Schubert     ;
884e0c4386eSCy Schubert     ;
885e0c4386eSCy Schubert     ;
886e0c4386eSCy Schubert     ;
887e0c4386eSCy Schubert     ;
888e0c4386eSCy Schubert     ;
889e0c4386eSCy Schubert     ;
890e0c4386eSCy Schubert     ;
891e0c4386eSCy Schubert     ;
892e0c4386eSCy Schubert     ;
893e0c4386eSCy Schubert     ;
894e0c4386eSCy Schubert     ;
895e0c4386eSCy Schubert     ;
896e0c4386eSCy Schubert     ;
897e0c4386eSCy Schubert     ;
898e0c4386eSCy Schubert     ;
899e0c4386eSCy Schubert     ;
900e0c4386eSCy Schubert     ;
901e0c4386eSCy Schubert     ;
902e0c4386eSCy Schubert     ;
903e0c4386eSCy Schubert     ;
904e0c4386eSCy Schubert     ;
905e0c4386eSCy Schubert     ;
906e0c4386eSCy Schubert     ;
907e0c4386eSCy Schubert     ;
908e0c4386eSCy Schubert     ;
909e0c4386eSCy Schubert     ;
910e0c4386eSCy Schubert }
911