xref: /aosp_15_r20/external/mbedtls/.uncrustify.cfg (revision 62c56f9862f102b96d72393aff6076c951fb8148)
1*62c56f98SSadaf Ebrahimi# Configuration options for Uncrustify specifying the Mbed TLS code style.
2*62c56f98SSadaf Ebrahimi#
3*62c56f98SSadaf Ebrahimi# Note: The code style represented by this file has not yet been introduced
4*62c56f98SSadaf Ebrahimi# to Mbed TLS.
5*62c56f98SSadaf Ebrahimi#
6*62c56f98SSadaf Ebrahimi# Copyright The Mbed TLS Contributors
7*62c56f98SSadaf Ebrahimi# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
8*62c56f98SSadaf Ebrahimi
9*62c56f98SSadaf Ebrahimi
10*62c56f98SSadaf Ebrahimi# Wrap lines at 100 characters
11*62c56f98SSadaf Ebrahimicode_width = 100
12*62c56f98SSadaf Ebrahimi
13*62c56f98SSadaf Ebrahimi# Allow splitting long for statements between the condition statements
14*62c56f98SSadaf Ebrahimils_for_split_full = true
15*62c56f98SSadaf Ebrahimi
16*62c56f98SSadaf Ebrahimi# Allow splitting function calls between arguments
17*62c56f98SSadaf Ebrahimils_func_split_full = true
18*62c56f98SSadaf Ebrahimi
19*62c56f98SSadaf Ebrahimiinput_tab_size = 4
20*62c56f98SSadaf Ebrahimi
21*62c56f98SSadaf Ebrahimi# Spaces-only indentation
22*62c56f98SSadaf Ebrahimiindent_with_tabs = 0
23*62c56f98SSadaf Ebrahimi
24*62c56f98SSadaf Ebrahimiindent_columns = 4
25*62c56f98SSadaf Ebrahimi
26*62c56f98SSadaf Ebrahimi# Indent 'case' 1 level from 'switch'
27*62c56f98SSadaf Ebrahimiindent_switch_case = indent_columns
28*62c56f98SSadaf Ebrahimi
29*62c56f98SSadaf Ebrahimi# Line-up strings broken by '\'
30*62c56f98SSadaf Ebrahimiindent_align_string = true
31*62c56f98SSadaf Ebrahimi
32*62c56f98SSadaf Ebrahimi# Braces on the same line (Egyptian-style braces)
33*62c56f98SSadaf Ebrahiminl_enum_brace = remove
34*62c56f98SSadaf Ebrahiminl_union_brace = remove
35*62c56f98SSadaf Ebrahiminl_struct_brace = remove
36*62c56f98SSadaf Ebrahiminl_do_brace = remove
37*62c56f98SSadaf Ebrahiminl_if_brace = remove
38*62c56f98SSadaf Ebrahiminl_for_brace = remove
39*62c56f98SSadaf Ebrahiminl_else_brace = remove
40*62c56f98SSadaf Ebrahiminl_while_brace = remove
41*62c56f98SSadaf Ebrahiminl_switch_brace = remove
42*62c56f98SSadaf Ebrahimi
43*62c56f98SSadaf Ebrahimi# Braces on same line as keywords that follow them - 'else' and the 'while' in 'do {} while ()';
44*62c56f98SSadaf Ebrahiminl_brace_else = remove
45*62c56f98SSadaf Ebrahiminl_brace_while = remove
46*62c56f98SSadaf Ebrahimi# Space before else on the same line
47*62c56f98SSadaf Ebrahimisp_brace_else = add
48*62c56f98SSadaf Ebrahimi# If else is on the same line as '{', force exactly 1 space between them
49*62c56f98SSadaf Ebrahimisp_else_brace = force
50*62c56f98SSadaf Ebrahimi
51*62c56f98SSadaf Ebrahimi# Functions are the exception and have braces on the next line
52*62c56f98SSadaf Ebrahiminl_fcall_brace = add
53*62c56f98SSadaf Ebrahiminl_fdef_brace = add
54*62c56f98SSadaf Ebrahimi
55*62c56f98SSadaf Ebrahimi# Force exactly one space between ')' and '{' in statements
56*62c56f98SSadaf Ebrahimisp_sparen_brace = force
57*62c56f98SSadaf Ebrahimi
58*62c56f98SSadaf Ebrahimi# At least 1 space around assignment
59*62c56f98SSadaf Ebrahimisp_assign = add
60*62c56f98SSadaf Ebrahimi
61*62c56f98SSadaf Ebrahimi# Remove spaces around the preprocessor '##' token-concatenate
62*62c56f98SSadaf Ebrahimisp_pp_concat = ignore
63*62c56f98SSadaf Ebrahimi
64*62c56f98SSadaf Ebrahimi# At least 1 space around '||' and '&&'
65*62c56f98SSadaf Ebrahimisp_bool = add
66*62c56f98SSadaf Ebrahimi
67*62c56f98SSadaf Ebrahimi# But no space after the '!' operator
68*62c56f98SSadaf Ebrahimisp_not = remove
69*62c56f98SSadaf Ebrahimi
70*62c56f98SSadaf Ebrahimi# No space after the bitwise-not '~' operator
71*62c56f98SSadaf Ebrahimisp_inv = remove
72*62c56f98SSadaf Ebrahimi
73*62c56f98SSadaf Ebrahimi# No space after the addressof '&' operator
74*62c56f98SSadaf Ebrahimisp_addr = remove
75*62c56f98SSadaf Ebrahimi
76*62c56f98SSadaf Ebrahimi# No space around the member '.' and '->' operators
77*62c56f98SSadaf Ebrahimisp_member = remove
78*62c56f98SSadaf Ebrahimi
79*62c56f98SSadaf Ebrahimi# No space after the dereference '*' operator
80*62c56f98SSadaf Ebrahimisp_deref = remove
81*62c56f98SSadaf Ebrahimi
82*62c56f98SSadaf Ebrahimi# No space after a unary negation '-'
83*62c56f98SSadaf Ebrahimisp_sign = remove
84*62c56f98SSadaf Ebrahimi
85*62c56f98SSadaf Ebrahimi# No space between the '++'/'--' operator and its operand
86*62c56f98SSadaf Ebrahimisp_incdec = remove
87*62c56f98SSadaf Ebrahimi
88*62c56f98SSadaf Ebrahimi# At least 1 space around comparison operators
89*62c56f98SSadaf Ebrahimisp_compare = add
90*62c56f98SSadaf Ebrahimi
91*62c56f98SSadaf Ebrahimi# Remove spaces inside all kinds of parentheses:
92*62c56f98SSadaf Ebrahimi
93*62c56f98SSadaf Ebrahimi# Remove spaces inside parentheses
94*62c56f98SSadaf Ebrahimisp_inside_paren = remove
95*62c56f98SSadaf Ebrahimi
96*62c56f98SSadaf Ebrahimi# No spaces inside statement parentheses
97*62c56f98SSadaf Ebrahimisp_inside_sparen = remove
98*62c56f98SSadaf Ebrahimi
99*62c56f98SSadaf Ebrahimi# No spaces inside cast parentheses '( char )x' -> '(char)x'
100*62c56f98SSadaf Ebrahimisp_inside_paren_cast = remove
101*62c56f98SSadaf Ebrahimi
102*62c56f98SSadaf Ebrahimi# No spaces inside function parentheses
103*62c56f98SSadaf Ebrahimisp_inside_fparen = remove
104*62c56f98SSadaf Ebrahimi# (The case where the function has no parameters/arguments)
105*62c56f98SSadaf Ebrahimisp_inside_fparens = remove
106*62c56f98SSadaf Ebrahimi
107*62c56f98SSadaf Ebrahimi# No spaces inside the first parentheses in a function type
108*62c56f98SSadaf Ebrahimisp_inside_tparen = remove
109*62c56f98SSadaf Ebrahimi
110*62c56f98SSadaf Ebrahimi# (Uncrustify >= 0.74.0) No spaces inside parens in for statements
111*62c56f98SSadaf Ebrahimisp_inside_for = remove
112*62c56f98SSadaf Ebrahimi
113*62c56f98SSadaf Ebrahimi# Remove spaces between nested parentheses '( (' -> '(('
114*62c56f98SSadaf Ebrahimisp_paren_paren = remove
115*62c56f98SSadaf Ebrahimi# (Uncrustify >= 0.74.0)
116*62c56f98SSadaf Ebrahimisp_sparen_paren = remove
117*62c56f98SSadaf Ebrahimi
118*62c56f98SSadaf Ebrahimi# Remove spaces between ')' and adjacent '('
119*62c56f98SSadaf Ebrahimisp_cparen_oparen = remove
120*62c56f98SSadaf Ebrahimi
121*62c56f98SSadaf Ebrahimi# (Uncrustify >= 0.73.0) space between 'do' and '{'
122*62c56f98SSadaf Ebrahimisp_do_brace_open = force
123*62c56f98SSadaf Ebrahimi
124*62c56f98SSadaf Ebrahimi# (Uncrustify >= 0.73.0) space between '}' and 'while'
125*62c56f98SSadaf Ebrahimisp_brace_close_while = force
126*62c56f98SSadaf Ebrahimi
127*62c56f98SSadaf Ebrahimi# At least 1 space before a '*' pointer star
128*62c56f98SSadaf Ebrahimisp_before_ptr_star = add
129*62c56f98SSadaf Ebrahimi
130*62c56f98SSadaf Ebrahimi# Remove spaces between pointer stars
131*62c56f98SSadaf Ebrahimisp_between_ptr_star = remove
132*62c56f98SSadaf Ebrahimi
133*62c56f98SSadaf Ebrahimi# No space after a pointer star
134*62c56f98SSadaf Ebrahimisp_after_ptr_star = remove
135*62c56f98SSadaf Ebrahimi
136*62c56f98SSadaf Ebrahimi# But allow a space in the case of e.g. char * const x;
137*62c56f98SSadaf Ebrahimisp_after_ptr_star_qualifier = ignore
138*62c56f98SSadaf Ebrahimi
139*62c56f98SSadaf Ebrahimi# Remove space after star in a function return type
140*62c56f98SSadaf Ebrahimisp_after_ptr_star_func = remove
141*62c56f98SSadaf Ebrahimi
142*62c56f98SSadaf Ebrahimi# At least 1 space after a type in variable definition etc
143*62c56f98SSadaf Ebrahimisp_after_type = add
144*62c56f98SSadaf Ebrahimi
145*62c56f98SSadaf Ebrahimi# Force exactly 1 space between a statement keyword (e.g. 'if') and an opening parenthesis
146*62c56f98SSadaf Ebrahimisp_before_sparen = force
147*62c56f98SSadaf Ebrahimi
148*62c56f98SSadaf Ebrahimi# Remove a space before a ';'
149*62c56f98SSadaf Ebrahimisp_before_semi = remove
150*62c56f98SSadaf Ebrahimi# (Uncrustify >= 0.73.0) Remove space before a semi in a non-empty for
151*62c56f98SSadaf Ebrahimisp_before_semi_for = remove
152*62c56f98SSadaf Ebrahimi# (Uncrustify >= 0.73.0) Remove space in empty first statement of a for
153*62c56f98SSadaf Ebrahimisp_before_semi_for_empty = remove
154*62c56f98SSadaf Ebrahimi# (Uncrustify >= 0.74.0) Remove space in empty middle statement of a for
155*62c56f98SSadaf Ebrahimisp_between_semi_for_empty = remove
156*62c56f98SSadaf Ebrahimi
157*62c56f98SSadaf Ebrahimi# Add a space after a ';' (unless a comment follows)
158*62c56f98SSadaf Ebrahimisp_after_semi = add
159*62c56f98SSadaf Ebrahimi# (Uncrustify >= 0.73.0) Add a space after a semi in non-empty for statements
160*62c56f98SSadaf Ebrahimisp_after_semi_for = add
161*62c56f98SSadaf Ebrahimi# (Uncrustify >= 0.73.0) No space after final semi in empty for statements
162*62c56f98SSadaf Ebrahimisp_after_semi_for_empty = remove
163*62c56f98SSadaf Ebrahimi
164*62c56f98SSadaf Ebrahimi# Remove spaces on the inside of square brackets '[]'
165*62c56f98SSadaf Ebrahimisp_inside_square = remove
166*62c56f98SSadaf Ebrahimi
167*62c56f98SSadaf Ebrahimi# Must have at least 1 space after a comma
168*62c56f98SSadaf Ebrahimisp_after_comma = add
169*62c56f98SSadaf Ebrahimi
170*62c56f98SSadaf Ebrahimi# Must not have a space before a comma
171*62c56f98SSadaf Ebrahimisp_before_comma = remove
172*62c56f98SSadaf Ebrahimi
173*62c56f98SSadaf Ebrahimi# No space before the ':' in a case statement
174*62c56f98SSadaf Ebrahimisp_before_case_colon = remove
175*62c56f98SSadaf Ebrahimi
176*62c56f98SSadaf Ebrahimi# Must have space after a cast - '(char)x' -> '(char) x'
177*62c56f98SSadaf Ebrahimisp_after_cast = add
178*62c56f98SSadaf Ebrahimi
179*62c56f98SSadaf Ebrahimi# No space between 'sizeof' and '('
180*62c56f98SSadaf Ebrahimisp_sizeof_paren = remove
181*62c56f98SSadaf Ebrahimi
182*62c56f98SSadaf Ebrahimi# At least 1 space inside '{ }'
183*62c56f98SSadaf Ebrahimisp_inside_braces = add
184*62c56f98SSadaf Ebrahimi
185*62c56f98SSadaf Ebrahimi# At least 1 space inside '{ }' in an enum
186*62c56f98SSadaf Ebrahimisp_inside_braces_enum = add
187*62c56f98SSadaf Ebrahimi
188*62c56f98SSadaf Ebrahimi# At least 1 space inside '{ }' in a struct
189*62c56f98SSadaf Ebrahimisp_inside_braces_struct = add
190*62c56f98SSadaf Ebrahimi
191*62c56f98SSadaf Ebrahimi# At least 1 space between a function return type and the function name
192*62c56f98SSadaf Ebrahimisp_type_func = add
193*62c56f98SSadaf Ebrahimi
194*62c56f98SSadaf Ebrahimi# No space between a function name and its arguments/parameters
195*62c56f98SSadaf Ebrahimisp_func_proto_paren = remove
196*62c56f98SSadaf Ebrahimisp_func_def_paren = remove
197*62c56f98SSadaf Ebrahimisp_func_call_paren = remove
198*62c56f98SSadaf Ebrahimi
199*62c56f98SSadaf Ebrahimi# No space between '__attribute__' and '('
200*62c56f98SSadaf Ebrahimisp_attribute_paren = remove
201*62c56f98SSadaf Ebrahimi
202*62c56f98SSadaf Ebrahimi# No space between 'defined' and '(' in preprocessor conditions
203*62c56f98SSadaf Ebrahimisp_defined_paren = remove
204*62c56f98SSadaf Ebrahimi
205*62c56f98SSadaf Ebrahimi# At least 1 space between a macro's name and its definition
206*62c56f98SSadaf Ebrahimisp_macro = add
207*62c56f98SSadaf Ebrahimisp_macro_func = add
208*62c56f98SSadaf Ebrahimi
209*62c56f98SSadaf Ebrahimi# Force exactly 1 space between a '}' and the name of a typedef if on the same line
210*62c56f98SSadaf Ebrahimisp_brace_typedef = force
211*62c56f98SSadaf Ebrahimi
212*62c56f98SSadaf Ebrahimi# At least 1 space before a '\' line continuation
213*62c56f98SSadaf Ebrahimisp_before_nl_cont = add
214*62c56f98SSadaf Ebrahimi
215*62c56f98SSadaf Ebrahimi# At least 1 space around '?' and ':' in ternary statements
216*62c56f98SSadaf Ebrahimisp_cond_colon = add
217*62c56f98SSadaf Ebrahimisp_cond_question = add
218*62c56f98SSadaf Ebrahimi
219*62c56f98SSadaf Ebrahimi# Space between #else/#endif and comment afterwards
220*62c56f98SSadaf Ebrahimisp_endif_cmt = add
221*62c56f98SSadaf Ebrahimi
222*62c56f98SSadaf Ebrahimi# Remove newlines at the start of a file
223*62c56f98SSadaf Ebrahiminl_start_of_file = remove
224*62c56f98SSadaf Ebrahimi
225*62c56f98SSadaf Ebrahimi# At least 1 newline at the end of a file
226*62c56f98SSadaf Ebrahiminl_end_of_file = add
227*62c56f98SSadaf Ebrahiminl_end_of_file_min = 1
228*62c56f98SSadaf Ebrahimi
229*62c56f98SSadaf Ebrahimi# Add braces in single-line statements
230*62c56f98SSadaf Ebrahimimod_full_brace_do = add
231*62c56f98SSadaf Ebrahimimod_full_brace_for = add
232*62c56f98SSadaf Ebrahimimod_full_brace_if = add
233*62c56f98SSadaf Ebrahimimod_full_brace_while = add
234*62c56f98SSadaf Ebrahimi
235*62c56f98SSadaf Ebrahimi# Remove parentheses from return statements
236*62c56f98SSadaf Ebrahimimod_paren_on_return = remove
237*62c56f98SSadaf Ebrahimi
238*62c56f98SSadaf Ebrahimi# Disable removal of leading spaces in a multi-line comment if the first and
239*62c56f98SSadaf Ebrahimi# last lines are the same length
240*62c56f98SSadaf Ebrahimicmt_multi_check_last = false
241