From 352dc1abca118be510c08097a6629f804761997c Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Sun, 7 May 2023 11:49:02 +0200 Subject: [PATCH] circ_buf: fix -Wpointer-arith MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pointer arithmetic should not be done on void pointers. circ_buf.c: In function ‘circ_read’: circ_buf.c:104:25: warning: pointer of type ‘void *’ used in subtraction [-Wpointer-arith] 104 | return (void*)p - buf; | ^ Signed-off-by: Krzysztof Kozlowski --- circ_buf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/circ_buf.c b/circ_buf.c index e0d7dac..895ad85 100644 --- a/circ_buf.c +++ b/circ_buf.c @@ -85,7 +85,7 @@ size_t circ_peak(struct circ_buf *circ, void *buf, size_t len) tail = (tail + 1) & (CIRC_BUF_SIZE - 1); } - return (void*)p - buf; + return p - (char *)buf; } size_t circ_read(struct circ_buf *circ, void *buf, size_t len) @@ -101,5 +101,5 @@ size_t circ_read(struct circ_buf *circ, void *buf, size_t len) circ->tail = (circ->tail + 1) & (CIRC_BUF_SIZE - 1); } - return (void*)p - buf; + return p - (char *)buf; }