[CRIU] [PATCH] syscall: fix arguments for preadv()

Dmitry Safonov 0x7f454c46 at gmail.com
Fri Dec 15 13:39:47 MSK 2017


2017-12-15 2:30 GMT+00:00 Andrei Vagin <avagin at openvz.org>:
> It has two arguments "pos_l and "pos_h" instead of one "off". It is used
> to handle 64-bit offsets on 32-bit kernels.
>
> SYSCALL_DEFINE5(preadv, unsigned long, fd, const struct iovec __user *, vec,
>                 unsigned long, vlen, unsigned long, pos_l, unsigned long, pos_h)
>
> https://github.com/checkpoint-restore/criu/issues/424
> Signed-off-by: Andrei Vagin <avagin at openvz.org>
> ---
[..]
> @@ -53,4 +55,22 @@ typedef int kernel_timer_t;
>
>  #include <compel/plugins/std/asm/syscall-types.h>
>
> +
> +extern long sys_preadv_raw(int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h);
> +
> +#ifndef BITS_PER_LONG
> +# error "BITS_PER_LONG isn't defined"
> +#endif
> +
> +#if BITS_PER_LONG == 64
> +#define LO_HI_LONG(val) (val), 0
> +# else
> +#define LO_HI_LONG(val) (long) (val), (((uint64_t) (val)) >> 32)
> +#endif
> +
> +static inline long sys_preadv(int fd, struct iovec *iov, unsigned long nr, off_t off)
> +{
> +       return sys_preadv_raw(fd, iov, nr, LO_HI_LONG(off));
> +}
> +

Wouldn't it a bit more readable just doing it explicitly:
static inline long sys_preadv(int fd, struct iovec *iov, unsigned long
nr, off_t off)
{
#if BITS_PER_LONG == 64
       return sys_preadv_raw(fd, iov, nr, off, 0);
# else
       return sys_preadv_raw(fd, iov, nr, (long)off, ((uint64_t)off) >> 32);
#endif
}

Well, anyway, it's just my preference,
Reviewed-by: Dmitry Safonov <0x7f454c46 at gmail.com>

-- 
             Dima


More information about the CRIU mailing list