From 3fab7624eb4b31dd6caa33ad50adb18b51cc9a60 Mon Sep 17 00:00:00 2001 From: Andrej Butok Date: Tue, 24 Oct 2023 11:44:56 +0200 Subject: [PATCH] doc: pipes: Fix the pipe read example. Replaces sizeof(header) which is equal to the size of the pointer, by sizeof (*header), which is equal to the size of struct message_header. Signed-off-by: Andrej Butok --- doc/kernel/services/data_passing/pipes.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/kernel/services/data_passing/pipes.rst b/doc/kernel/services/data_passing/pipes.rst index 62c4f8f0223..bdeec48f011 100644 --- a/doc/kernel/services/data_passing/pipes.rst +++ b/doc/kernel/services/data_passing/pipes.rst @@ -150,12 +150,12 @@ process data items generated by one or more producing threads. while (1) { rc = k_pipe_get(&my_pipe, buffer, sizeof(buffer), &bytes_read, - sizeof(header), K_MSEC(100)); + sizeof(*header), K_MSEC(100)); - if ((rc < 0) || (bytes_read < sizeof (header))) { + if ((rc < 0) || (bytes_read < sizeof (*header))) { /* Incomplete message header received */ ... - } else if (header->num_data_bytes + sizeof(header) > bytes_read) { + } else if (header->num_data_bytes + sizeof(*header) > bytes_read) { /* Only some data was received */ ... } else {