qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Cody <jcody@redhat.com>
To: qemu-block@nongnu.org
Cc: peter.maydell@linaro.org, jcody@redhat.com,
	"Kevin Wolf" <kwolf@redhat.com>,
	qemu-devel@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PULL 2/3] blockjob: use qapi enum helpers
Date: Tue,  3 Apr 2018 12:13:23 -0400	[thread overview]
Message-ID: <20180403161324.24514-3-jcody@redhat.com> (raw)
In-Reply-To: <20180403161324.24514-1-jcody@redhat.com>

From: Marc-André Lureau <marcandre.lureau@redhat.com>

QAPI generator provide #define helpers for looking up enum string.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Message-id: 20180327153011.29569-1-marcandre.lureau@redhat.com
Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 blockjob.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/blockjob.c b/blockjob.c
index c510a9fde5..27f957e571 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.13.6

  parent reply	other threads:[~2018-04-03 16:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-03 16:13 [Qemu-devel] [PULL 0/3] Block patches for 2.12-rc2 Jeff Cody
2018-04-03 16:13 ` [Qemu-devel] [PULL 1/3] blockjob: leak fix, remove from txn when failing early Jeff Cody
2018-04-03 16:13 ` Jeff Cody [this message]
2018-04-03 16:13 ` [Qemu-devel] [PULL 3/3] gluster: Fix blockdev-add with server.N.type=unix Jeff Cody
2018-04-04 12:59 ` [Qemu-devel] [PULL 0/3] Block patches for 2.12-rc2 Peter Maydell

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=20180403161324.24514-3-jcody@redhat.com \
    --to=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).