From: Nikolaus Rath Date: Thu, 12 Jan 2017 23:17:54 +0000 (-0800) Subject: Replaced evil pointer magic with offsetof() X-Git-Tag: fuse-3.0.1~37 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=3006686b536942f6f96675e3d12b793087e78e6a;p=qemu-gpiodev%2Flibfuse.git Replaced evil pointer magic with offsetof() This triggered undefined behaviour warnings from UBSan. --- diff --git a/example/cuse.c b/example/cuse.c index 15e2d37..cfbf753 100644 --- a/example/cuse.c +++ b/example/cuse.c @@ -141,11 +141,11 @@ static void fioc_do_rw(fuse_req_t req, void *addr, const void *in_buf, /* prepare size outputs */ out_iov[0].iov_base = - addr + (unsigned long)&(((struct fioc_rw_arg *)0)->prev_size); + addr + offsetof(struct fioc_rw_arg, prev_size); out_iov[0].iov_len = sizeof(arg->prev_size); out_iov[1].iov_base = - addr + (unsigned long)&(((struct fioc_rw_arg *)0)->new_size); + addr + offsetof(struct fioc_rw_arg, new_size); out_iov[1].iov_len = sizeof(arg->new_size); /* prepare client buf */