From 67edd6c417c6752f546e9053afd8e3704239d3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikolai=20G=C3=BCtschow?= Date: Wed, 13 Nov 2024 19:59:45 +0100 Subject: [PATCH] sys/usb_cdc_acm_stdio: only submit and flush for non-empty buffer --- sys/usb/usbus/cdc/acm/cdc_acm_stdio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c b/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c index 3b8359434afe..fe171e74202b 100644 --- a/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c +++ b/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c @@ -37,13 +37,13 @@ static uint8_t _cdc_tx_buf_mem[CONFIG_USBUS_CDC_ACM_STDIO_BUF_SIZE]; static ssize_t _write(const void* buffer, size_t len) { const char *start = buffer; - do { + while (len) { size_t n = usbus_cdc_acm_submit(&cdcacm, buffer, len); usbus_cdc_acm_flush(&cdcacm); /* Use tsrb and flush */ buffer = (char *)buffer + n; len -= n; - } while (len); + } return (char *)buffer - start; }