qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH] blockjob: use qapi enum helpers


From: Jeff Cody
Subject: Re: [Qemu-block] [PATCH] blockjob: use qapi enum helpers
Date: Wed, 28 Mar 2018 14:25:10 -0400
User-agent: Mutt/1.5.24 (2015-08-30)

On Tue, Mar 27, 2018 at 05:30:11PM +0200, Marc-André Lureau wrote:
> QAPI generator provide #define helpers for looking up enum string.
> 
> Signed-off-by: Marc-André Lureau <address@hidden>
> ---
>  blockjob.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/blockjob.c b/blockjob.c
> index ef3ed69ff1..11c9ce124d 100644
> --- a/blockjob.c
> +++ b/blockjob.c
> @@ -75,10 +75,8 @@ static void block_job_state_transition(BlockJob *job, 
> BlockJobStatus s1)
>      assert(s1 >= 0 && s1 <= BLOCK_JOB_STATUS__MAX);
>      trace_block_job_state_transition(job, job->ret, BlockJobSTT[s0][s1] ?
>                                       "allowed" : "disallowed",
> -                                     qapi_enum_lookup(&BlockJobStatus_lookup,
> -                                                      s0),
> -                                     qapi_enum_lookup(&BlockJobStatus_lookup,
> -                                                      s1));
> +                                     BlockJobStatus_str(s0),
> +                                     BlockJobStatus_str(s1));
>      assert(BlockJobSTT[s0][s1]);
>      job->status = s1;
>  }
> @@ -86,17 +84,15 @@ static void block_job_state_transition(BlockJob *job, 
> BlockJobStatus s1)
>  static int block_job_apply_verb(BlockJob *job, BlockJobVerb bv, Error **errp)
>  {
>      assert(bv >= 0 && bv <= BLOCK_JOB_VERB__MAX);
> -    trace_block_job_apply_verb(job, qapi_enum_lookup(&BlockJobStatus_lookup,
> -                                                     job->status),
> -                               qapi_enum_lookup(&BlockJobVerb_lookup, bv),
> +    trace_block_job_apply_verb(job, BlockJobStatus_str(job->status),
> +                               BlockJobVerb_str(bv),
>                                 BlockJobVerbTable[bv][job->status] ?
>                                 "allowed" : "prohibited");
>      if (BlockJobVerbTable[bv][job->status]) {
>          return 0;
>      }
>      error_setg(errp, "Job '%s' in state '%s' cannot accept command verb 
> '%s'",
> -               job->id, qapi_enum_lookup(&BlockJobStatus_lookup, 
> job->status),
> -               qapi_enum_lookup(&BlockJobVerb_lookup, bv));
> +               job->id, BlockJobStatus_str(job->status), 
> BlockJobVerb_str(bv));
>      return -EPERM;
>  }
>  
> -- 
> 2.17.0.rc1.1.g4c4f2b46a3
> 

Thanks,

Looks like a bug fix to me.

Applied to my block branch:

git://github.com/codyprime/qemu-kvm-jtc block

-Jeff



reply via email to

[Prev in Thread] Current Thread [Next in Thread]