[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v10 11/25] qapi: Track all failures between visit_st
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v10 11/25] qapi: Track all failures between visit_start/stop |
Date: |
Fri, 29 Jan 2016 06:48:47 -0700 |
Inside the generated code between visit_start_struct() and
visit_end_struct(), we were blindly setting the error into
the caller's errp parameter. But a future patch to split
visit_end_struct() will require that we take action based
on whether an error has occurred, which requires us to track
all actions through a local err. Rewrite the visits to be
more in line with the other generated calls.
Generated code changes look like:
| visit_start_struct(v, (void **)obj, "Abort", name, sizeof(Abort), &err);
|- if (!err) {
|- if (*obj) {
|- visit_type_Abort_fields(v, obj, errp);
|- }
|- visit_end_struct(v, &err);
|+ if (err) {
|+ goto out;
| }
|+ if (!*obj) {
|+ goto out_obj;
|+ }
|+ visit_type_Abort_fields(v, obj, &err);
|+ error_propagate(errp, err);
|+ err = NULL;
|+out_obj:
|+ visit_end_struct(v, &err);
|+out:
| error_propagate(errp, err);
| }
Signed-off-by: Eric Blake <address@hidden>
---
v10: enhance commit message, move out_obj label and drop R-b
v9: enhance commit message
v8: no change
v7: place earlier in series
v6: based loosely on v5 7/46, but mostly a rewrite to get the last
generated code in the same form as all the others, so that the
later conversion to split visit_check_struct() will be easier
---
scripts/qapi-visit.py | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index b93690b..ec16e36 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -2,7 +2,7 @@
# QAPI visitor generator
#
# Copyright IBM, Corp. 2011
-# Copyright (C) 2014-2015 Red Hat, Inc.
+# Copyright (C) 2014-2016 Red Hat, Inc.
#
# Authors:
# Anthony Liguori <address@hidden>
@@ -123,12 +123,18 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj,
const char *name, Error
Error *err = NULL;
visit_start_struct(v, (void **)obj, "%(name)s", name, sizeof(%(c_name)s),
&err);
- if (!err) {
- if (*obj) {
- visit_type_%(c_name)s_fields(v, obj, errp);
- }
- visit_end_struct(v, &err);
+ if (err) {
+ goto out;
}
+ if (!*obj) {
+ goto out_obj;
+ }
+ visit_type_%(c_name)s_fields(v, obj, &err);
+ error_propagate(errp, err);
+ err = NULL;
+out_obj:
+ visit_end_struct(v, &err);
+out:
error_propagate(errp, err);
}
''',
--
2.5.0
- [Qemu-devel] [PATCH v10 00/25] qapi visitor cleanups part 1 (post-introspection cleanups subset E), Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 04/25] qapi: Dealloc visitor does not need a type_size(), Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 07/25] hmp: Cache use of qapi visitor, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 01/25] qobject: Document more shortcomings in our number handling, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 05/25] qapi: Drop dead parameter in gen_params(), Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 08/25] vl: Ensure qapi visitor properly ends struct visit, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 11/25] qapi: Track all failures between visit_start/stop,
Eric Blake <=
- [Qemu-devel] [PATCH v10 03/25] qapi: Drop dead dealloc visitor variable, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 13/25] qapi: Prefer type_int64 over type_int in visitors, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 14/25] qapi: Make all visitors supply uint64 callbacks, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 06/25] hmp: Drop pointless allocation during qapi visit, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 09/25] balloon: Improve use of qapi visitor, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 16/25] qapi: Don't cast Enum* to int*, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 02/25] qapi: Avoid use of misnamed DO_UPCAST(), Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 17/25] qom: Use typedef for Visitor, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 25/25] qmp: Don't abuse stack to track qmp-output root, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 15/25] qapi: Consolidate visitor small integer callbacks, Eric Blake, 2016/01/29