mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] docs/core-api: Fix circular buffer examples
@ 2025-07-20 16:02 carlos.bilbao
  2025-07-21  2:47 ` Akira Yokosawa
  0 siblings, 1 reply; 5+ messages in thread
From: carlos.bilbao @ 2025-07-20 16:02 UTC (permalink / raw)
  To: corbet, linux-doc, linux-kernel; +Cc: bilbao, Carlos Bilbao

From: Carlos Bilbao <carlos.bilbao@kernel.org>

Fix circular buffer usage in producer/consumer examples in
circular-buffers.rst. They incorrectly access items using buffer[head] and
buffer[tail], as if buffer was a flat array; but the examples also use
buffer->head and buffer->tail, so it's a struct. Use buffer->vals[head] and
buffer->vals[tail] instead to match the intended layout.

Signed-off-by: Carlos Bilbao <carlos.bilbao@kernel.org>
---
 Documentation/core-api/circular-buffers.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/core-api/circular-buffers.rst b/Documentation/core-api/circular-buffers.rst
index 50966f66e398..b697915a2bd0 100644
--- a/Documentation/core-api/circular-buffers.rst
+++ b/Documentation/core-api/circular-buffers.rst
@@ -161,7 +161,7 @@ The producer will look something like this::
 
 	if (CIRC_SPACE(head, tail, buffer->size) >= 1) {
 		/* insert one item into the buffer */
-		struct item *item = buffer[head];
+		struct item *item = buffer->vals[head];
 
 		produce_item(item);
 
@@ -203,7 +203,7 @@ The consumer will look something like this::
 	if (CIRC_CNT(head, tail, buffer->size) >= 1) {
 
 		/* extract one item from the buffer */
-		struct item *item = buffer[tail];
+		struct item *item = buffer->vals[tail];
 
 		consume_item(item);
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-08-06 17:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-20 16:02 [PATCH] docs/core-api: Fix circular buffer examples carlos.bilbao
2025-07-21  2:47 ` Akira Yokosawa
2025-07-23 20:47   ` Paul E. McKenney
2025-08-04 22:05     ` Carlos Bilbao
2025-08-06 17:19       ` Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®