1.. _coding_guidelines:
2
3Coding Guidelines
4#################
5
6
7Main rules
8**********
9
10The coding guideline rules are based on MISRA-C 2012 and are a **subset** of MISRA-C.
11The subset is listed in the table below with a summary of the rules, its
12severity and the equivalent rules from other standards for reference.
13
14.. note::
15
16    For existing Zephyr maintainers and collaborators, if you are unable to
17    obtain a copy through your employer, a limited number of copies will be made
18    available through the project. If you need a copy of MISRA-C 2012, please
19    send email to safety@lists.zephyrproject.org and provide details on reason
20    why you can't obtain one through other options and expected contributions
21    once you have one.  The safety committee will review all requests.
22
23
24.. list-table:: Main rules
25    :header-rows: 1
26    :widths: 12 45 15 14 12
27
28    * -  Zephyr rule
29      -  Description
30      -  MISRA-C 2012 rule
31      -  MISRA-C severity
32      -  CERT C reference
33
34         .. _MisraC_Dir_1_1:
35    * -  1
36      -  Any implementation-defined behaviour on which the output of the program depends shall be documented and understood
37      -  `Dir 1.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_01_01.c>`_
38      -  Required
39      -  `MSC09-C <https://wiki.sei.cmu.edu/confluence/display/c/MSC09-C.+Character+encoding%3A+Use+subset+of+ASCII+for+safety>`_
40
41         .. _MisraC_Dir_2_1:
42    * -  2
43      -  All source files shall compile without any compilation errors
44      -  `Dir 2.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_02_01.c>`_
45      -  Required
46      -  N/A
47
48         .. _MisraC_Dir_3_1:
49    * -  3
50      -  All code shall be traceable to documented requirements
51      -  `Dir 3.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_03_01.c>`_
52      -  Required
53      -  N/A
54
55         .. _MisraC_Dir_4_1:
56    * -  4
57      -  Run-time failures shall be minimized
58      -  `Dir 4.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_01.c>`_
59      -  Required
60      -  N/A
61
62         .. _MisraC_Dir_4_2:
63    * -  5
64      -  All usage of assembly language should be documented
65      -  `Dir 4.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_02.c>`_
66      -  Advisory
67      -  N/A
68
69         .. _MisraC_Dir_4_4:
70    * -  6
71      -  Sections of code should not be “commented out”
72      -  `Dir 4.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_04.c>`_
73      -  Advisory
74      -  `MSC04-C <https://wiki.sei.cmu.edu/confluence/display/c/MSC04-C.+Use+comments+consistently+and+in+a+readable+fashion>`_
75
76         .. _MisraC_Dir_4_5:
77    * -  7
78      -  Identifiers in the same name space with overlapping visibility should be typographically unambiguous
79      -  `Dir 4.5 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_05.c>`_
80      -  Advisory
81      -  `DCL02-C <https://wiki.sei.cmu.edu/confluence/display/c/DCL02-C.+Use+visually+distinct+identifiers>`_
82
83         .. _MisraC_Dir_4_6:
84    * -  8
85      -  typedefs that indicate size and signedness should be used in place of the basic numerical types
86      -  `Dir 4.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_06.c>`_
87      -  Advisory
88      -  N/A
89
90         .. _MisraC_Dir_4_7:
91    * -  9
92      -  If a function returns error information, then that error information shall be tested
93      -  `Dir 4.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_07.c>`_
94      -  Required
95      -  N/A
96
97         .. _MisraC_Dir_4_8:
98    * -  10
99      -  If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden
100      -  | `Dir 4.8 example 1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_08_1.c>`_
101         | `Dir 4.8 example 2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_08_2.c>`_
102      -  Advisory
103      -  `DCL12-C <https://wiki.sei.cmu.edu/confluence/display/c/DCL12-C.+Implement+abstract+data+types+using+opaque+types>`_
104
105         .. _MisraC_Dir_4_9:
106    * -  11
107      -  A function should be used in preference to a function-like macro where they are interchangeable
108      -  `Dir 4.9 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_09.c>`_
109      -  Advisory
110      -  `PRE00-C <https://wiki.sei.cmu.edu/confluence/display/c/PRE00-C.+Prefer+inline+or+static+functions+to+function-like+macros>`_
111
112         .. _MisraC_Dir_4_10:
113    * -  12
114      -  Precautions shall be taken in order to prevent the contents of a header file being included more than once
115      -  `Dir 4.10 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_10.c>`_
116      -  Required
117      -  `PRE06-C <https://wiki.sei.cmu.edu/confluence/display/c/PRE06-C.+Enclose+header+files+in+an+include+guard>`_
118
119         .. _MisraC_Dir_4_11:
120    * -  13
121      -  The validity of values passed to library functions shall be checked
122      -  `Dir 4.11 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_11.c>`_
123      -  Required
124      -  N/A
125
126         .. _MisraC_Dir_4_12:
127    * - 14
128      -  Dynamic memory allocation shall not be used
129      -  `Dir 4.12 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_12.c>`_
130      -  Required
131      -  `STR01-C <https://wiki.sei.cmu.edu/confluence/display/c/STR01-C.+Adopt+and+implement+a+consistent+plan+for+managing+strings>`_
132
133         .. _MisraC_Dir_4_13:
134    * -  15
135      -  Functions which are designed to provide operations on a resource should be called in an appropriate sequence
136      -  `Dir 4.13 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_13.c>`_
137      -  Advisory
138      -  N/A
139
140         .. _MisraC_Dir_4_14:
141    * -  16
142      -  The validity of values received from external sources shall be checked
143      -  `Dir 4.14 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/D_04_14.c>`_
144      -  Required
145      -  N/A
146
147         .. _MisraC_Rule_1_2:
148    * -  17
149      -  Language extensions should not be used
150      -  `Rule 1.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_01_02.c>`_
151      -  Advisory
152      -  `MSC04-C <https://wiki.sei.cmu.edu/confluence/display/c/MSC04-C.+Use+comments+consistently+and+in+a+readable+fashion>`_
153
154         .. _MisraC_Rule_1_3:
155    * -  18
156      -  There shall be no occurrence of undefined or critical unspecified behaviour
157      -  `Rule 1.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_01_03.c>`_
158      -  Required
159      -  N/A
160
161         .. _MisraC_Rule_2_1:
162    * -  19
163      -  A project shall not contain unreachable code
164      -  | `Rule 2.1 example 1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_01_1.c>`_
165         | `Rule 2.1 example 2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_01_2.c>`_
166      -  Required
167      -  `MSC07-C <https://wiki.sei.cmu.edu/confluence/display/c/MSC07-C.+Detect+and+remove+dead+code>`_
168
169         .. _MisraC_Rule_2_2:
170    * -  20
171      -  There shall be no dead code
172      -  `Rule 2.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_02.c>`_
173      -  Required
174      -  `MSC12-C <https://wiki.sei.cmu.edu/confluence/display/c/MSC12-C.+Detect+and+remove+code+that+has+no+effect+or+is+never+executed>`_
175
176         .. _MisraC_Rule_2_3:
177    * -  21
178      -  A project should not contain unused type declarations
179      -  `Rule 2.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_03.c>`_
180      -  Advisory
181      -  N/A
182
183         .. _MisraC_Rule_2_6:
184    * -  22
185      -  A function should not contain unused label declarations
186      -  `Rule 2.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_06.c>`_
187      -  Advisory
188      -  N/A
189
190         .. _MisraC_Rule_2_7:
191    * -  23
192      -  There should be no unused parameters in functions
193      -  `Rule 2.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_02_07.c>`_
194      -  Advisory
195      -  N/A
196
197         .. _MisraC_Rule_3_1:
198    * -  24
199      -  The character sequences /* and // shall not be used within a comment
200      -  `Rule 3.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_03_01.c>`_
201      -  Required
202      -  `MSC04-C <https://wiki.sei.cmu.edu/confluence/display/c/MSC04-C.+Use+comments+consistently+and+in+a+readable+fashion>`_
203
204         .. _MisraC_Rule_3_2:
205    * -  25
206      -  Line-splicing shall not be used in // comments
207      -  `Rule 3.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_03_02.c>`_
208      -  Required
209      -  N/A
210
211         .. _MisraC_Rule_4_1:
212    * -  26
213      -  Octal and hexadecimal escape sequences shall be terminated
214      -  `Rule 4.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_04_01.c>`_
215      -  Required
216      -  `MSC09-C <https://wiki.sei.cmu.edu/confluence/display/c/MSC09-C.+Character+encoding%3A+Use+subset+of+ASCII+for+safety>`_
217
218         .. _MisraC_Rule_4_2:
219    * -  27
220      -  Trigraphs should not be used
221      -  `Rule 4.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_04_02.c>`_
222      -  Advisory
223      -  `PRE07-C <https://wiki.sei.cmu.edu/confluence/display/c/PRE07-C.+Avoid+using+repeated+question+marks>`_
224
225         .. _MisraC_Rule_5_1:
226    * -  28
227      -  External identifiers shall be distinct
228      -  | `Rule 5.1 example 1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_01_1.c>`_
229         | `Rule 5.1 example 2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_01_2.c>`_
230      -  Required
231      -  `DCL23-C <https://wiki.sei.cmu.edu/confluence/display/c/DCL23-C.+Guarantee+that+mutually+visible+identifiers+are+unique>`_
232
233         .. _MisraC_Rule_5_2:
234    * -  29
235      -  Identifiers declared in the same scope and name space shall be distinct
236      -  `Rule 5.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_02.c>`_
237      -  Required
238      -  `DCL23-C <https://wiki.sei.cmu.edu/confluence/display/c/DCL23-C.+Guarantee+that+mutually+visible+identifiers+are+unique>`_
239
240         .. _MisraC_Rule_5_3:
241    * -  30
242      -  An identifier declared in an inner scope shall not hide an identifier declared in an outer scope
243      -  `Rule 5.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_03.c>`_
244      -  Required
245      -  `DCL23-C <https://wiki.sei.cmu.edu/confluence/display/c/DCL23-C.+Guarantee+that+mutually+visible+identifiers+are+unique>`_
246
247         .. _MisraC_Rule_5_4:
248    * -  31
249      -  Macro identifiers shall be distinct
250      -  `Rule 5.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_04.c>`_
251      -  Required
252      -  `DCL23-C <https://wiki.sei.cmu.edu/confluence/display/c/DCL23-C.+Guarantee+that+mutually+visible+identifiers+are+unique>`_
253
254         .. _MisraC_Rule_5_5:
255    * -  32
256      -  Identifiers shall be distinct from macro names
257      -  `Rule 5.5 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_05.c>`_
258      -  Required
259      -  `DCL23-C <https://wiki.sei.cmu.edu/confluence/display/c/DCL23-C.+Guarantee+that+mutually+visible+identifiers+are+unique>`_
260
261         .. _MisraC_Rule_5_6:
262    * -  33
263      -  A typedef name shall be a unique identifier
264      -  `Rule 5.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_06.c>`_
265      -  Required
266      -  N/A
267
268         .. _MisraC_Rule_5_7:
269    * -  34
270      -  A tag name shall be a unique identifier
271      -  `Rule 5.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_07.c>`_
272      -  Required
273      -  N/A
274
275         .. _MisraC_Rule_5_8:
276    * -  35
277      -  Identifiers that define objects or functions with external linkage shall be unique
278      -  | `Rule 5.8 example 1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_08_1.c>`_
279         | `Rule 5.8 example 2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_08_2.c>`_
280      -  Required
281      -  N/A
282
283         .. _MisraC_Rule_5_9:
284    * -  36
285      -  Identifiers that define objects or functions with internal linkage should be unique
286      -  | `Rule 5.9 example 1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_09_1.c>`_
287         | `Rule 5.9 example 2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_05_09_2.c>`_
288      -  Advisory
289      -  N/A
290
291         .. _MisraC_Rule_6_1:
292    * -  37
293      -  Bit-fields shall only be declared with an appropriate type
294      -  `Rule 6.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_06_01.c>`_
295      -  Required
296      -  `INT14-C <https://wiki.sei.cmu.edu/confluence/display/c/INT14-C.+Avoid+performing+bitwise+and+arithmetic+operations+on+the+same+data>`_
297
298         .. _MisraC_Rule_6_2:
299    * -  38
300      -  Single-bit named bit fields shall not be of a signed type
301      -  `Rule 6.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_06_02.c>`_
302      -  Required
303      -  `INT14-C <https://wiki.sei.cmu.edu/confluence/display/c/INT14-C.+Avoid+performing+bitwise+and+arithmetic+operations+on+the+same+data>`_
304
305         .. _MisraC_Rule_7_1:
306    * -  39
307      -  Octal constants shall not be used
308      -  `Rule 7.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_07_01.c>`_
309      -  Required
310      -  `DCL18-C <https://wiki.sei.cmu.edu/confluence/display/c/DCL18-C.+Do+not+begin+integer+constants+with+0+when+specifying+a+decimal+value>`_
311
312         .. _MisraC_Rule_7_2:
313    * -  40
314      -  A u or U suffix shall be applied to all integer constants that are represented in an unsigned type
315      -  `Rule 7.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_07_02.c>`_
316      -  Required
317      -  N/A
318
319         .. _MisraC_Rule_7_3:
320    * -  41
321      -  The lowercase character l shall not be used in a literal suffix
322      -  `Rule 7.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_07_03.c>`_
323      -  Required
324      -  `DCL16-C <https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152241>`_
325
326         .. _MisraC_Rule_7_4:
327    * -  42
328      -  A string literal shall not be assigned to an object unless the objects type is pointer to const-qualified char
329      -  `Rule 7.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_07_04.c>`_
330      -  Required
331      -  N/A
332
333         .. _MisraC_Rule_8_1:
334    * -  43
335      -  Types shall be explicitly specified
336      -  `Rule 8.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_01.c>`_
337      -  Required
338      -  N/A
339
340         .. _MisraC_Rule_8_2:
341    * -  44
342      -  Function types shall be in prototype form with named parameters
343      -  `Rule 8.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_02.c>`_
344      -  Required
345      -  `DCL20-C <https://wiki.sei.cmu.edu/confluence/display/c/DCL20-C.+Explicitly+specify+void+when+a+function+accepts+no+arguments>`_
346
347         .. _MisraC_Rule_8_3:
348    * -  45
349      -  All declarations of an object or function shall use the same names and type qualifiers
350      -  `Rule 8.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_03.c>`_
351      -  Required
352      -  N/A
353
354         .. _MisraC_Rule_8_4:
355    * -  46
356      -  A compatible declaration shall be visible when an object or function with external linkage is defined
357      -  `Rule 8.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_04.c>`_
358      -  Required
359      -  N/A
360
361         .. _MisraC_Rule_8_5:
362    * -  47
363      -  An external object or function shall be declared once in one and only one file
364      -  | `Rule 8.5 example 1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_05_1.c>`_
365         | `Rule 8.5 example 2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_05_2.c>`_
366      -  Required
367      -  N/A
368
369         .. _MisraC_Rule_8_6:
370    * -  48
371      -  An identifier with external linkage shall have exactly one external definition
372      -  | `Rule 8.6 example 1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_06_1.c>`_
373         | `Rule 8.6 example 2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_06_2.c>`_
374      -  Required
375      -  N/A
376
377         .. _MisraC_Rule_8_8:
378    * -  49
379      -  The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage
380      -  `Rule 8.8 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_08.c>`_
381      -  Required
382      -  `DCL15-C <https://wiki.sei.cmu.edu/confluence/display/c/DCL15-C.+Declare+file-scope+objects+or+functions+that+do+not+need+external+linkage+as+static>`_
383
384         .. _MisraC_Rule_8_9:
385    * -  50
386      -  An object should be defined at block scope if its identifier only appears in a single function
387      -  `Rule 8.9 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_09.c>`_
388      -  Advisory
389      -  `DCL19-C <https://wiki.sei.cmu.edu/confluence/display/c/DCL19-C.+Minimize+the+scope+of+variables+and+functions>`_
390
391         .. _MisraC_Rule_8_10:
392    * -  51
393      -  An inline function shall be declared with the static storage class
394      -  `Rule 8.10 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_10.c>`_
395      -  Required
396      -  N/A
397
398         .. _MisraC_Rule_8_12:
399    * -  52
400      -  Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique
401      -  `Rule 8.12 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_12.c>`_
402      -  Required
403      -  `INT09-C <https://wiki.sei.cmu.edu/confluence/display/c/INT09-C.+Ensure+enumeration+constants+map+to+unique+values>`_
404
405         .. _MisraC_Rule_8_14:
406    * -  53
407      -  The restrict type qualifier shall not be used
408      -  `Rule 8.14 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_08_14.c>`_
409      -  Required
410      -  N/A
411
412         .. _MisraC_Rule_9_1:
413    * -  54
414      -  The value of an object with automatic storage duration shall not be read before it has been set
415      -  `Rule 9.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_09_01.c>`_
416      -  Mandatory
417      -  N/A
418
419         .. _MisraC_Rule_9_2:
420    * -  55
421      -  The initializer for an aggregate or union shall be enclosed in braces
422      -  `Rule 9.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_09_02.c>`_
423      -  Required
424      -  N/A
425
426         .. _MisraC_Rule_9_3:
427    * -  56
428      -  Arrays shall not be partially initialized
429      -  `Rule 9.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_09_03.c>`_
430      -  Required
431      -  N/A
432
433         .. _MisraC_Rule_9_4:
434    * -  57
435      -  An element of an object shall not be initialized more than once
436      -  `Rule 9.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_09_04.c>`_
437      -  Required
438      -  N/A
439
440         .. _MisraC_Rule_9_5:
441    * -  58
442      -  Where designated initializers are used to initialize an array object the size of the array shall be specified explicitly
443      -  `Rule 9.5 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_09_05.c>`_
444      -  Required
445      -  N/A
446
447         .. _MisraC_Rule_10_1:
448    * -  59
449      -  Operands shall not be of an inappropriate essential type
450      -  `Rule 10.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_10_01.c>`_
451      -  Required
452      -  `STR04-C <https://wiki.sei.cmu.edu/confluence/display/c/STR04-C.+Use+plain+char+for+characters+in+the+basic+character+set>`_
453
454         .. _MisraC_Rule_10_2:
455    * -  60
456      -  Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations
457      -  `Rule 10.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_10_02.c>`_
458      -  Required
459      -  `STR04-C <https://wiki.sei.cmu.edu/confluence/display/c/STR04-C.+Use+plain+char+for+characters+in+the+basic+character+set>`_
460
461         .. _MisraC_Rule_10_3:
462    * -  61
463      -  The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category
464      -  `Rule 10.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_10_03.c>`_
465      -  Required
466      -  `STR04-C <https://wiki.sei.cmu.edu/confluence/display/c/STR04-C.+Use+plain+char+for+characters+in+the+basic+character+set>`_
467
468         .. _MisraC_Rule_10_4:
469    * -  62
470      -  Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category
471      -  `Rule 10.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_10_04.c>`_
472      -  Required
473      -  `STR04-C <https://wiki.sei.cmu.edu/confluence/display/c/STR04-C.+Use+plain+char+for+characters+in+the+basic+character+set>`_
474
475         .. _MisraC_Rule_10_5:
476    * -  63
477      -  The value of an expression should not be cast to an inappropriate essential type
478      -  `Rule 10.5 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_10_05.c>`_
479      -  Advisory
480      -  N/A
481
482         .. _MisraC_Rule_10_6:
483    * -  64
484      -  The value of a composite expression shall not be assigned to an object with wider essential type
485      -  `Rule 10.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_10_06.c>`_
486      -  Required
487      -  `INT02-C <https://wiki.sei.cmu.edu/confluence/display/c/INT02-C.+Understand+integer+conversion+rules>`_
488
489         .. _MisraC_Rule_10_7:
490    * -  65
491      -  If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type
492      -  `Rule 10.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_10_07.c>`_
493      -  Required
494      -  `INT02-C <https://wiki.sei.cmu.edu/confluence/display/c/INT02-C.+Understand+integer+conversion+rules>`_
495
496         .. _MisraC_Rule_10_8:
497    * -  66
498      -  The value of a composite expression shall not be cast to a different essential type category or a wider essential type
499      -  `Rule 10.8 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_10_08.c>`_
500      -  Required
501      -  `INT02-C <https://wiki.sei.cmu.edu/confluence/display/c/INT02-C.+Understand+integer+conversion+rules>`_
502
503         .. _MisraC_Rule_11_2:
504    * -  67
505      -  Conversions shall not be performed between a pointer to an incomplete type and any other type
506      -  `Rule 11.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_11_02.c>`_
507      -  Required
508      -  N/A
509
510         .. _MisraC_Rule_11_6:
511    * -  68
512      -  A cast shall not be performed between pointer to void and an arithmetic type
513      -  `Rule 11.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_11_06.c>`_
514      -  Required
515      -  N/A
516
517         .. _MisraC_Rule_11_7:
518    * -  69
519      -  A cast shall not be performed between pointer to object and a noninteger arithmetic type
520      -  `Rule 11.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_11_07.c>`_
521      -  Required
522      -  N/A
523
524         .. _MisraC_Rule_11_8:
525    * -  70
526      -  A cast shall not remove any const or volatile qualification from the type pointed to by a pointer
527      -  `Rule 11.8 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_11_08.c>`_
528      -  Required
529      -  `EXP05-C <https://wiki.sei.cmu.edu/confluence/display/c/EXP05-C.+Do+not+cast+away+a+const+qualification>`_
530
531         .. _MisraC_Rule_11_9:
532    * -  71
533      -  The macro NULL shall be the only permitted form of integer null pointer constant
534      -  `Rule 11.9 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_11_09.c>`_
535      -  Required
536      -  N/A
537
538         .. _MisraC_Rule_12_1:
539    * -  72
540      -  The precedence of operators within expressions should be made explicit
541      -  `Rule 12.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_12_01.c>`_
542      -  Advisory
543      -  `EXP00-C <https://wiki.sei.cmu.edu/confluence/display/c/EXP00-C.+Use+parentheses+for+precedence+of+operation>`_
544
545         .. _MisraC_Rule_12_2:
546    * -  73
547      -  The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand
548      -  `Rule 12.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_12_02.c>`_
549      -  Required
550      -  N/A
551
552         .. _MisraC_Rule_12_4:
553    * -  74
554      -  Evaluation of constant expressions should not lead to unsigned integer wrap-around
555      -  `Rule 12.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_12_04.c>`_
556      -  Advisory
557      -  N/A
558
559         .. _MisraC_Rule_12_5:
560    * -  75
561      -  The sizeof operator shall not have an operand which is a function parameter declared as “array of type”
562      -  `Rule 12.5 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_12_05.c>`_
563      -  Mandatory
564      -  N/A
565
566         .. _MisraC_Rule_13_1:
567    * -  76
568      -  Initializer lists shall not contain persistent side effects
569      -  | `Rule 13.1 example 1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_13_01_1.c>`_
570         | `Rule 13.1 example 2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_13_01_2.c>`_
571      -  Required
572      -  N/A
573
574         .. _MisraC_Rule_13_2:
575    * -  77
576      -  The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders
577      -  `Rule 13.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_13_02.c>`_
578      -  Required
579      -  N/A
580
581         .. _MisraC_Rule_13_3:
582    * -  78
583      -  A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator
584      -  `Rule 13.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_13_03.c>`_
585      -  Advisory
586      -  N/A
587
588         .. _MisraC_Rule_13_4:
589    * -  79
590      -  The result of an assignment operator should not be used
591      -  `Rule 13.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_13_04.c>`_
592      -  Advisory
593      -  N/A
594
595         .. _MisraC_Rule_13_5:
596    * -  80
597      -  The right hand operand of a logical && or || operator shall not contain persistent side effects
598      -  | `Rule 13.5 example 1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_13_05_1.c>`_
599         | `Rule 13.5 example 2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_13_05_2.c>`_
600      -  Required
601      -  `EXP10-C <https://wiki.sei.cmu.edu/confluence/display/c/EXP10-C.+Do+not+depend+on+the+order+of+evaluation+of+subexpressions+or+the+order+in+which+side+effects+take+place>`_
602
603         .. _MisraC_Rule_13_6:
604    * -  81
605      -  The operand of the sizeof operator shall not contain any expression which has potential side effects
606      -  `Rule 13.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_13_06.c>`_
607      -  Mandatory
608      -  N/A
609
610         .. _MisraC_Rule_14_1:
611    * -  82
612      -  A loop counter shall not have essentially floating type
613      -  `Rule 14.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_14_01.c>`_
614      -  Required
615      -  N/A
616
617         .. _MisraC_Rule_14_2:
618    * -  83
619      -  A for loop shall be well-formed
620      -  `Rule 14.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_14_02.c>`_
621      -  Required
622      -  N/A
623
624         .. _MisraC_Rule_14_3:
625    * -  84
626      -  Controlling expressions shall not be invariant
627      -  `Rule 14.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_14_03.c>`_
628      -  Required
629      -  N/A
630
631         .. _MisraC_Rule_14_4:
632    * -  85
633      -  The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type
634      -  `Rule 14.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_14_04.c>`_
635      -  Required
636      -  N/A
637
638         .. _MisraC_Rule_15_2:
639    * -  86
640      -  The goto statement shall jump to a label declared later in the same function
641      -  `Rule 15.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_15_02.c>`_
642      -  Required
643      -  N/A
644
645         .. _MisraC_Rule_15_3:
646    * -  87
647      -  Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement
648      -  `Rule 15.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_15_03.c>`_
649      -  Required
650      -  N/A
651
652         .. _MisraC_Rule_15_6:
653    * -  88
654      -  The body of an iteration-statement or a selection-statement shall be a compound-statement
655      -  `Rule 15.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_15_06.c>`_
656      -  Required
657      -  `EXP19-C <https://wiki.sei.cmu.edu/confluence/display/c/EXP19-C.+Use+braces+for+the+body+of+an+if%2C+for%2C+or+while+statement>`_
658
659         .. _MisraC_Rule_15_7:
660    * -  89
661      -  All if else if constructs shall be terminated with an else statement
662      -  `Rule 15.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_15_07.c>`_
663      -  Required
664      -  N/A
665
666         .. _MisraC_Rule_16_1:
667    * -  90
668      -  All switch statements shall be well-formed
669      -  `Rule 16.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_16_01.c>`_
670      -  Required
671      -  N/A
672
673         .. _MisraC_Rule_16_2:
674    * -  91
675      -  A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement
676      -  `Rule 16.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_16_02.c>`_
677      -  Required
678      -  `MSC20-C <https://wiki.sei.cmu.edu/confluence/display/c/MSC20-C.+Do+not+use+a+switch+statement+to+transfer+control+into+a+complex+block>`_
679
680         .. _MisraC_Rule_16_3:
681    * -  92
682      -  An unconditional break statement shall terminate every switch-clause
683      -  `Rule 16.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_16_03.c>`_
684      -  Required
685      -  N/A
686
687         .. _MisraC_Rule_16_4:
688    * -  93
689      -  Every switch statement shall have a default label
690      -  `Rule 16.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_16_04.c>`_
691      -  Required
692      -  N/A
693
694         .. _MisraC_Rule_16_5:
695    * -  94
696      -  A default label shall appear as either the first or the last switch label of a switch statement
697      -  `Rule 16.5 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_16_05.c>`_
698      -  Required
699      -  N/A
700
701         .. _MisraC_Rule_16_6:
702    * -  95
703      -  Every switch statement shall have at least two switch-clauses
704      -  `Rule 16.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_16_06.c>`_
705      -  Required
706      -  N/A
707
708         .. _MisraC_Rule_16_7:
709    * -  96
710      -  A switch-expression shall not have essentially Boolean type
711      -  `Rule 16.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_16_07.c>`_
712      -  Required
713      -  N/A
714
715         .. _MisraC_Rule_17_1:
716    * -  97
717      -  The features of <stdarg.h> shall not be used
718      -  `Rule 17.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_17_01.c>`_
719      -  Required
720      -  `ERR00-C <https://wiki.sei.cmu.edu/confluence/display/c/ERR00-C.+Adopt+and+implement+a+consistent+and+comprehensive+error-handling+policy>`_
721
722         .. _MisraC_Rule_17_2:
723    * -  98
724      -  Functions shall not call themselves, either directly or indirectly
725      -  `Rule 17.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_17_02.c>`_
726      -  Required
727      -  `MEM05-C <https://wiki.sei.cmu.edu/confluence/display/c/MEM05-C.+Avoid+large+stack+allocations>`_
728
729         .. _MisraC_Rule_17_3:
730    * -  99
731      -  A function shall not be declared implicitly
732      -  `Rule 17.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_17_03.c>`_
733      -  Mandatory
734      -  N/A
735
736         .. _MisraC_Rule_17_4:
737    * -  100
738      -  All exit paths from a function with non-void return type shall have an explicit return statement with an expression
739      -  `Rule 17.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_17_04.c>`_
740      -  Mandatory
741      -  N/A
742
743         .. _MisraC_Rule_17_5:
744    * -  101
745      -  The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements
746      -  `Rule 17.5 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_17_05.c>`_
747      -  Advisory
748      -  N/A
749
750         .. _MisraC_Rule_17_6:
751    * -  102
752      -  The declaration of an array parameter shall not contain the static keyword between the [ ]
753      -  `Rule 17.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_17_06.c>`_
754      -  Mandatory
755      -  N/A
756
757         .. _MisraC_Rule_17_7:
758    * -  103
759      -  The value returned by a function having non-void return type shall be used
760      -  `Rule 17.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_17_07.c>`_
761      -  Required
762      -  N/A
763
764         .. _MisraC_Rule_18_1:
765    * -  104
766      -  A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand
767      -  `Rule 18.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_18_01.c>`_
768      -  Required
769      -  `EXP08-C <https://wiki.sei.cmu.edu/confluence/display/c/EXP08-C.+Ensure+pointer+arithmetic+is+used+correctly>`_
770
771         .. _MisraC_Rule_18_2:
772    * -  105
773      -  Subtraction between pointers shall only be applied to pointers that address elements of the same array
774      -  `Rule 18.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_18_02.c>`_
775      -  Required
776      -  `EXP08-C <https://wiki.sei.cmu.edu/confluence/display/c/EXP08-C.+Ensure+pointer+arithmetic+is+used+correctly>`_
777
778         .. _MisraC_Rule_18_3:
779    * -  106
780      -  The relational operators >, >=, < and <= shall not be applied to objects of pointer type except where they point into the same object
781      -  `Rule 18.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_18_03.c>`_
782      -  Required
783      -  `EXP08-C <https://wiki.sei.cmu.edu/confluence/display/c/EXP08-C.+Ensure+pointer+arithmetic+is+used+correctly>`_
784
785         .. _MisraC_Rule_18_5:
786    * -  107
787      -  Declarations should contain no more than two levels of pointer nesting
788      -  `Rule 18.5 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_18_05.c>`_
789      -  Advisory
790      -  N/A
791
792         .. _MisraC_Rule_18_6:
793    * -  108
794      -  The address of an object with automatic storage shall not be copied to another object that persists after the first object has ceased to exist
795      -  | `Rule 18.6 example 1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_18_06_1.c>`_
796         | `Rule 18.6 example 2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_18_06_2.c>`_
797      -  Required
798      -  N/A
799
800         .. _MisraC_Rule_18_8:
801    * -  109
802      -  Variable-length array types shall not be used
803      -  `Rule 18.8 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_18_08.c>`_
804      -  Required
805      -  N/A
806
807         .. _MisraC_Rule_19_1:
808    * -  110
809      -  An object shall not be assigned or copied to an overlapping object
810      -  `Rule 19.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_19_01.c>`_
811      -  Mandatory
812      -  N/A
813
814         .. _MisraC_Rule_20_2:
815    * -  111
816      -  The ', or \ characters and the /* or // character sequences shall not occur in a header file name"
817      -  `Rule 20.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_20_02.c>`_
818      -  Required
819      -  N/A
820
821         .. _MisraC_Rule_20_3:
822    * -  112
823      -  The #include directive shall be followed by either a <filename> or "filename" sequence
824      -  `Rule 20.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_20_03.c>`_
825      -  Required
826      -  N/A
827
828         .. _MisraC_Rule_20_4:
829    * -  113
830      -  A macro shall not be defined with the same name as a keyword
831      -  `Rule 20.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_20_04.c>`_
832      -  Required
833      -  N/A
834
835         .. _MisraC_Rule_20_7:
836    * -  114
837      -  Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses
838      -  `Rule 20.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_20_07.c>`_
839      -  Required
840      -  `PRE01-C <https://wiki.sei.cmu.edu/confluence/display/c/PRE01-C.+Use+parentheses+within+macros+around+parameter+names>`_
841
842         .. _MisraC_Rule_20_8:
843    * -  115
844      -  The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1
845      -  `Rule 20.8 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_20_08.c>`_
846      -  Required
847      -  N/A
848
849         .. _MisraC_Rule_20_9:
850    * -  116
851      -  All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #defined before evaluation
852      -  `Rule 20.9 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_20_09.c>`_
853      -  Required
854      -  N/A
855
856         .. _MisraC_Rule_20_11:
857    * -  117
858      -  A macro parameter immediately following a # operator shall not immediately be followed by a ## operator
859      -  `Rule 20.11 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_20_11.c>`_
860      -  Required
861      -  N/A
862
863         .. _MisraC_Rule_20_12:
864    * -  118
865      -  A macro parameter used as an operand to the # or ## operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators
866      -  `Rule 20.12 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_20_12.c>`_
867      -  Required
868      -  N/A
869
870         .. _MisraC_Rule_20_13:
871    * -  119
872      -  A line whose first token is # shall be a valid preprocessing directive
873      -  `Rule 20.13 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_20_13.c>`_
874      -  Required
875      -  N/A
876
877         .. _MisraC_Rule_20_14:
878    * -  120
879      -  All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related
880      -  `Rule 20.14 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_20_14.c>`_
881      -  Required
882      -  N/A
883
884         .. _MisraC_Rule_21_1:
885    * -  121
886      -  #define and #undef shall not be used on a reserved identifier or reserved macro name
887      -  `Rule 21.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_01.c>`_
888      -  Required
889      -  N/A
890
891         .. _MisraC_Rule_21_2:
892    * -  122
893      -  A reserved identifier or macro name shall not be declared
894      -  `Rule 21.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_02.c>`_
895      -  Required
896      -  N/A
897
898         .. _MisraC_Rule_21_3:
899    * -  123
900      -  The memory allocation and deallocation functions of <stdlib.h> shall not be used
901      -  `Rule 21.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_03.c>`_
902      -  Required
903      -  `MSC24-C <https://wiki.sei.cmu.edu/confluence/display/c/MSC24-C.+Do+not+use+deprecated+or+obsolescent+functions>`_
904
905         .. _MisraC_Rule_21_4:
906    * -  124
907      -  The standard header file <setjmp.h> shall not be used
908      -  `Rule 21.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_04.c>`_
909      -  Required
910      -  N/A
911
912         .. _MisraC_Rule_21_6:
913    * -  125
914      -  The Standard Library input/output functions shall not be used
915      -  `Rule 21.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_06.c>`_
916      -  Required
917      -  N/A
918
919         .. _MisraC_Rule_21_7:
920    * -  126
921      -  The atof, atoi, atol and atoll functions of <stdlib.h> shall not be used
922      -  `Rule 21.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_07.c>`_
923      -  Required
924      -  N/A
925
926         .. _MisraC_Rule_21_9:
927    * -  127
928      -  The library functions bsearch and qsort of <stdlib.h> shall not be used
929      -  `Rule 21.9 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_09.c>`_
930      -  Required
931      -  N/A
932
933         .. _MisraC_Rule_21_11:
934    * -  128
935      -  The standard header file <tgmath.h> shall not be used
936      -  `Rule 21.11 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_11.c>`_
937      -  Required
938      -  N/A
939
940         .. _MisraC_Rule_21_12:
941    * -  129
942      -  The exception handling features of <fenv.h> should not be used
943      -  `Rule 21.12 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_12.c>`_
944      -  Advisory
945      -  N/A
946
947         .. _MisraC_Rule_21_13:
948    * -  130
949      -  Any value passed to a function in <ctype.h> shall be representable as an unsigned char or be the value EO
950      -  `Rule 21.13 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_13.c>`_
951      -  Mandatory
952      -  N/A
953
954         .. _MisraC_Rule_21_14:
955    * -  131
956      -  The Standard Library function memcmp shall not be used to compare null terminated strings
957      -  `Rule 21.14 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_14.c>`_
958      -  Required
959      -  N/A
960
961         .. _MisraC_Rule_21_15:
962    * -  132
963      -  The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types
964      -  `Rule 21.15 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_15.c>`_
965      -  Required
966      -  N/A
967
968         .. _MisraC_Rule_21_16:
969    * -  133
970      -  The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type
971      -  `Rule 21.16 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_16.c>`_
972      -  Required
973      -  N/A
974
975         .. _MisraC_Rule_21_17:
976    * -  134
977      -  Use of the string handling functions from <string.h> shall not result in accesses beyond the bounds of the objects referenced by their pointer parameters
978      -  `Rule 21.17 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_17.c>`_
979      -  Mandatory
980      -  N/A
981
982         .. _MisraC_Rule_21_18:
983    * -  135
984      -  The size_t argument passed to any function in <string.h> shall have an appropriate value
985      -  `Rule 21.18 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_18.c>`_
986      -  Mandatory
987      -  N/A
988
989         .. _MisraC_Rule_21_19:
990    * -  136
991      -  The pointers returned by the Standard Library functions localeconv, getenv, setlocale or, strerror shall only be used as if they have pointer to const-qualified type
992      -  `Rule 21.19 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_19.c>`_
993      -  Mandatory
994      -  N/A
995
996         .. _MisraC_Rule_21_20:
997    * -  137
998      -  The pointer returned by the Standard Library functions asctime, ctime, gmtime, localtime, localeconv, getenv, setlocale or strerror shall not be used following a subsequent call to the same function
999      -  `Rule 21.20 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_21_20.c>`_
1000      -  Mandatory
1001      -  N/A
1002
1003         .. _MisraC_Rule_22_1:
1004    * -  138
1005      -  All resources obtained dynamically by means of Standard Library functions shall be explicitly released
1006      -  `Rule 22.1 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_22_01.c>`_
1007      -  Required
1008      -  N/A
1009
1010         .. _MisraC_Rule_22_2:
1011    * -  139
1012      -  A block of memory shall only be freed if it was allocated by means of a Standard Library function
1013      -  `Rule 22.2 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_22_02.c>`_
1014      -  Mandatory
1015      -  N/A
1016
1017         .. _MisraC_Rule_22_3:
1018    * -  140
1019      -  The same file shall not be open for read and write access at the same time on different streams
1020      -  `Rule 22.3 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_22_03.c>`_
1021      -  Required
1022      -  N/A
1023
1024         .. _MisraC_Rule_22_4:
1025    * -  141
1026      -  There shall be no attempt to write to a stream which has been opened as read-only
1027      -  `Rule 22.4 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_22_04.c>`_
1028      -  Mandatory
1029      -  N/A
1030
1031         .. _MisraC_Rule_22_5:
1032    * -  142
1033      -  A pointer to a FILE object shall not be dereferenced
1034      -  `Rule 22.5 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_22_05.c>`_
1035      -  Mandatory
1036      -  N/A
1037
1038         .. _MisraC_Rule_22_6:
1039    * -  143
1040      -  The value of a pointer to a FILE shall not be used after the associated stream has been closed
1041      -  `Rule 22.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_22_06.c>`_
1042      -  Mandatory
1043      -  N/A
1044
1045         .. _MisraC_Rule_22_7:
1046    * -  144
1047      -  The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF
1048      -  `Rule 22.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_22_07.c>`_
1049      -  Required
1050      -  N/A
1051
1052         .. _MisraC_Rule_22_8:
1053    * -  145
1054      -  The value of errno shall be set to zero prior to a call to an errno-setting-function
1055      -  `Rule 22.8 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_22_08.c>`_
1056      -  Required
1057      -  N/A
1058
1059         .. _MisraC_Rule_22_9:
1060    * -  146
1061      -  The value of errno shall be tested against zero after calling an errno-setting-function
1062      -  `Rule 22.9 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_22_09.c>`_
1063      -  Required
1064      -  N/A
1065
1066         .. _MisraC_Rule_22_10:
1067    * -  147
1068      -  The value of errno shall only be tested when the last function to be called was an errno-setting-function
1069      -  `Rule 22.10 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_22_10.c>`_
1070      -  Required
1071      -  N/A
1072
1073Additional rules
1074****************
1075
1076Rule A.1: Conditional Compilation
1077=================================
1078Severity
1079  Required
1080
1081Description
1082  Do not conditionally compile function declarations in header files. Do not
1083  conditionally compile structure declarations in header files. You may
1084  conditionally exclude fields within structure definitions to avoid wasting
1085  memory when the feature they support is not enabled.
1086
1087Rationale
1088  Excluding declarations from the header based on compile-time options may prevent
1089  their documentation from being generated. Their absence also prevents use of
1090  ``if (IS_ENABLED(CONFIG_FOO)) {}`` as an alternative to preprocessor
1091  conditionals when the code path should change based on the selected options.
1092
1093.. _coding_guideline_inclusive_language:
1094
1095Rule A.2: Inclusive Language
1096============================
1097Severity
1098  Required
1099
1100Description
1101  Do not introduce new usage of offensive terms listed below. This rule applies
1102  but is not limited to source code, comments, documentation, and branch names.
1103  Replacement terms may vary by area or subsystem, but should aim to follow
1104  updated industry standards when possible.
1105
1106  Exceptions are allowed for maintaining existing implementations or adding new
1107  implementations of industry standard specifications governed externally to the
1108  Zephyr Project.
1109
1110  Existing usage is recommended to change as soon as updated industry standard
1111  specifications become available or new terms are publicly announced by the
1112  governing body, or immediately if no specifications apply.
1113
1114  .. list-table::
1115     :header-rows: 1
1116
1117     * - Offensive Terms
1118       - Recommended Replacements
1119
1120     * - ``{master,leader} / slave``
1121       - - ``{primary,main} / {secondary,replica}``
1122         - ``{initiator,requester} / {target,responder}``
1123         - ``{controller,host} / {device,worker,proxy,target}``
1124         - ``director / performer``
1125         - ``central / peripheral``
1126
1127     * - ``blacklist / whitelist``
1128       - * ``denylist / allowlist``
1129         * ``blocklist / allowlist``
1130         * ``rejectlist / acceptlist``
1131
1132     * - ``grandfather policy``
1133       - * ``legacy``
1134
1135     * - ``sanity``
1136       - * ``coherence``
1137         * ``confidence``
1138
1139Rationale
1140  Offensive terms do not create an inclusive community environment and therefore
1141  violate the Zephyr Project `Code of Conduct`_. This coding rule was inspired by
1142  a similar rule in `Linux`_.
1143
1144  .. _Code of Conduct: https://github.com/zephyrproject-rtos/zephyr/blob/main/CODE_OF_CONDUCT.md
1145  .. _Linux: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=49decddd39e5f6132ccd7d9fdc3d7c470b0061bb
1146
1147Status
1148  Related GitHub Issues and Pull Requests are tagged with the `Inclusive Language Label`_.
1149
1150  .. list-table::
1151     :header-rows: 1
1152
1153     * - Area
1154       - Selected Replacements
1155       - Status
1156
1157     * - :ref:`Bluetooth <bluetooth_api>`
1158       - See `Bluetooth Appropriate Language Mapping Tables`_
1159       -
1160
1161     * - CAN
1162       - This `CAN in Automation Inclusive Language news post`_ has a list of general
1163         recommendations. See `CAN in Automation Inclusive Language`_ for terms to
1164         be used in specification document updates.
1165       -
1166
1167     * - eSPI
1168       - * ``master / slave`` => ``controller / target``
1169       - Refer to `eSPI Specification`_ for new terminology
1170
1171     * - gPTP
1172       - * ``master / slave`` => TBD
1173       -
1174
1175     * - :ref:`i2c_api`
1176       - * ``master / slave`` => TBD
1177       - NXP publishes the `I2C Specification`_ and has selected ``controller /
1178         target`` as replacement terms, but the timing to publish an announcement
1179         or new specification is TBD. Zephyr will update I2C when replacement
1180         terminology is confirmed by a public announcement or updated
1181         specification.
1182
1183         See :github:`Zephyr issue 27033 <27033>`.
1184
1185     * - :ref:`i2s_api`
1186       - * ``master / slave`` => TBD
1187       -
1188
1189     * - SMP/AMP
1190       - * ``master / slave`` => TBD
1191       -
1192
1193     * - :ref:`spi_api`
1194       - * ``master / slave`` => ``controller / peripheral``
1195         * ``MOSI / MISO / SS`` => ``SDO / SDI / CS``
1196       - The Open Source Hardware Association has selected these replacement
1197         terms. See `OSHWA Resolution to Redefine SPI Signal Names`_
1198
1199     * - :ref:`twister_script`
1200       - * ``platform_whitelist`` => ``platform_allow``
1201         * ``sanitycheck`` => ``twister``
1202       -
1203
1204  .. _Inclusive Language Label: https://github.com/zephyrproject-rtos/zephyr/issues?q=label%3A%22Inclusive+Language%22
1205  .. _I2C Specification: https://www.nxp.com/docs/en/user-guide/UM10204.pdf
1206  .. _Bluetooth Appropriate Language Mapping Tables: https://specificationrefs.bluetooth.com/language-mapping/Appropriate_Language_Mapping_Table.pdf
1207  .. _OSHWA Resolution to Redefine SPI Signal Names: https://www.oshwa.org/a-resolution-to-redefine-spi-signal-names/
1208  .. _CAN in Automation Inclusive Language news post: https://www.can-cia.org/news/archive/view/?tx_news_pi1%5Bnews%5D=699&tx_news_pi1%5Bday%5D=6&tx_news_pi1%5Bmonth%5D=12&tx_news_pi1%5Byear%5D=2020&cHash=784e79eb438141179386cf7c29ed9438
1209  .. _CAN in Automation Inclusive Language: https://can-newsletter.org/canopen/categories/
1210  .. _eSPI Specification: https://downloadmirror.intel.com/27055/327432%20espi_base_specification%20R1-5.pdf
1211
1212
1213.. _coding_guideline_libc_usage_restrictions_in_zephyr_kernel:
1214
1215Rule A.3: Macro name collisions
1216===============================
1217Severity
1218  Required
1219
1220Description
1221  Macros with commonly used names such as ``MIN``, ``MAX``, ``ARRAY_SIZE``, must not be modified or
1222  protected to avoid name collisions with other implementations. In particular, they must not be
1223  prefixed to place them in a Zephyr-specific namespace, re-defined using ``#undef``, or
1224  conditionally excluded from compilation using ``#ifndef``. Instead, if a conflict arises with an
1225  existing definition originating from a :ref:`module <modules>`, the module's code itself needs to
1226  be modified (ideally upstream, alternatively via a change in Zephyr's own fork).
1227
1228  This rule applies to Zephyr as a project in general, regardless of the time of introduction of the
1229  macro or its current name in the tree. If a macro name is commonly used in several other well-known
1230  open source projects then the implementation in Zephyr should use that name. While there is a
1231  subjective and non-measurable component to what "commonly used" means, the ultimate goal is to offer
1232  users familiar macros.
1233
1234  Finally, this rule applies to inter-module name collisions as well: in that case both modules, prior
1235  to their inclusion, should be modified to use module-specific versions of the macro name that
1236  collides.
1237
1238Rationale
1239  Zephyr is an RTOS that comes with additional functionality and dependencies in the form of modules.
1240  Those modules are typically independent projects that may use macro names that can conflict with
1241  other modules or with Zephyr itself. Since, in the context of this documentation, Zephyr is
1242  considered the central or main project, it should implement the non-namespaced versions of the
1243  macros. Given that Zephyr uses a fork of the corresponding upstream for each module, it is always
1244  possible to patch the macro implementation in each module to avoid collisions.
1245
1246Rule A.4: C Standard Library Usage Restrictions in Zephyr Kernel
1247================================================================
1248Severity
1249  Required
1250
1251Description
1252  The use of the C standard library functions and macros in the Zephyr kernel
1253  shall be limited to the following functions and macros from the ISO/IEC
1254  9899:2011 standard, also known as C11, and their extensions:
1255
1256  .. csv-table:: List of allowed libc functions and macros in the Zephyr kernel
1257     :header: Function,Source
1258     :widths: auto
1259
1260     abort(),ISO/IEC 9899:2011
1261     abs(),ISO/IEC 9899:2011
1262     aligned_alloc(),ISO/IEC 9899:2011
1263     assert(),ISO/IEC 9899:2011
1264     atoi(),ISO/IEC 9899:2011
1265     bsearch(),ISO/IEC 9899:2011
1266     calloc(),ISO/IEC 9899:2011
1267     exit(),ISO/IEC 9899:2011
1268     fprintf(),ISO/IEC 9899:2011
1269     fputc(),ISO/IEC 9899:2011
1270     fputs(),ISO/IEC 9899:2011
1271     free(),ISO/IEC 9899:2011
1272     fwrite(),ISO/IEC 9899:2011
1273     gmtime(),ISO/IEC 9899:2011
1274     isalnum(),ISO/IEC 9899:2011
1275     isalpha(),ISO/IEC 9899:2011
1276     iscntrl(),ISO/IEC 9899:2011
1277     isdigit(),ISO/IEC 9899:2011
1278     isgraph(),ISO/IEC 9899:2011
1279     isprint(),ISO/IEC 9899:2011
1280     isspace(),ISO/IEC 9899:2011
1281     isupper(),ISO/IEC 9899:2011
1282     isxdigit(),ISO/IEC 9899:2011
1283     labs(),ISO/IEC 9899:2011
1284     llabs(),ISO/IEC 9899:2011
1285     malloc(),ISO/IEC 9899:2011
1286     memchr(),ISO/IEC 9899:2011
1287     memcmp(),ISO/IEC 9899:2011
1288     memcpy(),ISO/IEC 9899:2011
1289     memmove(),ISO/IEC 9899:2011
1290     memset(),ISO/IEC 9899:2011
1291     perror(),ISO/IEC 9899:2011
1292     printf(),ISO/IEC 9899:2011
1293     putc(),ISO/IEC 9899:2011
1294     putchar(),ISO/IEC 9899:2011
1295     puts(),ISO/IEC 9899:2011
1296     qsort(),ISO/IEC 9899:2011
1297     rand(),ISO/IEC 9899:2011
1298     realloc(),ISO/IEC 9899:2011
1299     snprintf(),ISO/IEC 9899:2011
1300     sprintf(),ISO/IEC 9899:2011
1301     sqrt(),ISO/IEC 9899:2011
1302     sqrtf(),ISO/IEC 9899:2011
1303     srand(),ISO/IEC 9899:2011
1304     strcat(),ISO/IEC 9899:2011
1305     strchr(),ISO/IEC 9899:2011
1306     strcmp(),ISO/IEC 9899:2011
1307     strcpy(),ISO/IEC 9899:2011
1308     strcspn(),ISO/IEC 9899:2011
1309     strerror(),ISO/IEC 9899:2011
1310     strlen(),ISO/IEC 9899:2011
1311     strncat(),ISO/IEC 9899:2011
1312     strncmp(),ISO/IEC 9899:2011
1313     strncpy(),ISO/IEC 9899:2011
1314     `strnlen()`_,POSIX.1-2008
1315     strrchr(),ISO/IEC 9899:2011
1316     strspn(),ISO/IEC 9899:2011
1317     strstr(),ISO/IEC 9899:2011
1318     strtol(),ISO/IEC 9899:2011
1319     strtoll(),ISO/IEC 9899:2011
1320     strtoul(),ISO/IEC 9899:2011
1321     strtoull(),ISO/IEC 9899:2011
1322     time(),ISO/IEC 9899:2011
1323     tolower(),ISO/IEC 9899:2011
1324     toupper(),ISO/IEC 9899:2011
1325     vfprintf(),ISO/IEC 9899:2011
1326     vprintf(),ISO/IEC 9899:2011
1327     vsnprintf(),ISO/IEC 9899:2011
1328     vsprintf(),ISO/IEC 9899:2011
1329
1330  All of the functions listed above must be implemented by the
1331  :ref:`minimal libc <c_library_minimal>` to ensure that the Zephyr kernel can
1332  build with the minimal libc.
1333
1334  In addition, any functions from the above list that are not part of the
1335  ISO/IEC 9899:2011 standard must be implemented by the
1336  :ref:`common libc <c_library_common>` to ensure their availability across
1337  multiple C standard libraries.
1338
1339  Introducing new C standard library functions to the Zephyr kernel is allowed
1340  with justification given that the above requirements are satisfied.
1341
1342  Note that the use of the functions listed above are subject to secure and safe
1343  coding practices and it should not be assumed that their use in the Zephyr
1344  kernel is unconditionally permitted by being listed in this rule.
1345
1346  The "Zephyr kernel" in this context consists of the following components:
1347
1348  * Kernel (:file:`kernel`)
1349  * OS Library (:file:`lib/os`)
1350  * Architecture Port (:file:`arch`)
1351  * Logging Subsystem (:file:`subsys/logging`)
1352
1353Rationale
1354  Zephyr kernel must be able to build with the
1355  :ref:`minimal libc <c_library_minimal>`, a limited C standard library
1356  implementation that is part of the Zephyr RTOS and maintained by the Zephyr
1357  Project, to allow self-contained testing and verification of the kernel and
1358  core OS services.
1359
1360  In order to ensure that the Zephyr kernel can build with the minimal libc, it
1361  is necessary to restrict the use of the C standard library functions and macros
1362  in the Zephyr kernel to the functions and macros that are available as part of
1363  the minimal libc.
1364
1365Rule A.5: C Standard Library Usage Restrictions in Zephyr Codebase
1366==================================================================
1367Severity
1368  Required
1369
1370Description
1371  The use of the C standard library functions and macros in the Zephyr codebase
1372  shall be limited to the functions, excluding the Annex K "Bounds-checking
1373  interfaces", from the ISO/IEC 9899:2011 standard, also known as C11, unless
1374  exempted by this rule.
1375
1376  The "Zephyr codebase" in this context refers to all embedded source code files committed
1377  to the `main Zephyr repository`_, except the Zephyr kernel as defined by the
1378  :ref:`coding_guideline_libc_usage_restrictions_in_zephyr_kernel`.
1379  With embedded source code we refer to code which is meant to be executed in embedded
1380  targets, and therefore excludes host tooling, and code specific for the
1381  :ref:`native <boards_posix>` test targets.
1382
1383  The following non-ISO 9899:2011, hereinafter referred to as non-standard,
1384  functions and macros are exempt from this rule and allowed to be used in the
1385  Zephyr codebase:
1386
1387  .. csv-table:: List of allowed non-standard libc functions
1388     :header: Function,Source
1389     :widths: auto
1390
1391     `gmtime_r()`_,POSIX.1-2001
1392     `strnlen()`_,POSIX.1-2008
1393     `strtok_r()`_,POSIX.1-2001
1394
1395  All non-standard functions and macros listed above must be implemented by the
1396  :ref:`common libc <c_library_common>` in order to make sure that these
1397  functions can be made available when using a C standard library that does not
1398  implement these functions.
1399
1400  Adding a new non-standard function from common C standard libraries to the
1401  above list is allowed with justification, given that the above requirement is
1402  satisfied. However, when there exists a standard function that is functionally
1403  equivalent, the standard function shall be used.
1404
1405Rationale
1406  Some C standard libraries, such as Newlib and Picolibc, include additional
1407  functions and macros that are defined by the standards and de-facto standards
1408  that extend the ISO C standard (e.g. POSIX, Linux).
1409
1410  The ISO/IEC 9899:2011 standard does not require C compiler toolchains to
1411  include the support for these non-standard functions, and therefore using
1412  these functions can lead to compatibility issues with the third-party
1413  toolchains that come with their own C standard libraries.
1414
1415  .. _main Zephyr repository: https://github.com/zephyrproject-rtos/zephyr
1416  .. _gmtime_r(): https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime_r.html
1417  .. _strnlen(): https://pubs.opengroup.org/onlinepubs/9699919799/functions/strlen.html
1418  .. _strtok_r(): https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html
1419