-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathPointers1.json
More file actions
362 lines (362 loc) · 15.1 KB
/
Pointers1.json
File metadata and controls
362 lines (362 loc) · 15.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
{
"MISRA-C-2012": {
"RULE-11-1": {
"properties": {
"obligation": "required"
},
"queries": [
{
"description": "Converting between a function pointer into an incompatible type results in undefined behaviour.",
"kind": "problem",
"name": "Conversions shall not be performed between a pointer to a function and any other type",
"precision": "very-high",
"severity": "error",
"short_name": "ConversionBetweenFunctionPointerAndOtherType",
"tags": [
"correctness",
"external/misra/c/2012/third-edition-first-revision"
]
}
],
"title": "Conversions shall not be performed between a pointer to a function and any other type"
},
"RULE-11-2": {
"properties": {
"obligation": "required"
},
"queries": [
{
"description": "Converting between a pointer to an incomplete type to another type can result in undefined behaviour or violate encapsulation.",
"kind": "problem",
"name": "Conversions shall not be performed between a pointer to an incomplete type and any other type",
"precision": "very-high",
"severity": "error",
"short_name": "ConversionBetweenIncompleteTypePointerAndOtherType",
"tags": [
"correctness",
"external/misra/c/2012/third-edition-first-revision"
]
}
],
"title": "Conversions shall not be performed between a pointer to an incomplete type and any other type"
},
"RULE-11-3": {
"properties": {
"obligation": "required"
},
"queries": [
{
"description": "Casting between an object pointer and a pointer to a different object type can result in a pointer that is incorrectly aligned or that results in undefined behaviour if accessed.",
"kind": "problem",
"name": "A cast shall not be performed between a pointer to object type and a pointer to a different object",
"precision": "very-high",
"severity": "error",
"short_name": "CastBetweenObjectPointerAndDifferentObjectType",
"tags": [
"correctness",
"external/misra/c/2012/third-edition-first-revision"
]
}
],
"title": "A cast shall not be performed between a pointer to object type and a pointer to a different object type"
},
"RULE-11-4": {
"properties": {
"obligation": "advisory"
},
"queries": [
{
"description": "Converting between a pointer to an object and an integer type may result in undefined behaviour.",
"kind": "problem",
"name": "A conversion should not be performed between a pointer to object and an integer type",
"precision": "very-high",
"severity": "error",
"short_name": "ConversionBetweenPointerToObjectAndIntegerType",
"tags": [
"correctness",
"external/misra/c/2012/third-edition-first-revision"
]
}
],
"title": "A conversion should not be performed between a pointer to object and an integer type"
},
"RULE-11-5": {
"properties": {
"obligation": "advisory"
},
"queries": [
{
"description": "Converting from a pointer to void into a pointer to an object may result in an incorrectly aligned pointer and undefined behaviour.",
"kind": "problem",
"name": "A conversion should not be performed from pointer to void into pointer to object",
"precision": "very-high",
"severity": "error",
"short_name": "ConversionFromPointerToVoidIntoPointerToObject",
"tags": [
"correctness",
"external/misra/c/2012/third-edition-first-revision"
]
}
],
"title": "A conversion should not be performed from pointer to void into pointer to object"
},
"RULE-11-6": {
"properties": {
"obligation": "required"
},
"queries": [
{
"description": "Converting from an integer into a pointer to void may result in an incorrectly aligned pointer and undefined behaviour.",
"kind": "problem",
"name": "A cast shall not be performed between pointer to void and an arithmetic type",
"precision": "very-high",
"severity": "error",
"short_name": "CastBetweenPointerToVoidAndArithmeticType",
"tags": [
"correctness",
"external/misra/c/2012/third-edition-first-revision"
]
}
],
"title": "A cast shall not be performed between pointer to void and an arithmetic type"
},
"RULE-11-7": {
"properties": {
"obligation": "required"
},
"queries": [
{
"description": "Converting between a pointer to an object and a pointer to a non-integer arithmetic type can result in undefined behaviour.",
"kind": "problem",
"name": "A cast shall not be performed between pointer to object and a non-integer arithmetic type",
"precision": "very-high",
"severity": "error",
"short_name": "CastBetweenPointerToObjectAndNonIntArithmeticType",
"tags": [
"correctness",
"external/misra/c/2012/third-edition-first-revision"
]
}
],
"title": "A cast shall not be performed between pointer to object and a non-integer arithmetic type"
},
"RULE-11-8": {
"properties": {
"obligation": "required"
},
"queries": [
{
"description": "Casting away const or volatile qualifications violates the principle of type qualification and can result in unpredictable behaviour.",
"kind": "problem",
"name": "A cast shall not remove any const or volatile qualification from the type pointed to by a pointer",
"precision": "very-high",
"severity": "error",
"short_name": "CastRemovesConstOrVolatileQualification",
"tags": [
"correctness",
"external/misra/c/2012/third-edition-first-revision"
]
}
],
"title": "A cast shall not remove any const or volatile qualification from the type pointed to by a pointer"
},
"RULE-11-9": {
"properties": {
"obligation": "required"
},
"queries": [
{
"description": "The macro NULL unambiguously signifies the intended use of a null pointer constant.",
"kind": "problem",
"name": "The macro NULL shall be the only permitted form of integer null pointer constant",
"precision": "very-high",
"severity": "error",
"short_name": "MacroNullNotUsedAsIntegerNullPointerConstant",
"tags": [
"readability",
"external/misra/c/2012/third-edition-first-revision"
],
"implementation_scope": {
"description": "This rule allows two forms of null-pointer constants: a Zero literal created by the NULL macro or a Zero literal cast to a void pointer."
}
}
],
"title": "The macro NULL shall be the only permitted form of integer null pointer constant"
},
"RULE-18-1": {
"properties": {
"obligation": "required"
},
"queries": [
{
"description": "A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand.",
"kind": "problem",
"name": "A pointer resulting from arithmetic on a pointer operand shall address an element of the same array",
"precision": "medium",
"severity": "error",
"short_name": "PointerAndDerivedPointerMustAddressSameArray",
"shared_implementation_short_name": "DoNotUsePointerArithmeticToAddressDifferentArrays",
"tags": [
"correctness",
"external/misra/c/2012/third-edition-first-revision"
]
}
],
"title": "A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand"
},
"RULE-18-2": {
"properties": {
"obligation": "required"
},
"queries": [
{
"description": "Subtraction between pointers which do not both point to elements of the same array results in undefined behavior.",
"kind": "path-problem",
"name": "Subtraction between pointers shall only be applied to pointers that address elements of the same array",
"precision": "high",
"severity": "error",
"short_name": "SubtractionBetweenPointersMustAddressSameArray",
"shared_implementation_short_name": "DoNotSubtractPointersAddressingDifferentArrays",
"tags": [
"correctness",
"external/misra/c/2012/third-edition-first-revision"
]
}
],
"title": "Subtraction between pointers shall only be applied to pointers that address elements of the same array"
},
"RULE-18-3": {
"properties": {
"obligation": "required"
},
"queries": [
{
"description": "The relational operators >, >=, <, <= applied to pointers produces undefined behavior, except where they point to the same object.",
"kind": "path-problem",
"name": "The relational operators >, >=, < and <= shall not be applied to pointers unless they point to the same object",
"precision": "high",
"severity": "error",
"short_name": "RelationalOperatorComparesPointerToDifferentArray",
"shared_implementation_short_name": "DoNotUseRelationalOperatorsWithDifferingArrays",
"tags": [
"correctness",
"external/misra/c/2012/third-edition-first-revision"
]
}
],
"title": "The relational operators >, >=, < and <= shall not be applied to expressions of pointer type except where they point into the same object"
},
"RULE-18-4": {
"properties": {
"obligation": "advisory"
},
"queries": [
{
"description": "Array indexing should be used to perform pointer arithmetic as it is less prone to errors and undefined behaviour.",
"kind": "problem",
"name": "The +, -, += and -= operators should not be applied to an expression of pointer type",
"precision": "high",
"severity": "error",
"short_name": "DoNotUseAdditionOrSubtractionOperatorsOnPointers",
"shared_implementation_short_name": "UseOnlyArrayIndexingForPointerArithmetic",
"tags": [
"correctness",
"external/misra/c/2012/third-edition-first-revision"
]
}
],
"title": "The +, -, += and -= operators should not be applied to an expression of pointer type"
},
"RULE-18-5": {
"properties": {
"obligation": "advisory"
},
"queries": [
{
"description": "Declarations with more than two levels of pointer nesting can result in code that is difficult to read and understand.",
"kind": "problem",
"name": "Declarations should contain no more than two levels of pointer nesting",
"precision": "very-high",
"severity": "error",
"short_name": "NoMoreThanTwoLevelsOfPointerNestingInDeclarations",
"shared_implementation_short_name": "DoNotUseMoreThanTwoLevelsOfPointerIndirection",
"tags": [
"readability",
"external/misra/c/2012/third-edition-first-revision"
]
}
],
"title": "Declarations should contain no more than two levels of pointer nesting"
},
"RULE-18-6": {
"properties": {
"obligation": "required"
},
"queries": [
{
"description": "Storing the address of an object in a new object that persists past the original object's lifetime results in undefined behaviour if the address is subsequently accessed.",
"kind": "problem",
"name": "The address of an object with automatic storage shall not be copied to another object that persists",
"precision": "very-high",
"severity": "error",
"short_name": "AutomaticStorageObjectAddressCopiedToOtherObject",
"shared_implementation_short_name": "DoNotCopyAddressOfAutoStorageObjectToOtherObject",
"tags": [
"correctness",
"external/misra/c/2012/third-edition-first-revision"
]
}
],
"title": "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"
},
"DIR-4-8": {
"properties": {
"obligation": "advisory"
},
"queries": [
{
"description": "If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden to prevent unintentional changes.",
"kind": "problem",
"name": "The implementation of an object shall be hidden if a pointer to its structure or union is never dereferenced within a translation unit",
"precision": "very-high",
"severity": "error",
"short_name": "ObjectWithNoPointerDereferenceShouldBeOpaque",
"tags": [
"readability",
"maintainability",
"external/misra/c/2012/third-edition-first-revision"
],
"implementation_scope": {
"description": "This rule considers all cases where a structure or union is referenced as a pointer but has no FieldAccess within a translation unit. Further excluded from this rule are translation units in which the structure or union is declared as a non-pointer variable."
}
}
],
"title": "If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden"
},
"RULE-8-13": {
"properties": {
"obligation": "advisory"
},
"queries": [
{
"description": "A pointer should point to a const-qualified type unless it is used to modify an object or the underlying object data is copied.",
"kind": "problem",
"name": "A pointer should point to a const-qualified type whenever possible",
"precision": "high",
"severity": "error",
"short_name": "PointerShouldPointToConstTypeWhenPossible",
"tags": [
"correctness",
"maintainability",
"readability",
"external/misra/c/2012/third-edition-first-revision"
],
"implementation_scope": {
"description": "To exclude compliant exceptions, this rule only excludes direct assignments of pointers to non-const-qualified types in the context of a single function and does not cover memory-copying functions. This rule also excludes pointers passed to other functions without conversion."
}
}
],
"title": "A pointer should point to a const-qualified type whenever possible"
}
}
}