summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Michalec <tm@semihalf.com>2021-12-01 14:25:58 +0100
committerCommit Bot <commit-bot@chromium.org>2021-12-02 17:00:37 +0000
commit29eca8bc04f50fe287769fa9b3e6ca1edc1b8feb (patch)
tree12d1d7b6d443e11ef47c6661463afce4aa0f1c0b
parent44a7c5af0093d599de6d2e06ef7c95b8a6efbe8d (diff)
downloadchrome-ec-29eca8bc04f50fe287769fa9b3e6ca1edc1b8feb.tar.gz
zephyr: Fix console buffer characters collecting
Console buffer should write chars at location of tail index and then increment index, not otherwise. It fixes reading buffer before first buffer overwrite (start condition with empty buffer is head_idx == 0 and tail_idx == 0, first char was written to index 1 not 0, so uninitialized char at index 0 (head_idx) could be read). It fixes not reading last char by EC_CMD_CONSOLE_READ host command. Empty buffer condition is head_idx == tail_idx. It was impossible to read last char if it was pointed by tail_idx. Because of that tail_idx should point past last written char. BUG=none BRANCH=none TEST=make configure --test zephyr/test/drivers TEST="ectool console" on volteer; logs usually ends with newline; after this change extra newline should be printed (last char in buffer) Signed-off-by: Tomasz Michalec <tm@semihalf.com> Change-Id: I056b95533580db3724897d04d8863a78e73c2b2f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3310857 Commit-Queue: Tomasz Michalec <tmichalec@google.com> Tested-by: Tomasz Michalec <tmichalec@google.com> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/shim/src/console_buffer.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/zephyr/shim/src/console_buffer.c b/zephyr/shim/src/console_buffer.c
index 191306c80e..b768bb279f 100644
--- a/zephyr/shim/src/console_buffer.c
+++ b/zephyr/shim/src/console_buffer.c
@@ -52,7 +52,7 @@ void console_buf_notify_chars(const char *s, size_t len)
current_snapshot_idx =
next_idx(current_snapshot_idx);
- console_buf[new_tail] = *s++;
+ console_buf[tail_idx] = *s++;
tail_idx = new_tail;
}
k_mutex_unlock(&console_write_lock);