qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type
Date: Fri, 09 Jun 2017 14:32:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

PATCH 01-41 look ready with minor tweaks.  I chatted with Marc-André,
and he asked me to apply them myself.  You can find the result at
https://repo.or.cz/qemu/armbru.git in branch qapi-next.  Marc-André,
please give it a quick look-over.  If it's good, I'll post a pull
request later today.

PATCH 42 is RFC.  I'd like to give PATCH 43 a bit more time on the list.

Incremental diff for your convenience:

diff --git a/blockdev.c b/blockdev.c
index 154c95d..4009dd9 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -335,10 +335,9 @@ static bool parse_stats_intervals(BlockAcctStats *stats, 
QList *intervals,
         }
 
         case QTYPE_QNUM: {
-            int64_t length;
+            int64_t length = qnum_get_int(qobject_to_qnum(entry->value));
 
-            if (qnum_get_try_int(qobject_to_qnum(entry->value), &length) &&
-                length > 0 && length <= UINT_MAX) {
+            if (length > 0 && length <= UINT_MAX) {
                 block_acct_add_interval(stats, (unsigned) length);
             } else {
                 error_setg(errp, "Invalid interval length: %" PRId64, length);
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index a8f09c1..68cd653 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -71,7 +71,7 @@ static void set_enum(Object *obj, Visitor *v, const char 
*name, void *opaque,
 
 static void set_default_value_enum(Object *obj, const Property *prop)
 {
-    object_property_set_str(obj, prop->info->enum_table[prop->defval.u],
+    object_property_set_str(obj, prop->info->enum_table[prop->defval.i],
                             prop->name, &error_abort);
 }
 
diff --git a/tests/test-qobject-input-visitor.c 
b/tests/test-qobject-input-visitor.c
index 3bcdb9a..34bab8a 100644
--- a/tests/test-qobject-input-visitor.c
+++ b/tests/test-qobject-input-visitor.c
@@ -152,6 +152,7 @@ static void test_visitor_in_uint(TestInputVisitorData *data,
     g_assert_cmpuint(res, ==, 18446744073709551574U);
 
     visit_type_number(v, NULL, &dbl, &error_abort);
+    g_assert_cmpfloat(dbl, ==, 18446744073709552000.0);
 }
 
 static void test_visitor_in_int_overflow(TestInputVisitorData *data,
@@ -161,9 +162,10 @@ static void 
test_visitor_in_int_overflow(TestInputVisitorData *data,
     Error *err = NULL;
     Visitor *v;
 
-    /* this will overflow a QNUM_I64, so should be deserialized into a
+    /*
+     * This will overflow a QNUM_I64, so should be deserialized into a
      * QNUM_DOUBLE field instead, leading to an error if we pass it to
-     * visit_type_int. confirm this.
+     * visit_type_int().  Confirm this.
      */
     v = visitor_input_test_init(data, "%f", DBL_MAX);
 
diff --git a/tests/test-qobject-output-visitor.c 
b/tests/test-qobject-output-visitor.c
index d23c8eb..749c540 100644
--- a/tests/test-qobject-output-visitor.c
+++ b/tests/test-qobject-output-visitor.c
@@ -609,11 +609,13 @@ static void check_native_list(QObject *qobj,
         for (i = 0; i < 32; i++) {
             QObject *tmp;
             QNum *qvalue;
+            uint64_t val;
 
             tmp = qlist_peek(qlist);
             g_assert(tmp);
             qvalue = qobject_to_qnum(tmp);
-            g_assert_cmpuint(qnum_get_uint(qvalue), ==, i);
+            g_assert(qnum_get_try_uint(qvalue, &val));
+            g_assert_cmpint(val, ==, i);
             qobject_decref(qlist_pop(qlist));
         }
         break;



reply via email to

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