From a081fb693d1cdeb452e4fa84e800ea8dbfb7ddeb Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Sat, 23 Nov 2019 08:09:14 +0100 Subject: [PATCH] tests/pipe: cleanup application The string formatter initially used doesn't seem to be supported by the AVR toolchain. Correctly closing the buffer with a null byte and using plain %s formatter works in all cases --- tests/pipe/main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/pipe/main.c b/tests/pipe/main.c index e7e05a8c23..7c64bf0371 100644 --- a/tests/pipe/main.c +++ b/tests/pipe/main.c @@ -47,11 +47,12 @@ static void *run_middle(void *arg) unsigned read_total = 0; while (read_total < BYTES_TOTAL) { - char buf[4]; - unsigned read = pipe_read(&pipes[0], buf, sizeof (buf)); + char buf[5]; + unsigned read = pipe_read(&pipes[0], buf, sizeof(buf) - 1); + buf[read] = 0; unsigned read_start = read_total; read_total += read; - printf("Middle read: <%.*s> [%u:%u]\n", read, buf, + printf("Middle read: <%s> [%u:%u]\n", buf, read_start, read_total); unsigned written_total = 0; @@ -72,11 +73,12 @@ static void *run_end(void *arg) unsigned read_total = 0; while (read_total < BYTES_TOTAL) { - char buf[3]; - int read = pipe_read(&pipes[1], buf, sizeof (buf)); + char buf[4]; + int read = pipe_read(&pipes[1], buf, sizeof(buf) - 1); + buf[read] = 0; unsigned read_start = read_total; read_total += read; - printf("End read: <%.*s> [%u:%u]\n", read, buf, + printf("End read: <%s> [%u:%u]\n", buf, read_start, read_total); }