This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit a250fa8bfe27d4012dccc5c675fe690142803442 Author: huojianchao <[email protected]> AuthorDate: Thu Nov 12 16:52:36 2026 +0800 drivers/syslog: keep the CR of an empty line With CONFIG_SYSLOG_CRLF, syslog_write_foreach() writes the text in front of each '\n' and then "\r\n". For an empty line, or a '\n' at the start of the buffer, the text in front is empty and the write returns 0. Since "drivers/syslog: fix syslog write busy loop when a channel is full" a return of 0 means a full channel, so such a '\n' was left to the tail write and went out without its CR. Do not write the empty text in front of a '\n'. Signed-off-by: huojianchao <[email protected]> --- drivers/syslog/syslog_write.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/syslog/syslog_write.c b/drivers/syslog/syslog_write.c index e45376158b9..ecdea71295b 100644 --- a/drivers/syslog/syslog_write.c +++ b/drivers/syslog/syslog_write.c @@ -187,10 +187,14 @@ ssize_t syslog_write_foreach(int priority, FAR const char *buffer, continue; } - ret = write(channel, buffer + nwritten, head - nwritten); - if (ret <= 0) + if (head > nwritten) { - continue; + ret = write(channel, buffer + nwritten, + head - nwritten); + if (ret <= 0) + { + continue; + } } /* On failure leave the '\n' to the tail write: rewinding
