vmsplice-touser: cleanup
authorJens Axboe <jens.axboe@oracle.com>
Wed, 13 Jun 2007 13:46:07 +0000 (15:46 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 13 Jun 2007 13:46:07 +0000 (15:46 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
vmsplice-touser.c

index 75e789dd4d9ccafda70f9fae3f4ccb06153a980f..3f6977fba66c0a04b83bb61fcc6403ff8f66d714 100644 (file)
@@ -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)