logging: fix LOG_HEXDUMP_* in C++.
Previously, there were two issues when attempting to use LOG_HEXDUMP_* from C++: First, gcc and clang in C mode both allow implicit pointer conversion by default, but require -fpermissive, which no one should ever use, in C++ mode. Furthermore, -Wpointer-sign, the warning emitted in C for convertion between pointers to types of different signedness (e.g. char* vs u8_t*) is explicitly disabled in Zephyr. Switch the various hexdump functions to void*, which is guaranteed to work in both languages. Second, the soon-to-be-standardized C++20 version of designated initializers requires that the designators appear in the same order as they are declared in the type being initialized. Signed-off-by: Josh Gao <josh@jmgao.dev>
This commit is contained in:
parent
66bdb76e7c
commit
9f2916b943
3 changed files with 22 additions and 21 deletions
|
@ -223,7 +223,7 @@ extern "C" {
|
|||
/******************************************************************************/
|
||||
/****************** Defiinitions used by minimal logging **********************/
|
||||
/******************************************************************************/
|
||||
void log_minimal_hexdump_print(int level, const char *data, size_t size);
|
||||
void log_minimal_hexdump_print(int level, const void *data, size_t size);
|
||||
|
||||
#define Z_LOG_TO_PRINTK(_level, fmt, ...) do { \
|
||||
printk("%c: " fmt "\n", z_log_minimal_level_to_char(_level), \
|
||||
|
@ -314,8 +314,8 @@ static inline char z_log_minimal_level_to_char(int level)
|
|||
(_level <= LOG_RUNTIME_FILTER(_filter))) { \
|
||||
struct log_msg_ids src_level = { \
|
||||
.level = _level, \
|
||||
.domain_id = CONFIG_LOG_DOMAIN_ID, \
|
||||
.source_id = _id, \
|
||||
.domain_id = CONFIG_LOG_DOMAIN_ID \
|
||||
}; \
|
||||
\
|
||||
if (is_user_context) { \
|
||||
|
@ -548,9 +548,7 @@ void log_n(const char *str,
|
|||
* @param length Data length.
|
||||
* @param src_level Log identification.
|
||||
*/
|
||||
void log_hexdump(const char *str,
|
||||
const u8_t *data,
|
||||
u32_t length,
|
||||
void log_hexdump(const char *str, const void *data, u32_t length,
|
||||
struct log_msg_ids src_level);
|
||||
|
||||
/** @brief Process log message synchronously.
|
||||
|
@ -569,7 +567,7 @@ void log_string_sync(struct log_msg_ids src_level, const char *fmt, ...);
|
|||
* @param len Data length.
|
||||
*/
|
||||
void log_hexdump_sync(struct log_msg_ids src_level, const char *metadata,
|
||||
const u8_t *data, u32_t len);
|
||||
const void *data, u32_t len);
|
||||
|
||||
/**
|
||||
* @brief Writes a generic log message to the log.
|
||||
|
@ -647,7 +645,7 @@ __syscall void z_log_string_from_user(u32_t src_level_val, const char *str);
|
|||
* @param len Data length.
|
||||
*/
|
||||
void log_hexdump_from_user(struct log_msg_ids src_level, const char *metadata,
|
||||
const u8_t *data, u32_t len);
|
||||
const void *data, u32_t len);
|
||||
|
||||
/* Internal function used by log_hexdump_from_user(). */
|
||||
__syscall void z_log_hexdump_from_user(u32_t src_level_val,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue