qobject: Clean up around qtype_code
authorMarkus Armbruster <armbru@redhat.com>
Wed, 29 Apr 2015 21:35:04 +0000 (15:35 -0600)
committerLuiz Capitulino <lcapitulino@redhat.com>
Mon, 11 May 2015 12:59:07 +0000 (08:59 -0400)
QTYPE_NONE is a sentinel value.  No QObject has this type code.
Document it properly.

Fix dump_qobject() to abort() on QTYPE_NONE, just like for any other
invalid type code.

Fix to_json() to abort() on all invalid type codes, not just
QTYPE_MAX.

Clean up Property member qtype's type: it's a qtype_code.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
block/qapi.c
include/hw/qdev-core.h
include/qapi/qmp/qobject.h
qobject/qjson.c

index 063dd1bc1f3f9167167e0114d79bf0e0d90fab43..18d2b95f54aeb9e830d806e385f1ec6cf01b4771 100644 (file)
@@ -523,9 +523,6 @@ static void dump_qobject(fprintf_function func_fprintf, void *f,
             QDECREF(value);
             break;
         }
-        case QTYPE_NONE:
-            break;
-        case QTYPE_MAX:
         default:
             abort();
     }
index 4e673f9d294525bb05cd96080c08953c4516e412..9a0ee30db527147b258aa73eebc8756f6be5385e 100644 (file)
@@ -226,7 +226,7 @@ struct Property {
     PropertyInfo *info;
     int          offset;
     uint8_t      bitnr;
-    uint8_t      qtype;
+    qtype_code   qtype;
     int64_t      defval;
     int          arrayoffset;
     PropertyInfo *arrayinfo;
index d0bbc7c4a64d792c00194893ad42b086410bc19b..099129657a5768284a21056c9b6be91f52d6abb8 100644 (file)
@@ -36,7 +36,7 @@
 #include <assert.h>
 
 typedef enum {
-    QTYPE_NONE,
+    QTYPE_NONE,    /* sentinel value, no QObject has this type code */
     QTYPE_QINT,
     QTYPE_QSTRING,
     QTYPE_QDICT,
index 12c576d548d1935b774e6d7419468e00ddaaeede..f2857c13ea1466385196e5d2ef37ea34113e59c4 100644 (file)
@@ -260,9 +260,8 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent)
     }
     case QTYPE_QERROR:
         /* XXX: should QError be emitted? */
-    case QTYPE_NONE:
         break;
-    case QTYPE_MAX:
+    default:
         abort();
     }
 }