X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=vmsplice-touser.c;fp=vmsplice-touser.c;h=3f6977fba66c0a04b83bb61fcc6403ff8f66d714;hb=c972eeebd96e46a54adf52c2061bb42c685dcad5;hp=75e789dd4d9ccafda70f9fae3f4ccb06153a980f;hpb=4ffe329a592b295778ce1a8cd290001fe711af3c;p=splice.git diff --git a/vmsplice-touser.c b/vmsplice-touser.c index 75e789d..3f6977f 100644 --- a/vmsplice-touser.c +++ b/vmsplice-touser.c @@ -28,16 +28,15 @@ static int do_vmsplice_unmap(int fd, unsigned char *buf, int len) return svmsplice(fd, &iov, 1, SPLICE_F_UNMAP); } -static int do_vmsplice(int fd, unsigned char **buf, int len) +static int do_vmsplice(int fd, void **buf, int len) { struct pollfd pfd = { .fd = fd, .events = POLLIN, }; - struct iovec iov; + struct iovec iov = { + .iov_base = *buf, + .iov_len = len, + }; int written; - int ret; - - iov.iov_base = *buf; - iov.iov_len = len; - ret = 0; + int ret = 0; while (len) { /* @@ -49,7 +48,9 @@ static int do_vmsplice(int fd, unsigned char **buf, int len) return error("poll"); written = svmsplice(fd, &iov, 1, splice_flags); - *buf = iov.iov_base; + + if (!ret) + *buf = iov.iov_base; if (written < 0) return error("vmsplice"); @@ -121,7 +122,7 @@ static void asciidump(unsigned char *buf, int len) int main(int argc, char *argv[]) { - unsigned char *buf; + void *buf; int ret; if (parse_options(argc, argv) < 0)