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 extra SPC in format-tagged multi-line comment
21 * trailing multi-line comment
24 if (ctx == NULL) { /* non-leading end-of-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 /* should not trigger: constant on LHS of comparison or assignment operator */
157 const OPTIONS passwd_options[] = {
158 {"aixmd5", OPT_AIXMD5, '-', "AIX MD5-based password algorithm"},
159 #if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
160 {"crypt", OPT_CRYPT, '-', "Standard Unix password algorithm (default)"},
175 typedef OSSL_CMP_MSG *(*cmp_srv_process_cb_t)
176 (OSSL_CMP_SRV_CTX *ctx, OSSL_CMP_MSG *msg)
187 { /*@ brace after 'if' not on same line just to construct case */
205 const unsigned char trans_id[OSSL_CMP_TRANSACTIONID_LENGTH] = {
208 const unsigned char trans_id[OSSL_CMP_TRANSACTIONID_LENGTH] =
248 #define Y /* .. */ 2 + 2
249 #define Z 3 + 3 * (*a++)
251 static varref cmp_vars[] = { /* comment. comment? comment! */
252 {&opt_config}, {&opt_section},
254 {&opt_server}, {&opt_proxy}, {&opt_path},
265 #define DEFINE_SET_GET_BASE_TEST(PREFIX, SETN, GETN, DUP, FIELD, TYPE, ERR, \
266 DEFAULT, NEW, FREE) \
267 static int execute_CTX_##SETN##_##GETN##_##FIELD( \
268 TEST_FIXTURE *fixture) \
270 CTX *ctx = fixture->ctx; \
271 int (*set_fn)(CTX *ctx, TYPE) = \
272 (int (*)(CTX *ctx, TYPE))PREFIX##_##SETN##_##FIELD; \
276 union un var; /* struct/union/enum in variable type */
277 struct provider_store_st *f() /* struct/union/enum in function return type */
280 static void f(struct pem_pass_data *data) /* struct/union/enum in arg list */
284 static void *fun(void)
286 if (pem_name != NULL)
291 label1: /* allow special indent 1 for label at outermost level in body */
294 size_t available_len, data_len;
295 const char *curr = txt, *next = txt;
303 char *intraline_string_with_comment_delimiters_and_dbl_space = "1 /*1";
304 char *multiline_string_with_comment_delimiters_and_dbl_space = "1 /*1\
305 2222222\'22222222222222222\"222222222" "33333 /*3333333333" "44 /*44444444444\
310 ASN1_CHOICE(OSSL_CRMF_POPO) = {
311 ASN1_IMP(OSSL_CRMF_POPO, value.raVerified, ASN1_NULL, 0),
312 ASN1_EXP(OSSL_CRMF_POPO, value.keyAgreement, OSSL_CRMF_POPOPRIVKEY, 3)
313 } ASN1_CHOICE_END(OSSL_CRMF_POPO)
314 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_POPO)
316 ASN1_ADB(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) = {
317 ADB_ENTRY(NID_id_regCtrl_regToken,
318 ASN1_SIMPLE(OSSL_CRMF_ATTRIBUTETYPEANDVALUE,
319 value.regToken, ASN1_UTF8STRING)),
320 } ASN1_ADB_END(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, 0, type, 0,
321 &attributetypeandvalue_default_tt, NULL);
323 ASN1_ITEM_TEMPLATE(OSSL_CRMF_MSGS) =
324 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
325 OSSL_CRMF_MSGS, OSSL_CRMF_MSG)
326 ASN1_ITEM_TEMPLATE_END(OSSL_CRMF_MSGS)
328 void f_looong_body_200()
329 { /* function body length up to 200 lines accepted */
532 void f_looong_body_201()
533 { /* function body length > 200 lines, but LONG BODY marker present */