diff options
author | Wei Liu <wei.liu2@citrix.com> | 2015-12-02 14:22:04 +0000 |
---|---|---|
committer | Timothy Pearson <tpearson@raptorengineering.com> | 2019-11-29 19:28:22 -0600 |
commit | 01522d2e5eaad5e275efe6fb679c05aaca3ecbbe (patch) | |
tree | b90eeac402089abfc4395fb381ab31e9e667f904 /fsdev/9p-iov-marshal.c | |
parent | 6fe7ca1998908e09552a6b4ab50536d7a7a6eaf4 (diff) | |
download | hqemu-01522d2e5eaad5e275efe6fb679c05aaca3ecbbe.zip hqemu-01522d2e5eaad5e275efe6fb679c05aaca3ecbbe.tar.gz |
9pfs: make pdu_{,un}marshal proper functions
Factor out v9fs_iov_v{,un}marshal. Implement pdu_{,un}marshal with those
functions.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Diffstat (limited to 'fsdev/9p-iov-marshal.c')
-rw-r--r-- | fsdev/9p-iov-marshal.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/fsdev/9p-iov-marshal.c b/fsdev/9p-iov-marshal.c index 4883b60..08d783c 100644 --- a/fsdev/9p-iov-marshal.c +++ b/fsdev/9p-iov-marshal.c @@ -76,15 +76,13 @@ ssize_t v9fs_pack(struct iovec *in_sg, int in_num, size_t offset, return v9fs_packunpack((void *)src, in_sg, in_num, offset, size, 1); } -ssize_t v9fs_iov_unmarshal(struct iovec *out_sg, int out_num, size_t offset, - int bswap, const char *fmt, ...) +ssize_t v9fs_iov_vunmarshal(struct iovec *out_sg, int out_num, size_t offset, + int bswap, const char *fmt, va_list ap) { int i; - va_list ap; ssize_t copied = 0; size_t old_offset = offset; - va_start(ap, fmt); for (i = 0; fmt[i]; i++) { switch (fmt[i]) { case 'b': { @@ -180,25 +178,34 @@ ssize_t v9fs_iov_unmarshal(struct iovec *out_sg, int out_num, size_t offset, break; } if (copied < 0) { - va_end(ap); return copied; } offset += copied; } - va_end(ap); return offset - old_offset; } -ssize_t v9fs_iov_marshal(struct iovec *in_sg, int in_num, size_t offset, - int bswap, const char *fmt, ...) +ssize_t v9fs_iov_unmarshal(struct iovec *out_sg, int out_num, size_t offset, + int bswap, const char *fmt, ...) { - int i; + ssize_t ret; va_list ap; + + va_start(ap, fmt); + ret = v9fs_iov_vunmarshal(out_sg, out_num, offset, bswap, fmt, ap); + va_end(ap); + + return ret; +} + +ssize_t v9fs_iov_vmarshal(struct iovec *in_sg, int in_num, size_t offset, + int bswap, const char *fmt, va_list ap) +{ + int i; ssize_t copied = 0; size_t old_offset = offset; - va_start(ap, fmt); for (i = 0; fmt[i]; i++) { switch (fmt[i]) { case 'b': { @@ -290,12 +297,23 @@ ssize_t v9fs_iov_marshal(struct iovec *in_sg, int in_num, size_t offset, break; } if (copied < 0) { - va_end(ap); return copied; } offset += copied; } - va_end(ap); return offset - old_offset; } + +ssize_t v9fs_iov_marshal(struct iovec *in_sg, int in_num, size_t offset, + int bswap, const char *fmt, ...) +{ + ssize_t ret; + va_list ap; + + va_start(ap, fmt); + ret = v9fs_iov_vmarshal(in_sg, in_num, offset, bswap, fmt, ap); + va_end(ap); + + return ret; +} |