aboutsummaryrefslogtreecommitdiff
path: root/qapi/qapi-clone-visitor.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-07-07 18:05:45 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-07-10 15:18:08 +0200
commit012d4c96e260f99d5ca95cd033274af4fb73b825 (patch)
treecae388bc5db572e4462147479e7a98e33d162fbe /qapi/qapi-clone-visitor.c
parent3c4b89c3b209978f13bcb7ab4d375b81b6fdad99 (diff)
qapi: Make visitor functions taking Error ** return bool, not void
See recent commit "error: Document Error API usage rules" for rationale. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20200707160613.848843-18-armbru@redhat.com>
Diffstat (limited to 'qapi/qapi-clone-visitor.c')
-rw-r--r--qapi/qapi-clone-visitor.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/qapi/qapi-clone-visitor.c b/qapi/qapi-clone-visitor.c
index daab6819b4..c45c5caa3b 100644
--- a/qapi/qapi-clone-visitor.c
+++ b/qapi/qapi-clone-visitor.c
@@ -24,7 +24,7 @@ static QapiCloneVisitor *to_qcv(Visitor *v)
return container_of(v, QapiCloneVisitor, visitor);
}
-static void qapi_clone_start_struct(Visitor *v, const char *name, void **obj,
+static bool qapi_clone_start_struct(Visitor *v, const char *name, void **obj,
size_t size, Error **errp)
{
QapiCloneVisitor *qcv = to_qcv(v);
@@ -34,11 +34,12 @@ static void qapi_clone_start_struct(Visitor *v, const char *name, void **obj,
/* Only possible when visiting an alternate's object
* branch. Nothing further to do here, since the earlier
* visit_start_alternate() already copied memory. */
- return;
+ return true;
}
*obj = g_memdup(*obj, size);
qcv->depth++;
+ return true;
}
static void qapi_clone_end(Visitor *v, void **obj)
@@ -51,11 +52,11 @@ static void qapi_clone_end(Visitor *v, void **obj)
}
}
-static void qapi_clone_start_list(Visitor *v, const char *name,
+static bool qapi_clone_start_list(Visitor *v, const char *name,
GenericList **listp, size_t size,
Error **errp)
{
- qapi_clone_start_struct(v, name, (void **)listp, size, errp);
+ return qapi_clone_start_struct(v, name, (void **)listp, size, errp);
}
static GenericList *qapi_clone_next_list(Visitor *v, GenericList *tail,
@@ -69,42 +70,45 @@ static GenericList *qapi_clone_next_list(Visitor *v, GenericList *tail,
return tail->next;
}
-static void qapi_clone_start_alternate(Visitor *v, const char *name,
+static bool qapi_clone_start_alternate(Visitor *v, const char *name,
GenericAlternate **obj, size_t size,
Error **errp)
{
- qapi_clone_start_struct(v, name, (void **)obj, size, errp);
+ return qapi_clone_start_struct(v, name, (void **)obj, size, errp);
}
-static void qapi_clone_type_int64(Visitor *v, const char *name, int64_t *obj,
- Error **errp)
+static bool qapi_clone_type_int64(Visitor *v, const char *name, int64_t *obj,
+ Error **errp)
{
QapiCloneVisitor *qcv = to_qcv(v);
assert(qcv->depth);
/* Value was already cloned by g_memdup() */
+ return true;
}
-static void qapi_clone_type_uint64(Visitor *v, const char *name,
- uint64_t *obj, Error **errp)
+static bool qapi_clone_type_uint64(Visitor *v, const char *name,
+ uint64_t *obj, Error **errp)
{
QapiCloneVisitor *qcv = to_qcv(v);
assert(qcv->depth);
/* Value was already cloned by g_memdup() */
+ return true;
}
-static void qapi_clone_type_bool(Visitor *v, const char *name, bool *obj,
- Error **errp)
+static bool qapi_clone_type_bool(Visitor *v, const char *name, bool *obj,
+ Error **errp)
{
QapiCloneVisitor *qcv = to_qcv(v);
assert(qcv->depth);
/* Value was already cloned by g_memdup() */
+ return true;
}
-static void qapi_clone_type_str(Visitor *v, const char *name, char **obj,
- Error **errp)
+static bool qapi_clone_type_str(Visitor *v, const char *name, char **obj,
+ Error **errp)
{
QapiCloneVisitor *qcv = to_qcv(v);
@@ -117,24 +121,27 @@ static void qapi_clone_type_str(Visitor *v, const char *name, char **obj,
* string is intended.
*/
*obj = g_strdup(*obj ?: "");
+ return true;
}
-static void qapi_clone_type_number(Visitor *v, const char *name, double *obj,
- Error **errp)
+static bool qapi_clone_type_number(Visitor *v, const char *name, double *obj,
+ Error **errp)
{
QapiCloneVisitor *qcv = to_qcv(v);
assert(qcv->depth);
/* Value was already cloned by g_memdup() */
+ return true;
}
-static void qapi_clone_type_null(Visitor *v, const char *name, QNull **obj,
+static bool qapi_clone_type_null(Visitor *v, const char *name, QNull **obj,
Error **errp)
{
QapiCloneVisitor *qcv = to_qcv(v);
assert(qcv->depth);
*obj = qnull();
+ return true;
}
static void qapi_clone_free(Visitor *v)
@@ -167,7 +174,7 @@ static Visitor *qapi_clone_visitor_new(void)
return &v->visitor;
}
-void *qapi_clone(const void *src, void (*visit_type)(Visitor *, const char *,
+void *qapi_clone(const void *src, bool (*visit_type)(Visitor *, const char *,
void **, Error **))
{
Visitor *v;
@@ -184,7 +191,7 @@ void *qapi_clone(const void *src, void (*visit_type)(Visitor *, const char *,
}
void qapi_clone_members(void *dst, const void *src, size_t sz,
- void (*visit_type_members)(Visitor *, void *,
+ bool (*visit_type_members)(Visitor *, void *,
Error **))
{
Visitor *v;