Skip to content

Commit 486435c

Browse files
committed
Remove unneeded cppcheck misra suppress
- c2012-17.7 - memcpy, strcpy
1 parent b6c3846 commit 486435c

File tree

5 files changed

+0
-24
lines changed

5 files changed

+0
-24
lines changed

Src/json.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Json_startString(char* buffer, size_t buffer_size) {
4343
bool success = false;
4444

4545
if (buffer_size >= MINIMAL_SIZE) {
46-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case, therefore it is not used
4746
strcpy(&buffer[0], "{");
4847
success = true;
4948
}
@@ -59,25 +58,19 @@ Json_addData(char* buffer, size_t buffer_size, const char* key, const char* valu
5958
size_t total_size = strlen("\"\":\"\"") + strlen(key) + strlen(value) + 1U;
6059

6160
if (0 == strcmp(&buffer[index - 1U], "\"")) {
62-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case, therefore it is not used
6361
strcpy(&buffer[index], ",");
6462
++index;
6563
}
6664

6765
if ((total_size + index) <= buffer_size) {
68-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case, therefore it is not used
6966
strcpy(&buffer[index], "\"");
7067
index += strlen("\"");
71-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case, therefore it is not used
7268
strcpy(&buffer[index], key);
7369
index += strlen(key);
74-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case, therefore it is not used
7570
strcpy(&buffer[index], "\":\"");
7671
index += strlen("\":\"");
77-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case, therefore it is not used
7872
strcpy(&buffer[index], value);
7973
index += strlen(value);
80-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case, therefore it is not used
8174
strcpy(&buffer[index], "\"");
8275

8376
success = true;
@@ -92,7 +85,6 @@ Json_endString(char* buffer, size_t buffer_size) {
9285

9386
size_t index = strlen(buffer);
9487
if (buffer_size >= (MINIMAL_SIZE + index)) {
95-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case, therefore it is not used
9688
strcpy(&buffer[index], "}");
9789
success = true;
9890
}

Src/map.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,12 @@ Map_insert(Map_t* map, const byte_t* key, const byte_t* value) {
7373
int32_t index = GetIndex(map, key, map->current_size);
7474
if (index == INDEX_NOT_FOUND) {
7575
if (map->current_size != map->max_map_size) {
76-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
7776
memcpy(&map->keys[map->current_size * map->key_size], key, (size_t)map->key_size);
78-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
7977
memcpy(&map->values[map->current_size * map->value_size], value, (size_t)map->value_size);
8078
++map->current_size;
8179
status = true;
8280
}
8381
} else {
84-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
8582
memcpy(&map->values[index * map->value_size], value, (size_t)map->value_size);
8683
status = true;
8784
}
@@ -95,7 +92,6 @@ Map_getValue(const Map_t* map, const byte_t* key, byte_t* value) {
9592
if (map != NULL_PTR) {
9693
int32_t index = GetIndex(map, key, map->current_size);
9794
if (index != INDEX_NOT_FOUND) {
98-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
9995
memcpy(value, &map->values[index * map->value_size], (size_t)map->value_size);
10096
status = true;
10197
}

Src/priority_queue.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ PriorityQueue_enqueue(PriorityQueue_t* queue, const PriorityQueueItem_t* item) {
9696
bool status = false;
9797
if (!Full(queue)) {
9898
uint8_t* buffer = queue->buffer;
99-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
10099
memcpy(&buffer[queue->size * queue->element_size], item->element, queue->element_size);
101100
queue->priority_array[queue->size] = *(item->priority);
102101
queue->size = queue->size + 1U;
@@ -109,12 +108,10 @@ PriorityQueue_enqueue(PriorityQueue_t* queue, const PriorityQueueItem_t* item) {
109108
queue->size = queue->size - 1U;
110109
const uint32_t current_size = queue->size;
111110
for (uint32_t i = lowest_priority_index; i < current_size; ++i) {
112-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
113111
memcpy(&buffer[i * queue->element_size], &buffer[(i * queue->element_size) + queue->element_size],
114112
queue->element_size);
115113
queue->priority_array[i] = queue->priority_array[i + 1U];
116114
}
117-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
118115
memcpy(&buffer[queue->size * queue->element_size], item->element, queue->element_size);
119116
queue->priority_array[queue->size] = *(item->priority);
120117
queue->size = queue->size + 1U;
@@ -130,12 +127,10 @@ PriorityQueue_dequeue(PriorityQueue_t* queue, uint8_t* element) {
130127
status = true;
131128
uint32_t highest_priority_index = GetHighestPriorityIndex(queue);
132129
uint8_t* buffer = queue->buffer;
133-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
134130
memcpy(element, &buffer[highest_priority_index * queue->element_size], queue->element_size);
135131
queue->size = queue->size - 1U;
136132
const uint32_t current_size = queue->size;
137133
for (uint32_t i = highest_priority_index; i < current_size; ++i) {
138-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
139134
memcpy(&buffer[i * queue->element_size], &buffer[(i * queue->element_size) + queue->element_size],
140135
queue->element_size);
141136
queue->priority_array[i] = queue->priority_array[i + 1U];

Src/queue.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ Queue_enqueue(Queue_t* queue, const uint8_t* element) {
6767
if ((queue != NULL_PTR) && (element != NULL_PTR)) {
6868
if (!Queue_full(queue)) {
6969
uint8_t* buffer = queue->buffer;
70-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
7170
memcpy(&buffer[((queue->rear + 1U) % queue->capacity) * queue->element_size], element, queue->element_size);
7271
queue->rear = (queue->rear + 1U) % queue->capacity;
7372
queue->size = queue->size + 1U;
@@ -83,7 +82,6 @@ Queue_dequeue(Queue_t* queue, uint8_t* element) {
8382
if ((queue != NULL_PTR) && (element != NULL_PTR)) {
8483
if (!Queue_empty(queue)) {
8584
const uint8_t* buffer = (const uint8_t*)queue->buffer;
86-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
8785
memcpy(element, &buffer[queue->front * queue->element_size], queue->element_size);
8886
queue->front = (queue->front + 1U) % queue->capacity;
8987
queue->size = queue->size - 1U;
@@ -99,7 +97,6 @@ Queue_front(const Queue_t* queue, uint8_t* element) {
9997
if ((queue != NULL_PTR) && (element != NULL_PTR)) {
10098
if (!Queue_empty(queue)) {
10199
const uint8_t* buffer = (const uint8_t*)queue->buffer;
102-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
103100
memcpy(element, &buffer[queue->front * queue->element_size], queue->element_size);
104101
status = true;
105102
}
@@ -113,7 +110,6 @@ Queue_rear(const Queue_t* queue, uint8_t* element) {
113110
if ((queue != NULL_PTR) && (element != NULL_PTR)) {
114111
if (!Queue_empty(queue)) {
115112
const uint8_t* buffer = (const uint8_t*)queue->buffer;
116-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
117113
memcpy(element, &buffer[queue->rear * queue->element_size], queue->element_size);
118114
status = true;
119115
}

Src/sort/insertion_sort.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,16 @@ InsertionSort_sort(byte_t* buffer, int32_t number_of_elements, int32_t element_s
4444
byte_t* element = &max_element[0];
4545

4646
for (int32_t i = 1; i < number_of_elements; ++i) {
47-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
4847
memcpy(element, &elements[i * element_size], (size_t)element_size);
4948

5049
int32_t j = i - 1;
5150
bool compare = compareFun(&elements[j * element_size], element);
5251

5352
while ((j >= 0) && compare) {
54-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
5553
memcpy(&elements[(j + 1) * element_size], &elements[j * element_size], (size_t)element_size);
5654
--j;
5755
compare = compareFun(&elements[j * element_size], element);
5856
}
59-
// cppcheck-suppress misra-c2012-17.7; return value is not needed in this case
6057
memcpy(&elements[(j + 1) * element_size], element, (size_t)element_size);
6158
}
6259
}

0 commit comments

Comments
 (0)