mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
qapi: Use QNull for a more regular visit_type_null()
Make visit_type_null() take an @obj argument like its buddies. This helps keep the next commit simple. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
006ca09f30
commit
d2f95f4d48
15 changed files with 60 additions and 25 deletions
|
@ -127,12 +127,13 @@ static void qapi_clone_type_number(Visitor *v, const char *name, double *obj,
|
|||
/* Value was already cloned by g_memdup() */
|
||||
}
|
||||
|
||||
static void qapi_clone_type_null(Visitor *v, const char *name, Error **errp)
|
||||
static void qapi_clone_type_null(Visitor *v, const char *name, QNull **obj,
|
||||
Error **errp)
|
||||
{
|
||||
QapiCloneVisitor *qcv = to_qcv(v);
|
||||
|
||||
assert(qcv->depth);
|
||||
/* Nothing to do */
|
||||
*obj = qnull();
|
||||
}
|
||||
|
||||
static void qapi_clone_free(Visitor *v)
|
||||
|
|
|
@ -103,8 +103,12 @@ static void qapi_dealloc_type_anything(Visitor *v, const char *name,
|
|||
}
|
||||
}
|
||||
|
||||
static void qapi_dealloc_type_null(Visitor *v, const char *name, Error **errp)
|
||||
static void qapi_dealloc_type_null(Visitor *v, const char *name,
|
||||
QNull **obj, Error **errp)
|
||||
{
|
||||
if (obj) {
|
||||
QDECREF(*obj);
|
||||
}
|
||||
}
|
||||
|
||||
static void qapi_dealloc_free(Visitor *v)
|
||||
|
|
|
@ -325,10 +325,11 @@ void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp)
|
|||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
void visit_type_null(Visitor *v, const char *name, Error **errp)
|
||||
void visit_type_null(Visitor *v, const char *name, QNull **obj,
|
||||
Error **errp)
|
||||
{
|
||||
trace_visit_type_null(v, name);
|
||||
v->type_null(v, name, errp);
|
||||
trace_visit_type_null(v, name, obj);
|
||||
v->type_null(v, name, obj, errp);
|
||||
}
|
||||
|
||||
static void output_type_enum(Visitor *v, const char *name, int *obj,
|
||||
|
|
|
@ -587,11 +587,13 @@ static void qobject_input_type_any(Visitor *v, const char *name, QObject **obj,
|
|||
*obj = qobj;
|
||||
}
|
||||
|
||||
static void qobject_input_type_null(Visitor *v, const char *name, Error **errp)
|
||||
static void qobject_input_type_null(Visitor *v, const char *name,
|
||||
QNull **obj, Error **errp)
|
||||
{
|
||||
QObjectInputVisitor *qiv = to_qiv(v);
|
||||
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
|
||||
|
||||
*obj = NULL;
|
||||
if (!qobj) {
|
||||
return;
|
||||
}
|
||||
|
@ -599,7 +601,9 @@ static void qobject_input_type_null(Visitor *v, const char *name, Error **errp)
|
|||
if (qobject_type(qobj) != QTYPE_QNULL) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
|
||||
full_name(qiv, name), "null");
|
||||
return;
|
||||
}
|
||||
*obj = qnull();
|
||||
}
|
||||
|
||||
static void qobject_input_type_size_keyval(Visitor *v, const char *name,
|
||||
|
|
|
@ -187,7 +187,8 @@ static void qobject_output_type_any(Visitor *v, const char *name,
|
|||
qobject_output_add_obj(qov, name, *obj);
|
||||
}
|
||||
|
||||
static void qobject_output_type_null(Visitor *v, const char *name, Error **errp)
|
||||
static void qobject_output_type_null(Visitor *v, const char *name,
|
||||
QNull **obj, Error **errp)
|
||||
{
|
||||
QObjectOutputVisitor *qov = to_qov(v);
|
||||
qobject_output_add(qov, name, qnull());
|
||||
|
|
|
@ -326,14 +326,20 @@ static void parse_type_number(Visitor *v, const char *name, double *obj,
|
|||
*obj = val;
|
||||
}
|
||||
|
||||
static void parse_type_null(Visitor *v, const char *name, Error **errp)
|
||||
static void parse_type_null(Visitor *v, const char *name, QNull **obj,
|
||||
Error **errp)
|
||||
{
|
||||
StringInputVisitor *siv = to_siv(v);
|
||||
|
||||
*obj = NULL;
|
||||
|
||||
if (!siv->string || siv->string[0]) {
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
|
||||
"null");
|
||||
return;
|
||||
}
|
||||
|
||||
*obj = qnull();
|
||||
}
|
||||
|
||||
static void string_input_free(Visitor *v)
|
||||
|
|
|
@ -256,7 +256,8 @@ static void print_type_number(Visitor *v, const char *name, double *obj,
|
|||
string_output_set(sov, g_strdup_printf("%f", *obj));
|
||||
}
|
||||
|
||||
static void print_type_null(Visitor *v, const char *name, Error **errp)
|
||||
static void print_type_null(Visitor *v, const char *name, QNull **obj,
|
||||
Error **errp)
|
||||
{
|
||||
StringOutputVisitor *sov = to_sov(v);
|
||||
char *out;
|
||||
|
|
|
@ -31,4 +31,4 @@ visit_type_bool(void *v, const char *name, bool *obj) "v=%p name=%s obj=%p"
|
|||
visit_type_str(void *v, const char *name, char **obj) "v=%p name=%s obj=%p"
|
||||
visit_type_number(void *v, const char *name, double *obj) "v=%p name=%s obj=%p"
|
||||
visit_type_any(void *v, const char *name, void *obj) "v=%p name=%s obj=%p"
|
||||
visit_type_null(void *v, const char *name) "v=%p name=%s"
|
||||
visit_type_null(void *v, const char *name, void *obj) "v=%p name=%s obj=%p"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue