Skip to content

Commit b3fb756

Browse files
committed
Fix formatting
1 parent e8cb6b5 commit b3fb756

1 file changed

Lines changed: 9 additions & 15 deletions

File tree

cpp/misra/test/rules/RULE-8-7-1/test.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ void stack_allocated_single_dimensional_pointer_arithmetic(int *array) {
1313
int *invalid1 =
1414
array +
1515
4; // NON_COMPLIANT: pointer points more than one beyond the last element
16-
int *invalid2 =
17-
array - 1; // NON_COMPLIANT: pointer is outside boundary
16+
int *invalid2 = array - 1; // NON_COMPLIANT: pointer is outside boundary
1817
}
1918

2019
void stack_allocated_single_dimensional_array_access(int *array) {
@@ -26,8 +25,7 @@ void stack_allocated_single_dimensional_array_access(int *array) {
2625
// element, but non-compliant to Rule 4.1.3
2726
int invalid1 = array[4]; // NON_COMPLIANT: pointer points more than one beyond
2827
// the last element
29-
int invalid2 =
30-
array[-1]; // NON_COMPLIANT: pointer is outside boundary
28+
int invalid2 = array[-1]; // NON_COMPLIANT: pointer is outside boundary
3129
}
3230

3331
void malloc_single_dimensional_pointer_arithmetic(int *array) { // [1, 4]
@@ -43,8 +41,7 @@ void malloc_single_dimensional_pointer_arithmetic(int *array) { // [1, 4]
4341
// beyond the last element (lower bound: 1)
4442
int *invalid2 = array + 5; // NON_COMPLIANT: pointer points more than one
4543
// beyond the last element (lower bound: 1)
46-
int *invalid3 =
47-
array - 1; // NON_COMPLIANT: pointer is outside boundary
44+
int *invalid3 = array - 1; // NON_COMPLIANT: pointer is outside boundary
4845
}
4946

5047
void malloc_single_dimensional_array_access(int *array) { // [1, 4]
@@ -75,8 +72,7 @@ void calloc_single_dimensional_pointer_arithmetic(int *array) { // [2, 5]
7572
// the last element (lower bound: 2)
7673
int *invalid1 = array + 4; // NON_COMPLIANT: pointer points more than one
7774
// beyond the last element (lower bound: 2)
78-
int *invalid2 =
79-
array - 1; // NON_COMPLIANT: pointer is outside boundary
75+
int *invalid2 = array - 1; // NON_COMPLIANT: pointer is outside boundary
8076
}
8177

8278
void calloc_single_dimensional_array_access(int *array) { // [2, 5]
@@ -90,8 +86,7 @@ void calloc_single_dimensional_array_access(int *array) { // [2, 5]
9086
// the last element (lower bound: 2)
9187
int invalid1 = array[4]; // NON_COMPLIANT: pointer points more than one
9288
// beyond the last element (lower bound: 2)
93-
int invalid2 =
94-
array[-1]; // NON_COMPLIANT: pointer is outside boundary
89+
int invalid2 = array[-1]; // NON_COMPLIANT: pointer is outside boundary
9590
}
9691

9792
void realloc_single_dimensional_pointer_arithmetic(int *array) { // [3, 6]
@@ -105,8 +100,7 @@ void realloc_single_dimensional_pointer_arithmetic(int *array) { // [3, 6]
105100
// element (lower bound: 3)
106101
int *invalid1 = array + 4; // NON_COMPLIANT: pointer points more than one
107102
// beyond the last element (lower bound: 3)
108-
int *invalid2 =
109-
array - 1; // NON_COMPLIANT: pointer is outside boundary
103+
int *invalid2 = array - 1; // NON_COMPLIANT: pointer is outside boundary
110104
}
111105

112106
void realloc_single_dimensional_array_access(int *array) { // [3, 6]
@@ -122,8 +116,7 @@ void realloc_single_dimensional_array_access(int *array) { // [3, 6]
122116
// element, but non-compliant to Rule 4.1.3 (lower bound: 3)
123117
int invalid1 = array[4]; // NON_COMPLIANT: pointer points more than one beyond
124118
// the last element (lower bound: 3)
125-
int invalid2 =
126-
array[-1]; // NON_COMPLIANT: pointer is outside boundary
119+
int invalid2 = array[-1]; // NON_COMPLIANT: pointer is outside boundary
127120
}
128121

129122
void stack_allocated_multi_dimensional_array_access(int array[2][3]) {
@@ -540,7 +533,8 @@ int main(int argc, char *argv[]) {
540533
int stack_multi_dimensional_array[2][3] = {{1, 2, 3}, {4, 5, 6}};
541534

542535
/* 4. Multi-dimensional array initialized on the heap */
543-
int(*heap_multi_dimensional_array)[3] = (int(*)[3])malloc(sizeof(int[2][3]));
536+
int (*heap_multi_dimensional_array)[3] =
537+
(int (*)[3])malloc(sizeof(int[2][3]));
544538

545539
stack_allocated_multi_dimensional_array_access(stack_multi_dimensional_array);
546540
stack_allocated_multi_dimensional_pointer_arithmetic(

0 commit comments

Comments
 (0)