[CRIU] [PATCH 12/16] mem/page-pipe: Use xrealloc_safe in page_pipe_add_hole
Mike Rapoport
rppt at linux.ibm.com
Mon Jul 8 20:07:17 MSK 2019
On Fri, Jul 05, 2019 at 06:38:07PM +0300, Cyrill Gorcunov wrote:
> To shrink code a bit.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
Reviewed-by: Mike Rapoport <rppt at linux.ibm.com>
> ---
> criu/page-pipe.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/criu/page-pipe.c b/criu/page-pipe.c
> index 534380b0f1ce..a8216962dac4 100644
> --- a/criu/page-pipe.c
> +++ b/criu/page-pipe.c
> @@ -298,14 +298,12 @@ int page_pipe_add_hole(struct page_pipe *pp, unsigned long addr,
> unsigned int flags)
> {
> if (pp->free_hole >= pp->nr_holes) {
> - pp->holes = xrealloc(pp->holes,
> - (pp->nr_holes + PP_HOLES_BATCH) * sizeof(struct iovec));
> - if (!pp->holes)
> + size_t new_size = (pp->nr_holes + PP_HOLES_BATCH) * sizeof(struct iovec);
> + if (xrealloc_safe(&pp->holes, new_size))
> return -1;
>
> - pp->hole_flags = xrealloc(pp->hole_flags,
> - (pp->nr_holes + PP_HOLES_BATCH) * sizeof(unsigned int));
> - if(!pp->hole_flags)
> + new_size = (pp->nr_holes + PP_HOLES_BATCH) * sizeof(unsigned int);
> + if (xrealloc_safe(&pp->hole_flags, new_size))
> return -1;
>
> pp->nr_holes += PP_HOLES_BATCH;
> --
> 2.20.1
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
--
Sincerely yours,
Mike.
More information about the CRIU
mailing list