From 8aa2c3f3d181e698010aa42c0020b71e0e30b953 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Thu, 28 Oct 2021 22:10:08 -0600 Subject: [PATCH] sys: Fix warning for stripped const qualifier This causes an issue when compiling with `-Werror=cast-qual` Signed-off-by: Yuval Peress --- include/logging/log_core.h | 2 +- include/logging/log_msg2.h | 6 +++--- include/sys/util.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/logging/log_core.h b/include/logging/log_core.h index 89a9838d6cf..d3a6a32ad2e 100644 --- a/include/logging/log_core.h +++ b/include/logging/log_core.h @@ -549,7 +549,7 @@ enum log_strdup_action { static inline uint32_t log_const_source_id( const struct log_source_const_data *data) { - return ((uint8_t *)data - (uint8_t *)__log_const_start)/ + return ((const uint8_t *)data - (uint8_t *)__log_const_start)/ sizeof(struct log_source_const_data); } diff --git a/include/logging/log_msg2.h b/include/logging/log_msg2.h index 8d9acce894e..08f1177ae71 100644 --- a/include/logging/log_msg2.h +++ b/include/logging/log_msg2.h @@ -496,7 +496,7 @@ static inline void z_log_msg2_runtime_create(uint8_t domain_id, va_end(ap); } -static inline bool z_log_item_is_msg(union log_msg2_generic *msg) +static inline bool z_log_item_is_msg(const union log_msg2_generic *msg) { return msg->generic.type == Z_LOG_MSG2_LOG; } @@ -520,10 +520,10 @@ static inline uint32_t log_msg2_get_total_wlen(const struct log_msg2_desc desc) */ static inline uint32_t log_msg2_generic_get_wlen(const union mpsc_pbuf_generic *item) { - union log_msg2_generic *generic_msg = (union log_msg2_generic *)item; + const union log_msg2_generic *generic_msg = (const union log_msg2_generic *)item; if (z_log_item_is_msg(generic_msg)) { - struct log_msg2 *msg = (struct log_msg2 *)generic_msg; + const struct log_msg2 *msg = (const struct log_msg2 *)generic_msg; return log_msg2_get_total_wlen(msg->hdr.desc); } diff --git a/include/sys/util.h b/include/sys/util.h index 742253fbc23..3ff39328b2d 100644 --- a/include/sys/util.h +++ b/include/sys/util.h @@ -253,7 +253,7 @@ static inline void bytecpy(void *dst, const void *src, size_t size) size_t i; for (i = 0; i < size; ++i) { - ((uint8_t *)dst)[i] = ((uint8_t *)src)[i]; + ((uint8_t *)dst)[i] = ((const uint8_t *)src)[i]; } }