2 * Copyright 2007-2019 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 */
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 */
33 if (1) /* bad style: just part of control structure depends on #if */
35 if (2) /*@ resulting false positive */
37 c; /*@ resulting false positive */
55 1; while (2); /*@ more than one stmt just to construct case */
64 else do /*@ (non-brace) code before 'do' just to construct case */
68 b); do /*@ (non-brace) code before 'do' just to construct case */
73 b); do /*@ (non-brace) code before 'do' just to construct case */
79 do f(c, c); /*@ (non-brace) code after 'do' just to construct case */
88 b); else /*@ (non-brace) code before 'else' just to construct case */
94 { /*@ brace after 'if' not on same line just to construct case */
98 /* this comment is correctly indented if it refers to the following line */
103 } else /*@ no brace after 'else' just to construct case */
121 EVP_MAC_CTX *new_mac_ctx;
123 if (ctx->pkey == NULL)
128 /* This should be dead code */
146 const OPTIONS passwd_options[] = {
147 {"aixmd5", OPT_AIXMD5, '-', "AIX MD5-based password algorithm"},
148 #if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
149 {"crypt", OPT_CRYPT, '-', "Standard Unix password algorithm (default)"},
164 typedef OSSL_CMP_MSG *(*cmp_srv_process_cb_t)
165 (OSSL_CMP_SRV_CTX *ctx, OSSL_CMP_MSG *msg)
176 { /*@ brace after 'if' not on same line just to construct case */
194 const unsigned char trans_id[OSSL_CMP_TRANSACTIONID_LENGTH] = {
197 const unsigned char trans_id[OSSL_CMP_TRANSACTIONID_LENGTH] =
237 #define Y /* .. */ 2 + 2
240 static varref cmp_vars[] = { /* comment */
241 {&opt_config}, {&opt_section},
243 {&opt_server}, {&opt_proxy}, {&opt_path},
254 #define DEFINE_SET_GET_BASE_TEST(PREFIX, SETN, GETN, DUP, FIELD, TYPE, ERR, \
255 DEFAULT, NEW, FREE) \
256 static int execute_CTX_##SETN##_##GETN##_##FIELD( \
257 TEST_FIXTURE *fixture) \
259 CTX *ctx = fixture->ctx; \
260 int (*set_fn)(CTX *ctx, TYPE) = \
261 (int (*)(CTX *ctx, TYPE))PREFIX##_##SETN##_##FIELD; \
265 /* 'struct' in function header */
266 static int f(struct pem_pass_data *pass_data)
268 if (pass_data == NULL)
272 static void *fun(void)
274 if (pem_name != NULL)
279 size_t available_len, data_len;
280 const char *curr = txt, *next = txt;
284 char *intraline_string_with_comment_delimiters_and_dbl_space = "1 /*1";
285 char *multiline_string_with_comment_delimiters_and_dbl_space = "1 /*1\
286 2222222\'22222222222222222\"222222222" "33333 /*3333333333" "44 /*44444444444\
291 ASN1_CHOICE(OSSL_CRMF_POPO) = {
292 ASN1_IMP(OSSL_CRMF_POPO, value.raVerified, ASN1_NULL, 0),
293 ASN1_EXP(OSSL_CRMF_POPO, value.keyAgreement, OSSL_CRMF_POPOPRIVKEY, 3)
294 } ASN1_CHOICE_END(OSSL_CRMF_POPO)
295 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_POPO)
297 ASN1_ADB(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) = {
298 ADB_ENTRY(NID_id_regCtrl_regToken,
299 ASN1_SIMPLE(OSSL_CRMF_ATTRIBUTETYPEANDVALUE,
300 value.regToken, ASN1_UTF8STRING)),
301 } ASN1_ADB_END(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, 0, type, 0,
302 &attributetypeandvalue_default_tt, NULL);
304 ASN1_ITEM_TEMPLATE(OSSL_CRMF_MSGS) =
305 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
306 OSSL_CRMF_MSGS, OSSL_CRMF_MSG)
307 ASN1_ITEM_TEMPLATE_END(OSSL_CRMF_MSGS)
309 void f_looong_body_200()
310 { /* function body length up to 200 lines accepted */
513 void f_looong_body_201()
514 { /* function body length > 200 lines, but LONG BODY marker present */