qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v6 02/23] qapi: Require int64/uint64 implementation
Date: Wed, 25 Nov 2015 17:22:59 -0700	[thread overview]
Message-ID: <1448497401-27784-3-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1448497401-27784-1-git-send-email-eblake@redhat.com>

Now that all visitors supply both type_int64() and type_uint64()
callbacks, we can drop the redundant type_int() callback (the
public interface visit_type_int() remains, but calls into
type_int64() under the hood).

Signed-off-by: Eric Blake <eblake@redhat.com>

---
v6: new patch, but stems from v5 23/46
---
 include/qapi/visitor-impl.h  |  1 -
 qapi/opts-visitor.c          |  1 -
 qapi/qapi-dealloc-visitor.c  |  1 -
 qapi/qapi-visit-core.c       | 50 ++++++++++++++------------------------------
 qapi/qmp-input-visitor.c     |  1 -
 qapi/qmp-output-visitor.c    |  1 -
 qapi/string-input-visitor.c  |  1 -
 qapi/string-output-visitor.c |  1 -
 8 files changed, 16 insertions(+), 41 deletions(-)

diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h
index 44a21b7..70326e0 100644
--- a/include/qapi/visitor-impl.h
+++ b/include/qapi/visitor-impl.h
@@ -36,7 +36,6 @@ struct Visitor
     void (*get_next_type)(Visitor *v, QType *type, bool promote_int,
                           const char *name, Error **errp);

