logger: fix PR codestyle issues

Fix some issues as complained by shippable.

Signed-off-by: Pavel Kral <pavel.kral@omsquare.com>
This commit is contained in:
Pavel Kral 2018-10-18 12:53:55 +02:00 committed by Carles Cufí
commit ced1592e54
3 changed files with 34 additions and 33 deletions

View file

@ -8,13 +8,13 @@ config HAS_SEGGER_RTT
bool
config USE_SEGGER_RTT
bool "Enable SEGGER RTT libraries."
depends on HAS_SEGGER_RTT
default n
help
Enable Segger J-Link RTT libraries for platforms that support it.
Selection of this option enables use of RTT for various subsytems.
Note that by enabling this option, RTT buffers consume more RAM.
bool "Enable SEGGER RTT libraries."
depends on HAS_SEGGER_RTT
default n
help
Enable Segger J-Link RTT libraries for platforms that support it.
Selection of this option enables use of RTT for various subsytems.
Note that by enabling this option, RTT buffers consume more RAM.
if USE_SEGGER_RTT

View file

@ -309,21 +309,21 @@ config LOG_BACKEND_RTT
if LOG_BACKEND_RTT
choice
prompt "Logger behaviour"
default LOG_BACKEND_RTT_MODE_BLOCK
prompt "Logger behaviour"
default LOG_BACKEND_RTT_MODE_BLOCK
config LOG_BACKEND_RTT_MODE_DROP
bool "Drop messages that do not fit in up-buffer."
help
If there is not enough space in up-buffer for a message, drop it.
Number of dropped messages will be logged.
Increase up-buffer size helps to reduce dropping of messages.
If there is not enough space in up-buffer for a message, drop it.
Number of dropped messages will be logged.
Increase up-buffer size helps to reduce dropping of messages.
config LOG_BACKEND_RTT_MODE_BLOCK
bool "Block until message is transferred to host."
help
Waits until there is enough space in the up-buffer for a message
and until the message is completely transferred to the host.
bool "Block until message is transferred to host."
help
Waits until there is enough space in the up-buffer for a message
and until the message is completely transferred to the host.
endchoice
@ -332,7 +332,7 @@ config LOG_BACKEND_RTT_MESSAGE_SIZE
range 32 256
default 128
help
This option defines maximum message size transferable to up-buffer.
This option defines maximum message size transferable to up-buffer.
config LOG_BACKEND_RTT_BUFFER
int "Buffer number used for logger output."

View file

@ -13,15 +13,15 @@
#if CONFIG_LOG_BACKEND_RTT_MODE_DROP
#define DROP_MESSAGE "\nmessages dropped: 99 \r"
#define DROP_MESSAGE_LEN (sizeof(DROP_MESSAGE) - 1)
static const char *drop_msg = DROP_MESSAGE;
static int drop_cnt = 0;
static int drop_warn = 0;
#define DROP_MSG "\nmessages dropped: 99 \r"
#define DROP_MSG_LEN (sizeof(DROP_MSG) - 1)
static const char *drop_msg = DROP_MSG;
static int drop_cnt;
static int drop_warn;
#else
#define DROP_MESSAGE_LEN 0
#define DROP_MSG_LEN 0
#endif /* CONFIG_LOG_BACKEND_RTT_MODE_DROP */
@ -38,7 +38,7 @@ static u8_t rtt_buf[CONFIG_LOG_BACKEND_RTT_BUFFER_SIZE];
#endif /* CONFIG_LOG_BACKEND_RTT_BUFFER > 0 */
static u8_t line_buf[CONFIG_LOG_BACKEND_RTT_MESSAGE_SIZE + DROP_MESSAGE_LEN];
static u8_t line_buf[CONFIG_LOG_BACKEND_RTT_MESSAGE_SIZE + DROP_MSG_LEN];
static u8_t *line_pos;
static u8_t char_buf;
static int panic_mode;
@ -96,23 +96,24 @@ static int log_backend_rtt_write(void)
*line_pos = '\r';
if (drop_cnt > 0 && !drop_warn) {
memmove(line_buf + DROP_MESSAGE_LEN, line_buf,
memmove(line_buf + DROP_MSG_LEN, line_buf,
line_pos - line_buf);
memcpy(line_buf, drop_msg, DROP_MESSAGE_LEN);
line_pos += DROP_MESSAGE_LEN;
memcpy(line_buf, drop_msg, DROP_MSG_LEN);
line_pos += DROP_MSG_LEN;
drop_warn = 1;
}
if (drop_warn) {
int cnt = min(drop_cnt, 99);
if (cnt < 10) {
line_buf[DROP_MESSAGE_LEN - 2] = ' ';
line_buf[DROP_MESSAGE_LEN - 3] = (u8_t) ('0' + cnt);
line_buf[DROP_MESSAGE_LEN - 4] = ' ';
line_buf[DROP_MSG_LEN - 2] = ' ';
line_buf[DROP_MSG_LEN - 3] = (u8_t) ('0' + cnt);
line_buf[DROP_MSG_LEN - 4] = ' ';
} else {
line_buf[DROP_MESSAGE_LEN - 2] = (u8_t) ('0' + cnt % 10);
line_buf[DROP_MESSAGE_LEN - 3] = (u8_t) ('0' + cnt / 10);
line_buf[DROP_MESSAGE_LEN - 4] = '>';
line_buf[DROP_MSG_LEN - 2] = (u8_t) ('0' + cnt % 10);
line_buf[DROP_MSG_LEN - 3] = (u8_t) ('0' + cnt / 10);
line_buf[DROP_MSG_LEN - 4] = '>';
}
}