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 */
73 for (;;) ; /* should not trigger: space before ';' */
74 lab: ; /* should not trigger: space before ';' */
77 if (1) /* bad style: just part of control structure depends on #if */
79 if (2) /*@ resulting false positive */
81 c; /*@ resulting false positive */
99 1; while (2); /*@ more than one stmt just to construct case */
108 else do /*@ (non-brace) code before 'do' just to construct case */
112 b); do /*@ (non-brace) code before 'do' just to construct case */
117 b); do /*@ (non-brace) code before 'do' just to construct case */
123 do f(c, c); /*@ (non-brace) code after 'do' just to construct case */
132 b); else /*@ (non-brace) code before 'else' just to construct case */
138 { /*@ brace after 'if' not on same line just to construct case */
142 /* this comment is correctly indented if it refers to the following line */
147 } else /*@ no brace after 'else' just to construct case */
165 EVP_MAC_CTX *new_mac_ctx;
167 if (ctx->pkey == NULL)
172 /* This should be dead code */
190 /* should not trigger: constant on LHS of comparison or assignment operator */
193 int ret, was_NULL = *certs == NULL;
195 /* should not trigger: no space before binary ... operator */
196 float z = 1e-6 * (-1) * b[+6] * 1e+1 * (a)->f * (long)+1
197 - (tmstart.tv_sec + tmstart.tv_nsec * 1e-9);
200 const OPTIONS passwd_options[] = {
201 {"aixmd5", OPT_AIXMD5, '-', "AIX MD5-based password algorithm"},
202 #if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
203 {"crypt", OPT_CRYPT, '-', "Standard Unix password algorithm (default)"},
218 typedef OSSL_CMP_MSG *(*cmp_srv_process_cb_t)
219 (OSSL_CMP_SRV_CTX *ctx, OSSL_CMP_MSG *msg)
230 { /*@ brace after 'if' not on same line just to construct case */
248 const unsigned char trans_id[OSSL_CMP_TRANSACTIONID_LENGTH] = {
251 const unsigned char trans_id[OSSL_CMP_TRANSACTIONID_LENGTH] =
291 #define Y /* .. */ 2 + 2
292 #define Z 3 + 3 * (*a++)
294 static varref cmp_vars[] = { /* comment. comment? comment! */
295 {&opt_config}, {&opt_section},
297 {&opt_server}, {&opt_proxy}, {&opt_path},
308 #define DEFINE_SET_GET_BASE_TEST(PREFIX, SETN, GETN, DUP, FIELD, TYPE, ERR, \
309 DEFAULT, NEW, FREE) \
310 static int execute_CTX_##SETN##_##GETN##_##FIELD( \
311 TEST_FIXTURE *fixture) \
313 CTX *ctx = fixture->ctx; \
314 int (*set_fn)(CTX *ctx, TYPE) = \
315 (int (*)(CTX *ctx, TYPE))PREFIX##_##SETN##_##FIELD; \
319 union un var; /* struct/union/enum in variable type */
320 struct provider_store_st *f() /* struct/union/enum in function return type */
323 static void f(struct pem_pass_data *data) /* struct/union/enum in arg list */
327 static void *fun(void)
329 if (pem_name != NULL)
334 label1: /* allow special indent 1 for label at outermost level in body */
337 size_t available_len, data_len;
338 const char *curr = txt, *next = txt;
346 char *intraline_string_with_comment_delimiters_and_dbl_space = "1 /*1";
347 char *multiline_string_with_comment_delimiters_and_dbl_space = "1 /*1\
348 2222222\'22222222222222222\"222222222" "33333 /*3333333333" "44 /*44444444444\
353 ASN1_CHOICE(OSSL_CRMF_POPO) = {
354 ASN1_IMP(OSSL_CRMF_POPO, value.raVerified, ASN1_NULL, 0),
355 ASN1_EXP(OSSL_CRMF_POPO, value.keyAgreement, OSSL_CRMF_POPOPRIVKEY, 3)
356 } ASN1_CHOICE_END(OSSL_CRMF_POPO)
357 IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_POPO)
359 ASN1_ADB(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) = {
360 ADB_ENTRY(NID_id_regCtrl_regToken,
361 ASN1_SIMPLE(OSSL_CRMF_ATTRIBUTETYPEANDVALUE,
362 value.regToken, ASN1_UTF8STRING)),
363 } ASN1_ADB_END(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, 0, type, 0,
364 &attributetypeandvalue_default_tt, NULL);
366 ASN1_ITEM_TEMPLATE(OSSL_CRMF_MSGS) =
367 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
368 OSSL_CRMF_MSGS, OSSL_CRMF_MSG)
369 ASN1_ITEM_TEMPLATE_END(OSSL_CRMF_MSGS)
371 void f_looong_body_200()
372 { /* function body length up to 200 lines accepted */
575 void f_looong_body_201()
576 { /* function body length > 200 lines, but LONG BODY marker present */