logging: avoid identifier collisions
MISRA-C Rule 5.3 states that identifiers in inner scope should not hide identifiers in outer scope. The log output instances all named "log_output" in backends collide with the "log_output" parameter of various functions. This renames the variables in the backends to make them more descriptive. Same goes for the buffers for some of these instances as they are all named "buf", and "hostname" being used in the network backend, so they are renamed. There are a few places where variables are overriden within an inner scope (e.g. inside loop and if block) so they are also renamed. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
d3d2730166
commit
3c2d0f37a3
10 changed files with 65 additions and 59 deletions
|
@ -225,8 +225,9 @@ static int data_out_block_mode(uint8_t *data, size_t length, void *ctx)
|
|||
return ((ret == 0) && host_present) ? 0 : length;
|
||||
}
|
||||
|
||||
LOG_OUTPUT_DEFINE(log_output, IS_ENABLED(CONFIG_LOG_BACKEND_RTT_MODE_BLOCK) ?
|
||||
data_out_block_mode : data_out_drop_mode,
|
||||
LOG_OUTPUT_DEFINE(log_output_rtt,
|
||||
IS_ENABLED(CONFIG_LOG_BACKEND_RTT_MODE_BLOCK) ?
|
||||
data_out_block_mode : data_out_drop_mode,
|
||||
char_buf, sizeof(char_buf));
|
||||
|
||||
static void put(const struct log_backend *const backend,
|
||||
|
@ -235,7 +236,7 @@ static void put(const struct log_backend *const backend,
|
|||
uint32_t flag = IS_ENABLED(CONFIG_LOG_BACKEND_RTT_SYST_ENABLE) ?
|
||||
LOG_OUTPUT_FLAG_FORMAT_SYST : 0;
|
||||
|
||||
log_backend_std_put(&log_output, flag, msg);
|
||||
log_backend_std_put(&log_output_rtt, flag, msg);
|
||||
}
|
||||
|
||||
static void log_backend_rtt_cfg(void)
|
||||
|
@ -258,14 +259,14 @@ static void log_backend_rtt_init(void)
|
|||
static void panic(struct log_backend const *const backend)
|
||||
{
|
||||
panic_mode = true;
|
||||
log_backend_std_panic(&log_output);
|
||||
log_backend_std_panic(&log_output_rtt);
|
||||
}
|
||||
|
||||
static void dropped(const struct log_backend *const backend, uint32_t cnt)
|
||||
{
|
||||
ARG_UNUSED(backend);
|
||||
|
||||
log_backend_std_dropped(&log_output, cnt);
|
||||
log_backend_std_dropped(&log_output_rtt, cnt);
|
||||
}
|
||||
|
||||
static void sync_string(const struct log_backend *const backend,
|
||||
|
@ -275,7 +276,7 @@ static void sync_string(const struct log_backend *const backend,
|
|||
uint32_t flag = IS_ENABLED(CONFIG_LOG_BACKEND_RTT_SYST_ENABLE) ?
|
||||
LOG_OUTPUT_FLAG_FORMAT_SYST : 0;
|
||||
|
||||
log_backend_std_sync_string(&log_output, flag, src_level,
|
||||
log_backend_std_sync_string(&log_output_rtt, flag, src_level,
|
||||
timestamp, fmt, ap);
|
||||
}
|
||||
|
||||
|
@ -286,7 +287,7 @@ static void sync_hexdump(const struct log_backend *const backend,
|
|||
uint32_t flag = IS_ENABLED(CONFIG_LOG_BACKEND_RTT_SYST_ENABLE) ?
|
||||
LOG_OUTPUT_FLAG_FORMAT_SYST : 0;
|
||||
|
||||
log_backend_std_sync_hexdump(&log_output, flag, src_level,
|
||||
log_backend_std_sync_hexdump(&log_output_rtt, flag, src_level,
|
||||
timestamp, metadata, data, length);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue