2 * Copyright 2007-2022 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright Siemens AG 2015-2022
5 * Licensed under the Apache License 2.0 (the "License"). You may not use
6 * this file except in compliance with the License. You can obtain a copy
7 * in the file LICENSE in the source distribution or at
8 * https://www.openssl.org/source/license.html
12 * A collection of test cases where check-format.pl should not report issues.
13 * There are some known false positives, though, which are marked below.
26 * allow extra SPC in format-tagged multi-line comment
29 * trailing multi-line comment
52 * multi-line comment should not disturb detection of local decls
55 /* intra-line comment should not disturb detection of local decls */
58 /* intra-line comment should not disturb detection of end of local decls */
59 if (ctx == NULL) { /* non-leading end-of-line comment */
60 if (/* comment after '(' */ pem_name != NULL /* comment before ')' */)
61 /* entire-line comment indent usually like for the following line */
62 return NULL; /* hanging indent also for this line after comment */
63 /* leading comment has same indentation as normal code */ stmt;
64 /* entire-line comment may have same indent as normal code */
75 if (1) /* bad style: just part of control structure depends on #if */
77 if (2) /*@ resulting false positive */
79 c; /*@ resulting false positive */
97 1; while (2); /*@ more than one stmt just to construct case */
106 else do /*@ (non-brace) code before 'do' just to construct case */
110 b); do /*@ (non-brace) code before 'do' just to construct case */
115 b); do /*@ (non-brace) code before 'do' just to construct case */
121 do f(c, c); /*@ (non-brace) code after 'do' just to construct case */
130 b); else /*@ (non-brace) code before 'else' just to construct case */
136 { /*@ brace after 'if' not on same line just to construct case */
140 /* this comment is correctly indented if it refers to the following line */
145 } else /*@ no brace after 'else' just to construct case */
163 EVP_MAC_CTX *new_mac_ctx;
165 if (ctx->pkey == NULL)
170 /* This should be dead code */
188 /* should not trigger: constant on LHS of comparison or assignment operator */
191 int ret, was_NULL = *certs == NULL;
193 const OPTIONS passwd_options[] = {
194 {"aixmd5", OPT_AIXMD5, '-', "AIX MD5-based password algorithm"},
195 #if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
196 {"crypt", OPT_CRYPT, '-', "Standard Unix password algorithm (default)"},
211 typedef OSSL_CMP_MSG *(*cmp_srv_process_cb_t)
212 (OSSL_CMP_SRV_CTX *ctx, OSSL_CMP_MSG *msg)
223 { /*@ brace after 'if' not on same line just to construct case */
241 const unsigned char trans_id[OSSL_CMP_TRANSACTIONID_LENGTH] = {
244 const unsigned char trans_id[OSSL_CMP_TRANSACTIONID_LENGTH] =
284 #define Y /* .. */ 2 + 2
285 #define Z 3 + 3 * (*a++)
287 static varref cmp_vars[] = { /* comment. comment? comment! */
288 {&opt_config}, {&opt_section},
290 {&opt_server}, {&opt_proxy}, {&opt_path},
301 #define DEFINE_SET_GET_BASE_TEST(PREFIX, SETN, GETN, DUP, FIELD, TYPE, ERR, \
302 DEFAULT, NEW, FREE) \
303 static int execute_CTX_##SETN##_##GETN##_##FIELD( \
304 TEST_FIXTURE *fixture) \
306 CTX *ctx = fixture->ctx; \
307 int (*set_fn)(CTX *ctx, TYPE) = \
308 (int (*)(CTX *ctx, TYPE))PREFIX##_##SETN##_##FIELD; \
312 union un var; /* struct/union/enum in variable type */
313 struct provider_store_st *f() /* struct/union/enum in function return type */
316 static void f(struct pem_pass_data *data) /* struct/union/enum in arg list */
320 static void *fun(void)
322 if (pem_name != NULL)
327 label1: /* allow special indent 1 for label at outermost level in body */
330 size_t available_len, data_len;
331 const char *curr = txt, *next = txt;
339 char *intraline_string_with_comment_delimiters_and_dbl_space = "1 /*1";
340 char *multiline_string_with_comment_delimiters_and_dbl_space = "1 /*1\
341 2222222\'22222222222222222\"222222222" "33333 /*3333333333" "44 /*44444444444\
346 ASN1_CHOICE(OSSL_CRMF_POPO) = {
347 ASN1_IMP(OSSL_CRMF_POPO, value.raVerified, ASN1_NULL, 0),
348 ASN1_EXP(OSSL_CRMF_POPO, value.keyAgreement, OSSL_CRMF_POPOPRIVKEY, 3)
349 } ASN1_CHOICE_END(OSSL_CRMF_POPO)
350 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_POPO)
352 ASN1_ADB(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) = {
353 ADB_ENTRY(NID_id_regCtrl_regToken,
354 ASN1_SIMPLE(OSSL_CRMF_ATTRIBUTETYPEANDVALUE,
355 value.regToken, ASN1_UTF8STRING)),
356 } ASN1_ADB_END(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, 0, type, 0,
357 &attributetypeandvalue_default_tt, NULL);
359 ASN1_ITEM_TEMPLATE(OSSL_CRMF_MSGS) =
360 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
361 OSSL_CRMF_MSGS, OSSL_CRMF_MSG)
362 ASN1_ITEM_TEMPLATE_END(OSSL_CRMF_MSGS)
364 void f_looong_body_200()
365 { /* function body length up to 200 lines accepted */
568 void f_looong_body_201()
569 { /* function body length > 200 lines, but LONG BODY marker present */