diff mbox series

migration: current_migration is never NULL

Message ID 20190626004211.4822-1-richardw.yang@linux.intel.com
State New
Headers show
Series migration: current_migration is never NULL | expand

Commit Message

Wei Yang June 26, 2019, 12:42 a.m. UTC
migration_object_init() create and assign current_migration, which means
it will never be null until migration_shutdown().

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 migration/migration.c | 4 ----
 1 file changed, 4 deletions(-)

Comments

Dr. David Alan Gilbert July 19, 2019, 3:10 p.m. UTC | #1
* Wei Yang (richardw.yang@linux.intel.com) wrote:
> migration_object_init() create and assign current_migration, which means
> it will never be null until migration_shutdown().
> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
>  migration/migration.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/migration/migration.c b/migration/migration.c
> index 0fd2364961..43fd8297ef 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -1667,10 +1667,6 @@ bool migration_is_idle(void)
>  {
>      MigrationState *s = current_migration;
>  
> -    if (!s) {
> -        return true;
> -    }
> -

I'd prefer to keep that because it's used by migrate_add_blocker
and without this check it means we'd only be able to add a blocker
after the migration object init - which is probably fine but we
would have to check all the cases and make sure no one breaks it in
the future;  where as this check makes it just work and we don't
need to worry about the order.

Dave

>      switch (s->state) {
>      case MIGRATION_STATUS_NONE:
>      case MIGRATION_STATUS_CANCELLED:
> -- 
> 2.19.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Wei Yang July 20, 2019, 1:37 a.m. UTC | #2
On Fri, Jul 19, 2019 at 04:10:02PM +0100, Dr. David Alan Gilbert wrote:
>* Wei Yang (richardw.yang@linux.intel.com) wrote:
>> migration_object_init() create and assign current_migration, which means
>> it will never be null until migration_shutdown().
>> 
>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>> ---
>>  migration/migration.c | 4 ----
>>  1 file changed, 4 deletions(-)
>> 
>> diff --git a/migration/migration.c b/migration/migration.c
>> index 0fd2364961..43fd8297ef 100644
>> --- a/migration/migration.c
>> +++ b/migration/migration.c
>> @@ -1667,10 +1667,6 @@ bool migration_is_idle(void)
>>  {
>>      MigrationState *s = current_migration;
>>  
>> -    if (!s) {
>> -        return true;
>> -    }
>> -
>
>I'd prefer to keep that because it's used by migrate_add_blocker
>and without this check it means we'd only be able to add a blocker
>after the migration object init - which is probably fine but we
>would have to check all the cases and make sure no one breaks it in
>the future;  where as this check makes it just work and we don't
>need to worry about the order.
>

Reasonable, Thanks :-)

>Dave
>
>>      switch (s->state) {
>>      case MIGRATION_STATUS_NONE:
>>      case MIGRATION_STATUS_CANCELLED:
>> -- 
>> 2.19.1
>> 
>--
>Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
diff mbox series

Patch

diff --git a/migration/migration.c b/migration/migration.c
index 0fd2364961..43fd8297ef 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1667,10 +1667,6 @@  bool migration_is_idle(void)
 {
     MigrationState *s = current_migration;
 
-    if (!s) {
-        return true;
-    }
-
     switch (s->state) {
     case MIGRATION_STATUS_NONE:
     case MIGRATION_STATUS_CANCELLED: