blob: f4b47b246a47be9ab982d488e81bd922a5bce649 [file] [log] [blame]
David Horstmannb95fa6b2022-10-07 19:27:43 +01001# Copyright The Mbed TLS Contributors
2# SPDX-License-Identifier: Apache-2.0
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16# Configuration options for Mbed TLS code style
17
18# Line length options
19
20# Wrap lines at 100 characters
21code_width = 100
22
23# Allow splitting long for statements between the condition statements
24ls_for_split_full = true
25
26# Allow splitting function calls between arguments
27ls_func_split_full = true
28
29input_tab_size = 4
30
31# Spaces-only indentation
32indent_with_tabs = 0
33
34indent_columns = 4
35
36# Indent 'case' 1 level from 'switch'
37indent_switch_case = indent_columns
38
39# Line-up strings broken by '\'
40indent_align_string = true
41
42# Braces on the same line (Egyptian-style braces)
43nl_enum_brace = remove
44nl_union_brace = remove
45nl_struct_brace = remove
46nl_do_brace = remove
47nl_if_brace = remove
48nl_for_brace = remove
49nl_else_brace = remove # Note: this option may cause problems for macro-guarded if-else partials
50nl_while_brace = remove
51nl_switch_brace = remove
52
53# Braces on same line as keywords that follow them - 'else' and the 'while' in 'do {} while ()';
54nl_brace_else = remove
55nl_brace_while = remove
56# Space before else on the same line
57sp_brace_else = add
58# If else is on the same line as '{', force exactly 1 space between them
59sp_else_brace = force
60
61# Functions are the exception and have braces on the next line
62nl_fcall_brace = add
63nl_fdef_brace = add
64
65# Force exactly one space between ')' and '{' in statements
66sp_sparen_brace = force
67
68# At least 1 space around assignment
69sp_assign = add
70
71# Remove spaces around the preprocessor '##' token-concatenate
72sp_pp_concat = ignore
73
74# At least 1 space around '||' and '&&'
75sp_bool = add
76
77# But no space after the '!' operator
78sp_not = remove
79
80# No space after the bitwise-not '~' operator
81sp_inv = remove
82
83# No space after the addressof '&' operator
84sp_addr = remove
85
86# No space around the member '.' and '->' operators
87sp_member = remove
88
89# No space after the dereference '*' operator
90sp_deref = remove
91
92# No space after a unary negation '-'
93sp_sign = remove
94
95# No space between the '++'/'--' operator and its operand
96sp_incdec = remove
97
98# At least 1 space around comparison operators
99sp_compare = add
100
101# Remove spaces inside all kinds of parentheses:
102
103# Remove spaces inside parentheses
104sp_inside_paren = remove
105
106# No spaces inside statement parentheses
107sp_inside_sparen = remove
108
109# No spaces inside cast parentheses '( char )x' -> '(char)x'
110sp_inside_paren_cast = remove
111
112# No spaces inside function parentheses
113sp_inside_fparen = remove
114# (The case where the function has no parameters/arguments)
115sp_inside_fparens = remove
116
117# No spaces inside the first parentheses in a function type
118sp_inside_tparen = remove
119
120# (Uncrustify >= 0.74.0) No spaces inside parens in for statements
121sp_inside_for = remove
122
123# Remove spaces between nested parentheses '( (' -> '(('
124sp_paren_paren = remove
125# (Uncrustify >= 0.74.0)
126sp_sparen_paren = remove
127
128# Remove spaces between ')' and adjacent '('
129sp_cparen_oparen = remove
130
131# (Uncrustify >= 0.73.0) space between 'do' and '{'
132sp_do_brace_open = force
133
134# (Uncrustify >= 0.73.0) space between '}' and 'while'
135sp_brace_close_while = force
136
137# At least 1 space before a '*' pointer star
138sp_before_ptr_star = add
139
140# Remove spaces between pointer stars
141sp_between_ptr_star = remove
142
143# No space after a pointer star
144sp_after_ptr_star = remove
145
146# But allow a space in the case of e.g. char * const x;
147sp_after_ptr_star_qualifier = ignore
148
149# Remove space after star in a function return type
150sp_after_ptr_star_func = remove
151
152# At least 1 space after a type in variable definition etc
153sp_after_type = add
154
155# Force exactly 1 space between a statement keyword (e.g. 'if') and an opening parenthesis
156sp_before_sparen = force
157
158# Remove a space before a ';'
159sp_before_semi = remove
160# (Uncrustify >= 0.73.0) Remove space before a semi in a non-empty for
161sp_before_semi_for = remove
162# (Uncrustify >= 0.73.0) Remove space in empty first statement of a for
163sp_before_semi_for_empty = remove
164# (Uncrustify >= 0.74.0) Remove space in empty middle statement of a for
165sp_between_semi_for_empty = remove
166
167# Add a space after a ';' (unless a comment follows)
168sp_after_semi = add
169# (Uncrustify >= 0.73.0) Add a space after a semi in non-empty for statements
170sp_after_semi_for = add
171# (Uncrustify >= 0.73.0) No space after final semi in empty for statements
172sp_after_semi_for_empty = remove
173
174# Remove spaces on the inside of square brackets '[]'
175sp_inside_square = remove
176
177# Must have at least 1 space after a comma
178sp_after_comma = add
179
180# Must not have a space before a comma
181sp_before_comma = remove
182
183# No space before the ':' in a case statement
184sp_before_case_colon = remove
185
186# No space after a cast - '(char) x' -> '(char)x'
187sp_after_cast = remove
188
189# No space between 'sizeof' and '('
190sp_sizeof_paren = remove
191
192# At least 1 space inside '{ }'
193sp_inside_braces = add
194
195# At least 1 space inside '{ }' in an enum
196sp_inside_braces_enum = add
197
198# At least 1 space inside '{ }' in a struct
199sp_inside_braces_struct = add
200
201# Except for empty braces which should not have a space
202
203# At least 1 space between a function return type and the function name
204sp_type_func = add
205
206# No space between a function name and its arguments/parameters
207sp_func_proto_paren = remove
208sp_func_def_paren = remove
209sp_func_call_paren = remove
210
211# No space between '__attribute__' and '('
212sp_attribute_paren = remove
213
214# No space between 'defined' and '(' in preprocessor conditions
215sp_defined_paren = remove
216
217# At least 1 space between a macro's name and its definition
218sp_macro = add
219sp_macro_func = add
220
221# Force exactly 1 space between a '}' and the name of a typedef if on the same line
222sp_brace_typedef = force
223
224# At least 1 space before a '\' line continuation
225sp_before_nl_cont = add
226
227# At least 1 space around '?' and ':' in ternary statements
228sp_cond_colon = add
229sp_cond_question = add
230
231# Space between #else/#endif and comment afterwards
232sp_endif_cmt = add
233
234# Remove newlines at the start of a file
235nl_start_of_file = remove
236
237# At least 1 newline at the end of a file
238nl_end_of_file = add
239nl_end_of_file_min = 1
240
241# Add braces in single-line statements
242mod_full_brace_do = add
243mod_full_brace_for = add
244mod_full_brace_if = add
245mod_full_brace_while = add
246
247# Remove parentheses from return statements
248mod_paren_on_return = remove
249
250# Disable removal of leading spaces in a multi-line comment if the first and
251# last lines are the same length
252cmt_multi_check_last = false