logging: backend_rtt: Align to changes in RTT_LOCK/UNLOCK

RTT_LOCK/UNLOCK in certain configuration creates code block (curly
braces). In that case variables declared inside are local to that
block. Moved declaration of ret variable before the block. Updated
code to ensure that RTT_LOCK/UNLOCK are in the same code block.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2021-05-26 18:13:50 +02:00 committed by Carles Cufí
commit f98bc0c0bc

View file

@ -154,9 +154,11 @@ static int line_out_drop_mode(void)
}
}
int ret;
RTT_LOCK();
int ret = SEGGER_RTT_WriteSkipNoLock(CONFIG_LOG_BACKEND_RTT_BUFFER,
line_buf, line_pos - line_buf);
ret = SEGGER_RTT_WriteSkipNoLock(CONFIG_LOG_BACKEND_RTT_BUFFER,
line_buf, line_pos - line_buf);
RTT_UNLOCK();
if (ret == 0) {
@ -209,12 +211,12 @@ static int data_out_block_mode(uint8_t *data, size_t length, void *ctx)
do {
if (!is_sync_mode()) {
RTT_LOCK();
}
ret = SEGGER_RTT_WriteSkipNoLock(CONFIG_LOG_BACKEND_RTT_BUFFER,
data, length);
if (!is_sync_mode()) {
ret = SEGGER_RTT_WriteSkipNoLock(CONFIG_LOG_BACKEND_RTT_BUFFER,
data, length);
RTT_UNLOCK();
} else {
ret = SEGGER_RTT_WriteSkipNoLock(CONFIG_LOG_BACKEND_RTT_BUFFER,
data, length);
}
if (ret) {