From 2115964929d5f35434e54d75ef4ff611c37cadcb Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Fri, 23 Apr 2021 10:52:53 +0200 Subject: [PATCH] logging: Fix casting related C++ warnings Fixed C++ warnings coming from implicit casting. Signed-off-by: Krzysztof Chruscinski --- include/logging/log_msg2.h | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/include/logging/log_msg2.h b/include/logging/log_msg2.h index af95185a4a9d46..23fc45538041b7 100644 --- a/include/logging/log_msg2.h +++ b/include/logging/log_msg2.h @@ -186,13 +186,12 @@ enum z_log_msg2_mode { /* Messages are aligned to alignment required by cbprintf package. */ #define Z_LOG_MSG2_ALIGNMENT CBPRINTF_PACKAGE_ALIGNMENT - #if CONFIG_LOG2_USE_VLA #define Z_LOG_MSG2_ON_STACK_ALLOC(ptr, len) \ long long _ll_buf[ceiling_fraction(len, sizeof(long long))]; \ long double _ld_buf[ceiling_fraction(len, sizeof(long double))]; \ ptr = (sizeof(long double) == Z_LOG_MSG2_ALIGNMENT) ? \ - (void *)_ld_buf : (void *)_ll_buf; \ + (struct log_msg2 *)_ld_buf : (struct log_msg2 *)_ll_buf; \ if (IS_ENABLED(CONFIG_LOG_TEST_CLEAR_MESSAGE_SPACE)) { \ /* During test fill with 0's to simplify message comparison */ \ memset(ptr, 0, len); \ @@ -215,15 +214,17 @@ enum z_log_msg2_mode { long double _ld_buf128[128 / sizeof(long double)]; \ long double _ld_buf256[256 / sizeof(long double)]; \ if (sizeof(long double) == Z_LOG_MSG2_ALIGNMENT) { \ - ptr = (len > 128) ? (void *)_ld_buf256 : \ - ((len > 64) ? (void *)_ld_buf128 : \ - ((len > 48) ? (void *)_ld_buf64 : \ - ((len > 32) ? (void *)_ld_buf48 : (void *)_ld_buf32)));\ + ptr = (len > 128) ? (struct log_msg2 *)_ld_buf256 : \ + ((len > 64) ? (struct log_msg2 *)_ld_buf128 : \ + ((len > 48) ? (struct log_msg2 *)_ld_buf64 : \ + ((len > 32) ? (struct log_msg2 *)_ld_buf48 : \ + (struct log_msg2 *)_ld_buf32)));\ } else { \ - ptr = (len > 128) ? (void *)_ll_buf256 : \ - ((len > 64) ? (void *)_ll_buf128 : \ - ((len > 48) ? (void *)_ll_buf64 : \ - ((len > 32) ? (void *)_ll_buf48 : (void *)_ll_buf32)));\ + ptr = (len > 128) ? (struct log_msg2 *)_ll_buf256 : \ + ((len > 64) ? (struct log_msg2 *)_ll_buf128 : \ + ((len > 48) ? (struct log_msg2 *)_ll_buf64 : \ + ((len > 32) ? (struct log_msg2 *)_ll_buf48 : \ + (struct log_msg2 *)_ll_buf32)));\ } \ if (IS_ENABLED(CONFIG_LOG_TEST_CLEAR_MESSAGE_SPACE)) { \ /* During test fill with 0's to simplify message comparison */ \ @@ -254,7 +255,7 @@ enum z_log_msg2_mode { } \ struct log_msg2_desc _desc = \ Z_LOG_MSG_DESC_INITIALIZER(_domain_id, _level, \ - _plen, _dlen); \ + (uint32_t)_plen, _dlen); \ z_log_msg2_finalize(_msg, _source, _desc, _data); \ } while (0) @@ -276,7 +277,7 @@ do { \ } \ struct log_msg2_desc _desc = \ Z_LOG_MSG_DESC_INITIALIZER(_domain_id, _level, \ - _plen, _dlen); \ + (uint32_t)_plen, _dlen); \ LOG_MSG2_DBG("creating message on stack: package len: %d, data len: %d\n", \ _plen, (int)(_dlen)); \ z_log_msg2_static_create((void *)_source, _desc, _msg->data, _data); \ @@ -289,7 +290,7 @@ do { \ size_t _msg_wlen = Z_LOG_MSG2_ALIGNED_WLEN(_plen, 0); \ struct log_msg2 *_msg = z_log_msg2_alloc(_msg_wlen); \ struct log_msg2_desc _desc = \ - Z_LOG_MSG_DESC_INITIALIZER(_domain_id, _level, _plen, 0); \ + Z_LOG_MSG_DESC_INITIALIZER(_domain_id, _level, (uint32_t)_plen, 0); \ LOG_MSG2_DBG("creating message zero copy: package len: %d, msg: %p\n", \ _plen, _msg); \ if (_msg) { \ @@ -437,11 +438,9 @@ do { \ #define Z_LOG_MSG2_CREATE(_try_0cpy, _mode, _domain_id, _source,\ _level, _data, _dlen, ...) \ -do { \ Z_LOG_MSG2_CREATE2(_try_0cpy, _mode, UTIL_CAT(Z_LOG_FUNC_PREFIX_, _level), \ _domain_id, _source, _level, _data, _dlen, \ - Z_LOG_STR(_level, __VA_ARGS__));\ -} while (0) + Z_LOG_STR(_level, __VA_ARGS__)) #define Z_TRACING_LOG_HDR_INIT(name, id) \ struct log_msg2_trace name = { \