All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com,
	jtc@redhat.com
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] blockjob: use qapi enum helpers
Date: Tue, 27 Mar 2018 12:42:32 -0400	[thread overview]
Message-ID: <93eeb364-6521-784f-b02b-c3c7e960461b@redhat.com> (raw)
In-Reply-To: <20180327153011.29569-1-marcandre.lureau@redhat.com>



On 03/27/2018 11:30 AM, Marc-André Lureau wrote:
> QAPI generator provide #define helpers for looking up enum string.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  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;
>  }
>  
> 

Oh, whoops. I knew you added functions, but I didn't realize we got
per-enum functions. Thanks.

Reviewed-by: John Snow <jsnow@redhat.com>

and forwarded to Jeff Cody.

--js

  reply	other threads:[~2018-03-27 16:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-27 15:30 [Qemu-devel] [PATCH] blockjob: use qapi enum helpers Marc-André Lureau
2018-03-27 16:42 ` John Snow [this message]
2018-03-28 18:25 ` Jeff Cody
2018-03-31  7:18 ` no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=93eeb364-6521-784f-b02b-c3c7e960461b@redhat.com \
    --to=jsnow@redhat.com \
    --cc=jtc@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.