You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/11/23 15:22:15 UTC
[incubator-nuttx] 02/02: mm/circbuf.c: Fix incorrect usage of void* arithmetics
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 39a567db206d621a1bf848c64ab75e56e45d96e4
Author: Ville Juven <vi...@unikie.com>
AuthorDate: Wed Nov 23 12:37:27 2022 +0200
mm/circbuf.c: Fix incorrect usage of void* arithmetics
---
mm/circbuf/circbuf.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/mm/circbuf/circbuf.c b/mm/circbuf/circbuf.c
index cd7ca61e65..4010b2b1d4 100644
--- a/mm/circbuf/circbuf.c
+++ b/mm/circbuf/circbuf.c
@@ -320,8 +320,8 @@ ssize_t circbuf_peekat(FAR struct circbuf_s *circ, size_t pos,
len = bytes;
}
- memcpy(dst, circ->base + off, len);
- memcpy(dst + len, circ->base, bytes - len);
+ memcpy(dst, (FAR char *)circ->base + off, len);
+ memcpy((FAR char *)dst + len, circ->base, bytes - len);
return bytes;
}
@@ -468,8 +468,8 @@ ssize_t circbuf_write(FAR struct circbuf_s *circ,
space = bytes;
}
- memcpy(circ->base + off, src, space);
- memcpy(circ->base, src + space, bytes - space);
+ memcpy((FAR char *)circ->base + off, src, space);
+ memcpy(circ->base, (FAR char *)src + space, bytes - space);
circ->head += bytes;
return bytes;
@@ -514,7 +514,7 @@ ssize_t circbuf_overwrite(FAR struct circbuf_s *circ,
if (bytes > circ->size)
{
- src += bytes - circ->size;
+ src = (FAR const void *)((FAR char *)src + bytes - circ->size);
bytes = circ->size;
}
@@ -531,8 +531,8 @@ ssize_t circbuf_overwrite(FAR struct circbuf_s *circ,
space = bytes;
}
- memcpy(circ->base + off, src, space);
- memcpy(circ->base, src + space, bytes - space);
+ memcpy((FAR char *)circ->base + off, src, space);
+ memcpy(circ->base, (FAR char *)src + space, bytes - space);
circ->head += bytes;
circ->tail += overwrite;