[PATCH 08/39] migration: replace assert(0) with g_assert_not_reached()

Pierrick Bouvier posted 39 patches 2 months, 2 weeks ago
There is a newer version of this series
[PATCH 08/39] migration: replace assert(0) with g_assert_not_reached()
Posted by Pierrick Bouvier 2 months, 2 weeks ago
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 migration/migration-hmp-cmds.c |  2 +-
 migration/postcopy-ram.c       | 14 +++++++-------
 migration/ram.c                |  6 +++---
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index 7d608d26e19..e6e96aa6288 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -636,7 +636,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
         visit_type_bool(v, param, &p->direct_io, &err);
         break;
     default:
-        assert(0);
+        g_assert_not_reached();
     }
 
     if (err) {
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 1c374b7ea1e..f431bbc0d4f 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -1411,40 +1411,40 @@ int postcopy_ram_incoming_init(MigrationIncomingState *mis)
 
 int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
 {
-    assert(0);
+    g_assert_not_reached();
     return -1;
 }
 
 int postcopy_ram_prepare_discard(MigrationIncomingState *mis)
 {
-    assert(0);
+    g_assert_not_reached();
     return -1;
 }
 
 int postcopy_request_shared_page(struct PostCopyFD *pcfd, RAMBlock *rb,
                                  uint64_t client_addr, uint64_t rb_offset)
 {
-    assert(0);
+    g_assert_not_reached();
     return -1;
 }
 
 int postcopy_ram_incoming_setup(MigrationIncomingState *mis)
 {
-    assert(0);
+    g_assert_not_reached();
     return -1;
 }
 
 int postcopy_place_page(MigrationIncomingState *mis, void *host, void *from,
                         RAMBlock *rb)
 {
-    assert(0);
+    g_assert_not_reached();
     return -1;
 }
 
 int postcopy_place_page_zero(MigrationIncomingState *mis, void *host,
                         RAMBlock *rb)
 {
-    assert(0);
+    g_assert_not_reached();
     return -1;
 }
 
@@ -1452,7 +1452,7 @@ int postcopy_wake_shared(struct PostCopyFD *pcfd,
                          uint64_t client_addr,
                          RAMBlock *rb)
 {
-    assert(0);
+    g_assert_not_reached();
     return -1;
 }
 #endif
diff --git a/migration/ram.c b/migration/ram.c
index 67ca3d5d51a..0aa5d347439 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1765,19 +1765,19 @@ bool ram_write_tracking_available(void)
 
 bool ram_write_tracking_compatible(void)
 {
-    assert(0);
+    g_assert_not_reached();
     return false;
 }
 
 int ram_write_tracking_start(void)
 {
-    assert(0);
+    g_assert_not_reached();
     return -1;
 }
 
 void ram_write_tracking_stop(void)
 {
-    assert(0);
+    g_assert_not_reached();
 }
 #endif /* defined(__linux__) */
 
-- 
2.39.2
Re: [PATCH 08/39] migration: replace assert(0) with g_assert_not_reached()
Posted by Peter Xu 2 months, 1 week ago
On Tue, Sep 10, 2024 at 03:15:35PM -0700, Pierrick Bouvier wrote:
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>

Reviewed-by: Peter Xu <peterx@redhat.com>

-- 
Peter Xu
Re: [PATCH 08/39] migration: replace assert(0) with g_assert_not_reached()
Posted by Richard Henderson 2 months, 2 weeks ago
On 9/10/24 15:15, Pierrick Bouvier wrote:
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   migration/migration-hmp-cmds.c |  2 +-
>   migration/postcopy-ram.c       | 14 +++++++-------
>   migration/ram.c                |  6 +++---
>   3 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
> index 7d608d26e19..e6e96aa6288 100644
> --- a/migration/migration-hmp-cmds.c
> +++ b/migration/migration-hmp-cmds.c
> @@ -636,7 +636,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
>           visit_type_bool(v, param, &p->direct_io, &err);
>           break;
>       default:
> -        assert(0);
> +        g_assert_not_reached();
>       }
>   
>       if (err) {
> diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
> index 1c374b7ea1e..f431bbc0d4f 100644
> --- a/migration/postcopy-ram.c
> +++ b/migration/postcopy-ram.c
> @@ -1411,40 +1411,40 @@ int postcopy_ram_incoming_init(MigrationIncomingState *mis)
>   
>   int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
>   {
> -    assert(0);
> +    g_assert_not_reached();
>       return -1;
>   }


You've got patches removing extra breaks, but these returns are dead too.

Anyway,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~
Re: [PATCH 08/39] migration: replace assert(0) with g_assert_not_reached()
Posted by Pierrick Bouvier 2 months, 2 weeks ago
On 9/10/24 19:17, Richard Henderson wrote:
> On 9/10/24 15:15, Pierrick Bouvier wrote:
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>>    migration/migration-hmp-cmds.c |  2 +-
>>    migration/postcopy-ram.c       | 14 +++++++-------
>>    migration/ram.c                |  6 +++---
>>    3 files changed, 11 insertions(+), 11 deletions(-)
>>
>> diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
>> index 7d608d26e19..e6e96aa6288 100644
>> --- a/migration/migration-hmp-cmds.c
>> +++ b/migration/migration-hmp-cmds.c
>> @@ -636,7 +636,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
>>            visit_type_bool(v, param, &p->direct_io, &err);
>>            break;
>>        default:
>> -        assert(0);
>> +        g_assert_not_reached();
>>        }
>>    
>>        if (err) {
>> diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
>> index 1c374b7ea1e..f431bbc0d4f 100644
>> --- a/migration/postcopy-ram.c
>> +++ b/migration/postcopy-ram.c
>> @@ -1411,40 +1411,40 @@ int postcopy_ram_incoming_init(MigrationIncomingState *mis)
>>    
>>    int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
>>    {
>> -    assert(0);
>> +    g_assert_not_reached();
>>        return -1;
>>    }
> 
> 
> You've got patches removing extra breaks, but these returns are dead too.
> 

I'll take a look to cleanup this in v2 as well.

> Anyway,
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> 
> 
> r~
Re: [PATCH 08/39] migration: replace assert(0) with g_assert_not_reached()
Posted by Fabiano Rosas 2 months, 2 weeks ago
Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:

> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>  migration/migration-hmp-cmds.c |  2 +-
>  migration/postcopy-ram.c       | 14 +++++++-------
>  migration/ram.c                |  6 +++---
>  3 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
> index 7d608d26e19..e6e96aa6288 100644
> --- a/migration/migration-hmp-cmds.c
> +++ b/migration/migration-hmp-cmds.c
> @@ -636,7 +636,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
>          visit_type_bool(v, param, &p->direct_io, &err);
>          break;
>      default:
> -        assert(0);
> +        g_assert_not_reached();
>      }
>  
>      if (err) {
> diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
> index 1c374b7ea1e..f431bbc0d4f 100644
> --- a/migration/postcopy-ram.c
> +++ b/migration/postcopy-ram.c
> @@ -1411,40 +1411,40 @@ int postcopy_ram_incoming_init(MigrationIncomingState *mis)
>  
>  int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
>  {
> -    assert(0);
> +    g_assert_not_reached();
>      return -1;
>  }
>  
>  int postcopy_ram_prepare_discard(MigrationIncomingState *mis)
>  {
> -    assert(0);
> +    g_assert_not_reached();
>      return -1;
>  }
>  
>  int postcopy_request_shared_page(struct PostCopyFD *pcfd, RAMBlock *rb,
>                                   uint64_t client_addr, uint64_t rb_offset)
>  {
> -    assert(0);
> +    g_assert_not_reached();
>      return -1;
>  }
>  
>  int postcopy_ram_incoming_setup(MigrationIncomingState *mis)
>  {
> -    assert(0);
> +    g_assert_not_reached();
>      return -1;
>  }
>  
>  int postcopy_place_page(MigrationIncomingState *mis, void *host, void *from,
>                          RAMBlock *rb)
>  {
> -    assert(0);
> +    g_assert_not_reached();
>      return -1;
>  }
>  
>  int postcopy_place_page_zero(MigrationIncomingState *mis, void *host,
>                          RAMBlock *rb)
>  {
> -    assert(0);
> +    g_assert_not_reached();
>      return -1;
>  }
>  
> @@ -1452,7 +1452,7 @@ int postcopy_wake_shared(struct PostCopyFD *pcfd,
>                           uint64_t client_addr,
>                           RAMBlock *rb)
>  {
> -    assert(0);
> +    g_assert_not_reached();
>      return -1;
>  }
>  #endif
> diff --git a/migration/ram.c b/migration/ram.c
> index 67ca3d5d51a..0aa5d347439 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -1765,19 +1765,19 @@ bool ram_write_tracking_available(void)
>  
>  bool ram_write_tracking_compatible(void)
>  {
> -    assert(0);
> +    g_assert_not_reached();
>      return false;
>  }
>  
>  int ram_write_tracking_start(void)
>  {
> -    assert(0);
> +    g_assert_not_reached();
>      return -1;
>  }
>  
>  void ram_write_tracking_stop(void)
>  {
> -    assert(0);
> +    g_assert_not_reached();
>  }
>  #endif /* defined(__linux__) */

Reviewed-by: Fabiano Rosas <farosas@suse.de>