mirror of
https://github.com/libfuse/libfuse.git
synced 2024-11-23 12:14:15 +08:00
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.
This commit is contained in:
parent
a6024d4bf8
commit
63c11456d4
12
lib/buffer.c
12
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)
|
||||
|
@ -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;
|
||||
|
@ -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] == '=')
|
||||
|
Loading…
Reference in New Issue
Block a user