From 63c11456d48b156b33b8b16cd47759c0d406f5b9 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Tue, 4 Jun 2019 12:33:17 -0700 Subject: Avoid pointer arithmetic with `void *` The pointer operand to the binary `+` operator must be to a complete object type. Since we are working with byte sizes, use `char *` instead. --- lib/buffer.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/buffer.c') diff --git a/lib/buffer.c b/lib/buffer.c index 85309ac..5ab9b87 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -48,10 +48,10 @@ static ssize_t fuse_buf_write(const struct fuse_buf *dst, size_t dst_off, while (len) { if (dst->flags & FUSE_BUF_FD_SEEK) { - res = pwrite(dst->fd, src->mem + src_off, len, + res = pwrite(dst->fd, (char *)src->mem + src_off, len, dst->pos + dst_off); } else { - res = write(dst->fd, src->mem + src_off, len); + res = write(dst->fd, (char *)src->mem + src_off, len); } if (res == -1) { if (!copied) @@ -82,10 +82,10 @@ static ssize_t fuse_buf_read(const struct fuse_buf *dst, size_t dst_off, while (len) { if (src->flags & FUSE_BUF_FD_SEEK) { - res = pread(src->fd, dst->mem + dst_off, len, + res = pread(src->fd, (char *)dst->mem + dst_off, len, src->pos + src_off); } else { - res = read(src->fd, dst->mem + dst_off, len); + res = read(src->fd, (char *)dst->mem + dst_off, len); } if (res == -1) { if (!copied) @@ -232,8 +232,8 @@ static ssize_t fuse_buf_copy_one(const struct fuse_buf *dst, size_t dst_off, int dst_is_fd = dst->flags & FUSE_BUF_IS_FD; if (!src_is_fd && !dst_is_fd) { - void *dstmem = dst->mem + dst_off; - void *srcmem = src->mem + src_off; + char *dstmem = (char *)dst->mem + dst_off; + char *srcmem = (char *)src->mem + src_off; if (dstmem != srcmem) { if (dstmem + len <= srcmem || srcmem + len <= dstmem) -- cgit v1.2.3