Avoid pointer arithmetic with `void *`
authorMichael Forney <mforney@mforney.org>
Tue, 4 Jun 2019 19:33:17 +0000 (12:33 -0700)
committerNikolaus Rath <Nikolaus@rath.org>
Thu, 6 Jun 2019 12:31:41 +0000 (13:31 +0100)
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
lib/fuse_lowlevel.c
lib/fuse_opt.c

index 85309ac2884b211d99db9b4093e178930ad047e8..5ab9b874554465b8107677f523b24b5c31c6c3b6 100644 (file)
@@ -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)
index ec0daaf8ea0694b0bab50c332a654242668e7de9..c96e211045b7a3a999109025f5ed1c3ac2fcdf47 100644 (file)
@@ -2566,7 +2566,7 @@ void fuse_session_process_buf_int(struct fuse_session *se,
                mbuf = newmbuf;
 
                tmpbuf = FUSE_BUFVEC_INIT(buf->size - write_header_size);
-               tmpbuf.buf[0].mem = mbuf + write_header_size;
+               tmpbuf.buf[0].mem = (char *)mbuf + write_header_size;
 
                res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
                err = -res;
index 3d4a3ddfed5034e1bb98423b7b181882d22f2ebd..f6cae4f41d9feac8b305e7707ddae3f02c914eff 100644 (file)
@@ -232,7 +232,7 @@ static int process_opt(struct fuse_opt_context *ctx,
                if (call_proc(ctx, arg, opt->value, iso) == -1)
                        return -1;
        } else {
-               void *var = ctx->data + opt->offset;
+               void *var = (char *)ctx->data + opt->offset;
                if (sep && opt->templ[sep + 1]) {
                        const char *param = arg + sep;
                        if (opt->templ[sep] == '=')