-    void (*type_int)(Visitor *v, int64_t *obj, const char *name, Error **errp);
     void (*type_bool)(Visitor *v, bool *obj, const char *name, Error **errp);
     void (*type_str)(Visitor *v, char **obj, const char *name, Error **errp);
     void (*type_number)(Visitor *v, double *obj, const char *name,
diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index bc2b976..8104e42 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -522,7 +522,6 @@ opts_visitor_new(const QemuOpts *opts)
      */
     ov->visitor.type_enum = &input_type_enum;

-    ov->visitor.type_int    = &opts_type_int64;
     ov->visitor.type_int64  = &opts_type_int64;
     ov->visitor.type_uint64 = &opts_type_uint64;
     ov->visitor.type_size   = &opts_type_size;
diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c
index 5d1b2e6..5133d37 100644
--- a/qapi/qapi-dealloc-visitor.c
+++ b/qapi/qapi-dealloc-visitor.c
@@ -220,7 +220,6 @@ QapiDeallocVisitor *qapi_dealloc_visitor_new(void)
     v->visitor.next_list = qapi_dealloc_next_list;
     v->visitor.end_list = qapi_dealloc_end_list;
     v->visitor.type_enum = qapi_dealloc_type_enum;
-    v->visitor.type_int = qapi_dealloc_type_int64;
     v->visitor.type_int64 = qapi_dealloc_type_int64;
     v->visitor.type_uint64 = qapi_dealloc_type_uint64;
     v->visitor.type_bool = qapi_dealloc_type_bool;
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 6d63e40..88bed9c 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -97,19 +97,19 @@ void visit_type_enum(Visitor *v, int *obj, const char * const strings[],

 void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp)
 {
-    v->type_int(v, obj, name, errp);
+    v->type_int64(v, obj, name, errp);
 }

 void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp)
 {
-    int64_t value;
+    uint64_t value;

     if (v->type_uint8) {
         v->type_uint8(v, obj, name, errp);
     } else {
         value = *obj;
-        v->type_int(v, &value, name, errp);
-        if (value < 0 || value > UINT8_MAX) {
+        v->type_uint64(v, &value, name, errp);
+        if (value > UINT8_MAX) {
             error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                        name ? name : "null", "uint8_t");
             return;
@@ -120,14 +120,14 @@ void visit_type_uint8(Visitor *v, uint8_t *obj, const char *name, Error **errp)

 void visit_type_uint16(Visitor *v, uint16_t *obj, const char *name, Error **errp)
 {
-    int64_t value;
+    uint64_t value;

     if (v->type_uint16) {
         v->type_uint16(v, obj, name, errp);
     } else {
         value = *obj;
-        v->type_int(v, &value, name, errp);
-        if (value < 0 || value > UINT16_MAX) {
+        v->type_uint64(v, &value, name, errp);
+        if (value > UINT16_MAX) {
             error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                        name ? name : "null", "uint16_t");
             return;
@@ -138,14 +138,14 @@ void visit_type_uint16(Visitor *v, uint16_t *obj, const char *name, Error **errp

 void visit_type_uint32(Visitor *v, uint32_t *obj, const char *name, Error **errp)
 {
-    int64_t value;
+    uint64_t value;

     if (v->type_uint32) {
         v->type_uint32(v, obj, name, errp);
     } else {
         value = *obj;
-        v->type_int(v, &value, name, errp);
-        if (value < 0 || value > UINT32_MAX) {
+        v->type_uint64(v, &value, name, errp);
+        if (value > UINT32_MAX) {
             error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                        name ? name : "null", "uint32_t");
             return;
@@ -156,15 +156,7 @@ void visit_type_uint32(Visitor *v, uint32_t *obj, const char *name, Error **errp

 void visit_type_uint64(Visitor *v, uint64_t *obj, const char *name, Error **errp)
 {
-    int64_t value;
-
-    if (v->type_uint64) {
-        v->type_uint64(v, obj, name, errp);
-    } else {
-        value = *obj;
-        v->type_int(v, &value, name, errp);
-        *obj = value;
-    }
+    v->type_uint64(v, obj, name, errp);
 }

 void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp)
@@ -175,7 +167,7 @@ void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp)
         v->type_int8(v, obj, name, errp);
     } else {
         value = *obj;
-        v->type_int(v, &value, name, errp);
+        v->type_int64(v, &value, name, errp);
         if (value < INT8_MIN || value > INT8_MAX) {
             error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                        name ? name : "null", "int8_t");
@@ -193,7 +185,7 @@ void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp)
         v->type_int16(v, obj, name, errp);
     } else {
         value = *obj;
-        v->type_int(v, &value, name, errp);
+        v->type_int64(v, &value, name, errp);
         if (value < INT16_MIN || value > INT16_MAX) {
             error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                        name ? name : "null", "int16_t");
@@ -211,7 +203,7 @@ void visit_type_int32(Visitor *v, int32_t *obj, const char *name, Error **errp)
         v->type_int32(v, obj, name, errp);
     } else {
         value = *obj;
-        v->type_int(v, &value, name, errp);
+        v->type_int64(v, &value, name, errp);
         if (value < INT32_MIN || value > INT32_MAX) {
             error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
                        name ? name : "null", "int32_t");
@@ -223,25 +215,15 @@ void visit_type_int32(Visitor *v, int32_t *obj, const char *name, Error **errp)

 void visit_type_int64(Visitor *v, int64_t *obj, const char *name, Error **errp)
 {
-    if (v->type_int64) {
-        v->type_int64(v, obj, name, errp);
-    } else {
-        v->type_int(v, obj, name, errp);
-    }
+    v->type_int64(v, obj, name, errp);
 }

 void visit_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp)
 {
-    int64_t value;
-
     if (v->type_size) {
         v->type_size(v, obj, name, errp);
-    } else if (v->type_uint64) {
-        v->type_uint64(v, obj, name, errp);
     } else {
-        value = *obj;
-        v->type_int(v, &value, name, errp);
-        *obj = value;
+        v->type_uint64(v, obj, name, errp);
     }
 }

diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c
index 96dafcb..ba743db 100644
--- a/qapi/qmp-input-visitor.c
+++ b/qapi/qmp-input-visitor.c
@@ -356,7 +356,6 @@ QmpInputVisitor *qmp_input_visitor_new(QObject *obj)
     v->visitor.next_list = qmp_input_next_list;
     v->visitor.end_list = qmp_input_end_list;
     v->visitor.type_enum = input_type_enum;
-    v->visitor.type_int = qmp_input_type_int64;
     v->visitor.type_int64 = qmp_input_type_int64;
     v->visitor.type_uint64 = qmp_input_type_uint64;
     v->visitor.type_bool = qmp_input_type_bool;
diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c
index a52f26f..e66ab3c 100644
--- a/qapi/qmp-output-visitor.c
+++ b/qapi/qmp-output-visitor.c
@@ -248,7 +248,6 @@ QmpOutputVisitor *qmp_output_visitor_new(void)
     v->visitor.next_list = qmp_output_next_list;
     v->visitor.end_list = qmp_output_end_list;
     v->visitor.type_enum = output_type_enum;
-    v->visitor.type_int = qmp_output_type_int64;
     v->visitor.type_int64 = qmp_output_type_int64;
     v->visitor.type_uint64 = qmp_output_type_uint64;
     v->visitor.type_bool = qmp_output_type_bool;
diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
index 0931321..0a7ddee 100644
--- a/qapi/string-input-visitor.c
+++ b/qapi/string-input-visitor.c
@@ -344,7 +344,6 @@ StringInputVisitor *string_input_visitor_new(const char *str)
     v = g_malloc0(sizeof(*v));

     v->visitor.type_enum = input_type_enum;
-    v->visitor.type_int = parse_type_int64;
     v->visitor.type_int64 = parse_type_int64;
     v->visitor.type_uint64 = parse_type_uint64;
     v->visitor.type_size = parse_type_size;
diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
index 83ca6cc..bcd72bb 100644
--- a/qapi/string-output-visitor.c
+++ b/qapi/string-output-visitor.c
@@ -348,7 +348,6 @@ StringOutputVisitor *string_output_visitor_new(bool human)
     v->string = g_string_new(NULL);
     v->human = human;
     v->visitor.type_enum = output_type_enum;
-    v->visitor.type_int = print_type_int64;
     v->visitor.type_int64 = print_type_int64;
     v->visitor.type_uint64 = print_type_uint64;
     v->visitor.type_size = print_type_size;
-- 
2.4.3

  parent reply	other threads:[~2015-11-26  0:23 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-26  0:22 [Qemu-devel] [PATCH v6 00/23] qapi visitor cleanups (post-introspection cleanups subset E) Eric Blake
2015-11-26  0:22 ` [Qemu-devel] [PATCH v6 01/23] qapi: Make all visitors supply int64/uint64 callbacks Eric Blake
2015-11-27 11:17   ` Markus Armbruster
2015-11-26  0:22 ` Eric Blake [this message]
2015-11-27 12:05   ` [Qemu-devel] [PATCH v6 02/23] qapi: Require int64/uint64 implementation Markus Armbruster
2015-12-02 21:25     ` Eric Blake
2015-12-03  8:30       ` Markus Armbruster
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 03/23] qapi: Consolidate visitor integer callbacks Eric Blake
2015-11-27 12:11   ` Markus Armbruster
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 04/23] qapi: Don't cast Enum* to int* Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 05/23] qmp: Fix reference-counting of qnull on empty output visit Eric Blake
2015-11-27 13:06   ` Markus Armbruster
2015-12-02 23:10     ` Eric Blake
2015-12-03 17:50       ` Markus Armbruster
2015-12-04  3:01         ` Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 06/23] qapi: Don't abuse stack to track qmp-output root Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 07/23] qapi: Document visitor interfaces Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 08/23] qapi: Drop unused error argument for list and implicit struct Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 09/23] hmp: Improve use of qapi visitor Eric Blake
2015-12-04 21:18   ` Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 10/23] vl: " Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 11/23] ppc: Improve use of qapi visitors Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 12/23] balloon: Improve use of qapi visitor Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 13/23] qapi: Add type.is_empty() helper Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 14/23] qapi: Fix command with named empty argument type Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 15/23] qapi: Improve generated event use of qapi visitor Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 16/23] qapi: Track all failures between visit_start/stop Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 17/23] qapi: Eliminate empty visit_type_FOO_fields Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 18/23] qapi: Canonicalize missing object to :empty Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 19/23] qapi-visit: Unify struct and union visit Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 20/23] qapi: Rework deallocation of partial struct Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 21/23] qapi: Simplify extra member error reporting in input visitors Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 22/23] qapi: Split visit_end_struct() into pieces Eric Blake
2015-11-26  0:23 ` [Qemu-devel] [PATCH v6 23/23] qapi: Change visit_type_FOO() to no longer return partial objects Eric Blake

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=1448497401-27784-3-git-send-email-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --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).