On Tue, Aug 15, 2023 at 11:38:27AM -0300, Fabiano Rosas wrote:
> Invert the first conditional so we return early when len == 0. This is
> merely to make the next patch easier to read.
> 
> Signed-off-by: Fabiano Rosas <faro...@suse.de>
> ---
>  migration/ram.c | 29 +++++++++++++++--------------
>  1 file changed, 15 insertions(+), 14 deletions(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index a10410a1a5..8ec38f69e8 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -1169,23 +1169,24 @@ static int save_zero_page(RAMState *rs, 
> PageSearchStatus *pss, RAMBlock *block,
>  {
>      int len = save_zero_page_to_file(pss, block, offset);
>  
> -    if (len) {
> -        stat64_add(&mig_stats.zero_pages, 1);
> -        ram_transferred_add(len);
> +    if (!len) {
> +        return -1;
> +    }
>  
> -        /*
> -         * Must let xbzrle know, otherwise a previous (now 0'd) cached
> -         * page would be stale.
> -         */
> -        if (rs->xbzrle_started) {
> -            XBZRLE_cache_lock();
> -            xbzrle_cache_zero_page(block->offset + offset);
> -            XBZRLE_cache_unlock();
> -        }
> +    stat64_add(&mig_stats.zero_pages, 1);
> +    ram_transferred_add(len);
>  
> -        return 1;
> +    /*
> +     * Must let xbzrle know, otherwise a previous (now 0'd) cached
> +     * page would be stale.
> +     */
> +    if (rs->xbzrle_started) {
> +        XBZRLE_cache_lock();
> +        xbzrle_cache_zero_page(block->offset + offset);
> +        XBZRLE_cache_unlock();
>      }
> -    return -1;
> +
> +    return 1;
>  }

Can we squash this into previous patch?

-- 
Peter Xu


Reply via email to