Skip to content

Commit

Permalink
logging: backend_rtt: Align to changes in RTT_LOCK/UNLOCK
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nordic-krch authored and carlescufi committed May 27, 2021
1 parent 9b69036 commit f98bc0c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions subsys/logging/log_backend_rtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f98bc0c

Please sign in to comment.