From d195325b05199038b5907fa791729425b9720d21 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 17 Jul 2012 16:17:04 +0200 Subject: qapi: fix error propagation Don't overwrite / leak previously set errors. Make traversal cope with missing mandatory sub-structs. Don't try to end a container that could not be started. v1->v2: - unchanged v2->v3: - instead of examining, assert that we never overwrite errors with error_set() - allow visitors to set a NULL struct pointer successfully, so traversal of incomplete objects can continue - check for a NULL "obj" before accessing "(*obj)->has_XXX" (this is not a typo, "obj != NULL" implies "*obj != NULL" here) - fix start_struct / end_struct balance for unions as well Signed-off-by: Paolo Bonzini Signed-off-by: Laszlo Ersek Signed-off-by: Stefan Hajnoczi --- docs/qapi-code-gen.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs/qapi-code-gen.txt') diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt index ad11767a2f..cccb11e562 100644 --- a/docs/qapi-code-gen.txt +++ b/docs/qapi-code-gen.txt @@ -220,6 +220,8 @@ Example: #endif mdroth@illuin:~/w/qemu2.git$ +(The actual structure of the visit_type_* functions is a bit more complex +in order to propagate errors correctly and avoid leaking memory). === scripts/qapi-commands.py === -- cgit v1.2.1