Patchwork Simplify cpu_can_run()

login
register
mail settings
Submitter Jun Koi
Date April 12, 2010, 6:24 a.m.
Message ID <w2zfdaac4d51004112324ocebd7e86oce6f3a92539f0b19@mail.gmail.com>
Download mbox | patch
Permalink /patch/49940/
State New
Headers show

Comments

Jun Koi - April 12, 2010, 6:24 a.m.
This patch simplifies cpu_can_run().

Signed-off-by: Jun Koi <junkoi2004@gmail.com>
Paolo Bonzini - April 12, 2010, 7:03 a.m.
On 04/12/2010 08:24 AM, Jun Koi wrote:
> diff --git a/cpus.c b/cpus.c
> index 0debe77..4adb66d 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -98,9 +98,7 @@ static void do_vm_stop(int reason)
>
>   static int cpu_can_run(CPUState *env)
>   {
> -    if (env->stop)
> -        return 0;
> -    if (env->stopped || !vm_running)
> +    if (env->stop || env->stopped || !vm_running)
>           return 0;
>       return 1;
>   }

I left it this way on purpose to help comparison with cpu_has_work.


static int cpu_can_run(CPUState *env)
{
     if (env->stop)
         return 0;
     if (env->stopped || !vm_running)
         return 0;
     return 1;
}

static int cpu_has_work(CPUState *env)
{
     if (env->stop)
         return 1;
     if (env->stopped || !vm_running)
         return 0;

Paolo

Patch

diff --git a/cpus.c b/cpus.c
index 0debe77..4adb66d 100644
--- a/cpus.c
+++ b/cpus.c
@@ -98,9 +98,7 @@  static void do_vm_stop(int reason)

 static int cpu_can_run(CPUState *env)
 {
-    if (env->stop)
-        return 0;
-    if (env->stopped || !vm_running)
+    if (env->stop || env->stopped || !vm_running)
         return 0;
     return 1;
 }