[CRIU] [PATCH 2/4] iov: Add iov_init() helper
Pavel Emelyanov
xemul at parallels.com
Thu Jun 19 04:38:02 PDT 2014
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
page-pipe.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/page-pipe.c b/page-pipe.c
index 19497a2..f03510d 100644
--- a/page-pipe.c
+++ b/page-pipe.c
@@ -19,6 +19,12 @@ static inline bool iov_grow(struct iovec *iov, unsigned long addr)
return false;
}
+static inline void iov_init(struct iovec *iov, unsigned long addr)
+{
+ iov->iov_base = (void *)addr;
+ iov->iov_len = PAGE_SIZE;
+}
+
static int page_pipe_grow(struct page_pipe *pp)
{
struct page_pipe_buf *ppb;
@@ -150,9 +156,7 @@ static inline int try_add_page_to(struct page_pipe *pp, struct page_pipe_buf *pp
pr_debug("Add iov to page pipe (%u iovs, %u/%u total)\n",
ppb->nr_segs, pp->free_iov, pp->nr_iovs);
- ppb->iov[ppb->nr_segs].iov_base = (void *)addr;
- ppb->iov[ppb->nr_segs].iov_len = PAGE_SIZE;
- ppb->nr_segs++;
+ iov_init(&ppb->iov[ppb->nr_segs++], addr);
pp->free_iov++;
BUG_ON(pp->free_iov > pp->nr_iovs);
out:
@@ -187,8 +191,6 @@ int page_pipe_add_page(struct page_pipe *pp, unsigned long addr)
int page_pipe_add_hole(struct page_pipe *pp, unsigned long addr)
{
- struct iovec *iov;
-
if (pp->free_hole >= pp->nr_holes) {
pp->holes = xrealloc(pp->holes,
(pp->nr_holes + PP_HOLES_BATCH) * sizeof(struct iovec));
@@ -202,10 +204,7 @@ int page_pipe_add_hole(struct page_pipe *pp, unsigned long addr)
iov_grow(&pp->holes[pp->free_hole - 1], addr))
goto out;
- iov = &pp->holes[pp->free_hole];
- iov->iov_base = (void *)addr;
- iov->iov_len = PAGE_SIZE;
- pp->free_hole++;
+ iov_init(&pp->holes[pp->free_hole++], addr);
out:
return 0;
}
--
1.8.4.2
More information about the CRIU
mailing list