2 * Copyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright Nokia 2007-2019
4 * Copyright Siemens AG 2015-2019
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
13 * A collection of test cases where check-format.pl should not report issues.
14 * There are some known false positives, though, which are marked below.
18 * allow double space in format-tagged multi-line comment
21 * trailing multi-line comment
24 if (ctx == NULL) { /* non-leading intra-line comment */
25 if (/* comment after '(' */ pem_name != NULL /* comment before ')' */)
26 /* entire-line comment indent usually like for the following line */
27 return NULL; /* hanging indent also for this line after comment */
28 /* leading comment has same indentation as normal code */ stmt;
29 /* entire-line comment may have same indent as normal code */
40 if (1) /* bad style: just part of control structure depends on #if */
42 if (2) /*@ resulting false positive */
44 c; /*@ resulting false positive */
62 1; while (2); /*@ more than one stmt just to construct case */
71 else do /*@ (non-brace) code before 'do' just to construct case */
75 b); do /*@ (non-brace) code before 'do' just to construct case */
80 b); do /*@ (non-brace) code before 'do' just to construct case */
86 do f(c, c); /*@ (non-brace) code after 'do' just to construct case */
95 b); else /*@ (non-brace) code before 'else' just to construct case */
101 { /*@ brace after 'if' not on same line just to construct case */
105 /* this comment is correctly indented if it refers to the following line */
110 } else /*@ no brace after 'else' just to construct case */
128 EVP_MAC_CTX *new_mac_ctx;
130 if (ctx->pkey == NULL)
135 /* This should be dead code */
153 const OPTIONS passwd_options[] = {
154 {"aixmd5", OPT_AIXMD5, '-', "AIX MD5-based password algorithm"},
155 #if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
156 {"crypt", OPT_CRYPT, '-', "Standard Unix password algorithm (default)"},
171 typedef OSSL_CMP_MSG *(*cmp_srv_process_cb_t)
172 (OSSL_CMP_SRV_CTX *ctx, OSSL_CMP_MSG *msg)
183 { /*@ brace after 'if' not on same line just to construct case */
201 const unsigned char trans_id[OSSL_CMP_TRANSACTIONID_LENGTH] = {
204 const unsigned char trans_id[OSSL_CMP_TRANSACTIONID_LENGTH] =
244 #define Y /* .. */ 2 + 2
245 #define Z 3 + 3 * (*a++)
247 static varref cmp_vars[] = { /* comment. comment? comment! */
248 {&opt_config}, {&opt_section},
250 {&opt_server}, {&opt_proxy}, {&opt_path},
261 #define DEFINE_SET_GET_BASE_TEST(PREFIX, SETN, GETN, DUP, FIELD, TYPE, ERR, \
262 DEFAULT, NEW, FREE) \
263 static int execute_CTX_##SETN##_##GETN##_##FIELD( \
264 TEST_FIXTURE *fixture) \
266 CTX *ctx = fixture->ctx; \
267 int (*set_fn)(CTX *ctx, TYPE) = \
268 (int (*)(CTX *ctx, TYPE))PREFIX##_##SETN##_##FIELD; \
272 /* 'struct' in function header */
273 static int f(struct pem_pass_data *pass_data)
275 if (pass_data == NULL)
279 static void *fun(void)
281 if (pem_name != NULL)
286 label1: /* allow special indent 1 for label at outermost level in body */
289 size_t available_len, data_len;
290 const char *curr = txt, *next = txt;
298 char *intraline_string_with_comment_delimiters_and_dbl_space = "1 /*1";
299 char *multiline_string_with_comment_delimiters_and_dbl_space = "1 /*1\
300 2222222\'22222222222222222\"222222222" "33333 /*3333333333" "44 /*44444444444\
305 ASN1_CHOICE(OSSL_CRMF_POPO) = {
306 ASN1_IMP(OSSL_CRMF_POPO, value.raVerified, ASN1_NULL, 0),
307 ASN1_EXP(OSSL_CRMF_POPO, value.keyAgreement, OSSL_CRMF_POPOPRIVKEY, 3)
308 } ASN1_CHOICE_END(OSSL_CRMF_POPO)
309 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_POPO)
311 ASN1_ADB(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) = {
312 ADB_ENTRY(NID_id_regCtrl_regToken,
313 ASN1_SIMPLE(OSSL_CRMF_ATTRIBUTETYPEANDVALUE,
314 value.regToken, ASN1_UTF8STRING)),
315 } ASN1_ADB_END(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, 0, type, 0,
316 &attributetypeandvalue_default_tt, NULL);
318 ASN1_ITEM_TEMPLATE(OSSL_CRMF_MSGS) =
319 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
320 OSSL_CRMF_MSGS, OSSL_CRMF_MSG)
321 ASN1_ITEM_TEMPLATE_END(OSSL_CRMF_MSGS)
323 void f_looong_body_200()
324 { /* function body length up to 200 lines accepted */
527 void f_looong_body_201()
528 { /* function body length > 200 lines, but LONG BODY marker present */