Skip to content

Commit

Permalink
coding guidelines: comply with MISRA C:2012 Rule 21.15
Browse files Browse the repository at this point in the history
- made explicit the copied data type

Signed-off-by: Abramo Bagnara <abramo.bagnara@bugseng.com>
  • Loading branch information
Abramo-Bagnara authored and nashif committed Apr 7, 2022
1 parent 88608b2 commit 7229c12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions kernel/msg_q.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ int z_impl_k_msgq_put(struct k_msgq *msgq, const void *data, k_timeout_t timeout
return 0;
} else {
/* put message in queue */
(void)memcpy(msgq->write_ptr, data, msgq->msg_size);
(void)memcpy(msgq->write_ptr, (char *)data, msgq->msg_size);
msgq->write_ptr += msgq->msg_size;
if (msgq->write_ptr == msgq->buffer_end) {
msgq->write_ptr = msgq->buffer_start;
Expand Down Expand Up @@ -217,7 +217,7 @@ int z_impl_k_msgq_get(struct k_msgq *msgq, void *data, k_timeout_t timeout)

if (msgq->used_msgs > 0U) {
/* take first available message from queue */
(void)memcpy(data, msgq->read_ptr, msgq->msg_size);
(void)memcpy((char *)data, msgq->read_ptr, msgq->msg_size);
msgq->read_ptr += msgq->msg_size;
if (msgq->read_ptr == msgq->buffer_end) {
msgq->read_ptr = msgq->buffer_start;
Expand All @@ -230,7 +230,7 @@ int z_impl_k_msgq_get(struct k_msgq *msgq, void *data, k_timeout_t timeout)
SYS_PORT_TRACING_OBJ_FUNC_BLOCKING(k_msgq, get, msgq, timeout);

/* add thread's message to queue */
(void)memcpy(msgq->write_ptr, pending_thread->base.swap_data,
(void)memcpy(msgq->write_ptr, (char *)pending_thread->base.swap_data,
msgq->msg_size);
msgq->write_ptr += msgq->msg_size;
if (msgq->write_ptr == msgq->buffer_end) {
Expand Down Expand Up @@ -290,7 +290,7 @@ int z_impl_k_msgq_peek(struct k_msgq *msgq, void *data)

if (msgq->used_msgs > 0U) {
/* take first available message from queue */
(void)memcpy(data, msgq->read_ptr, msgq->msg_size);
(void)memcpy((char *)data, msgq->read_ptr, msgq->msg_size);
result = 0;
} else {
/* don't wait for a message to become available */
Expand Down
8 changes: 4 additions & 4 deletions lib/os/cbprintf_packaged.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ int cbvprintf_package(void *packaged, size_t len, uint32_t flags,
return -ENOSPC;
}
if (Z_CBPRINTF_VA_STACK_LL_DBL_MEMCPY) {
memcpy(buf, &v, size);
memcpy(buf, (uint8_t *)&v, size);
} else if (format[-1] == 'L') {
*(long double *)buf = v.ld;
} else {
Expand Down Expand Up @@ -481,7 +481,7 @@ int cbvprintf_package(void *packaged, size_t len, uint32_t flags,

if (buf0 != NULL) {
if (Z_CBPRINTF_VA_STACK_LL_DBL_MEMCPY) {
memcpy(buf, &v, sizeof(long long));
memcpy(buf, (uint8_t *)&v, sizeof(long long));
} else {
*(long long *)buf = v;
}
Expand Down Expand Up @@ -561,7 +561,7 @@ int cbvprintf_package(void *packaged, size_t len, uint32_t flags,
*buf = str_ptr_pos[i];
++buf;
/* copy the string with its terminating '\0' */
memcpy(buf, s, size);
memcpy(buf, (uint8_t *)s, size);
buf += size;
}

Expand Down Expand Up @@ -686,7 +686,7 @@ int cbprintf_fsc_package(void *in_packaged,
}
*out = s_idx;
++out;
memcpy(out, *ps, slen);
memcpy(out, (uint8_t *)*ps, slen);
out += slen;
}
}
Expand Down

0 comments on commit 7229c12

Please sign in to comment.