[PATCH 08/11] migration/ram: One less indent for ram_find_and_save_block()

Peter Xu posted 11 patches 5 months, 3 weeks ago
There is a newer version of this series
[PATCH 08/11] migration/ram: One less indent for ram_find_and_save_block()
Posted by Peter Xu 5 months, 3 weeks ago
The check over PAGE_DIRTY_FOUND isn't necessary. We could indent one less
and assert that instead.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/ram.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index ed380ac86f..c66ad3cf8b 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2285,16 +2285,18 @@ static int ram_find_and_save_block(RAMState *rs)
         if (!get_queued_page(rs, pss)) {
             /* priority queue empty, so just search for something dirty */
             int res = find_dirty_block(rs, pss);
-            if (res != PAGE_DIRTY_FOUND) {
-                if (res == PAGE_ALL_CLEAN) {
-                    break;
-                } else if (res == PAGE_TRY_AGAIN) {
-                    continue;
-                } else if (res < 0) {
-                    pages = res;
-                    break;
-                }
+
+            if (res == PAGE_ALL_CLEAN) {
+                break;
+            } else if (res == PAGE_TRY_AGAIN) {
+                continue;
+            } else if (res < 0) {
+                pages = res;
+                break;
             }
+
+            /* Otherwise we must have a dirty page to move */
+            assert(res == PAGE_DIRTY_FOUND);
         }
         pages = ram_save_host_page(rs, pss);
         if (pages) {
-- 
2.49.0
Re: [PATCH 08/11] migration/ram: One less indent for ram_find_and_save_block()
Posted by Juraj Marcin 5 months, 2 weeks ago
On 2025-05-27 17:58, Peter Xu wrote:
> The check over PAGE_DIRTY_FOUND isn't necessary. We could indent one less
> and assert that instead.
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  migration/ram.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)

Reviewed-by: Juraj Marcin <jmarcin@redhat.com>