From 0677cd5cbbe222483b8616dd62c39897bf48c911 Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Sun, 16 Jun 2024 12:53:42 +0200 Subject: [PATCH] Empty log buffer when full --- src/sys/log.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sys/log.rs b/src/sys/log.rs index 6ac42890c..7bd4c70af 100644 --- a/src/sys/log.rs +++ b/src/sys/log.rs @@ -32,14 +32,15 @@ impl LogBuffer { impl core::fmt::Write for LogBuffer { fn write_str(&mut self, s: &str) -> core::fmt::Result { + if self.len + s.len() > LOG_SIZE { + self.len = 0; + self.buf.fill(0); + } + let bytes = s.as_bytes(); let i = self.len; let n = i + bytes.len(); - if n > LOG_SIZE { - return Err(core::fmt::Error); - } - self.buf[i..n].copy_from_slice(bytes); self.len += bytes.len();