From a838d3b98fba2cc0a5d9253339424898001848cc Mon Sep 17 00:00:00 2001 From: Daniele Palmas Date: Fri, 31 Jul 2026 15:33:56 +0200 Subject: [PATCH] libqcdm,tests: fix qcdm_send method for wwan The qcdm wwan device does not cope well with writing single bytes, while it does not have any issue if longer chunks are written. Fix qcdm_send accordingly, since it should not hurt the previously supported devices. Signed-off-by: Daniele Palmas --- libqcdm/tests/ipv6pref.c | 8 ++++---- libqcdm/tests/modepref.c | 8 ++++---- libqcdm/tests/reset.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libqcdm/tests/ipv6pref.c b/libqcdm/tests/ipv6pref.c index f5bd71c4..bd0f08f8 100644 --- a/libqcdm/tests/ipv6pref.c +++ b/libqcdm/tests/ipv6pref.c @@ -95,16 +95,16 @@ qcdm_send (int fd, char *buf, size_t len) while (i < len) { errno = 0; - status = write (fd, &buf[i], 1); - if (status < 0) { - if (errno == EAGAIN) { + status = write (fd, &buf[i], len - i); + if (status <= 0) { + if (errno == EAGAIN || status == 0) { eagain_count--; if (eagain_count <= 0) return FALSE; } else assert (errno == 0); } else - i++; + i += status; usleep (1000); } diff --git a/libqcdm/tests/modepref.c b/libqcdm/tests/modepref.c index f8855161..25d3fa11 100644 --- a/libqcdm/tests/modepref.c +++ b/libqcdm/tests/modepref.c @@ -95,16 +95,16 @@ qcdm_send (int fd, char *buf, size_t len) while (i < len) { errno = 0; - status = write (fd, &buf[i], 1); - if (status < 0) { - if (errno == EAGAIN) { + status = write (fd, &buf[i], len - i); + if (status <= 0) { + if (errno == EAGAIN || status == 0) { eagain_count--; if (eagain_count <= 0) return FALSE; } else assert (errno == 0); } else - i++; + i += status; usleep (1000); } diff --git a/libqcdm/tests/reset.c b/libqcdm/tests/reset.c index 079ee386..e4508e43 100644 --- a/libqcdm/tests/reset.c +++ b/libqcdm/tests/reset.c @@ -96,16 +96,16 @@ qcdm_send (int fd, char *buf, size_t len) while (i < len) { errno = 0; - status = write (fd, &buf[i], 1); - if (status < 0) { - if (errno == EAGAIN) { + status = write (fd, &buf[i], len - i); + if (status <= 0) { + if (errno == EAGAIN || status == 0) { eagain_count--; if (eagain_count <= 0) return FALSE; } else assert (errno == 0); } else - i++; + i += status; usleep (1000); }