From patchwork Thu Mar 22 11:51:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 148233 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 04829B6EEF for ; Thu, 22 Mar 2012 23:19:09 +1100 (EST) Received: from localhost ([::1]:44544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAgYw-0004Z8-7M for incoming@patchwork.ozlabs.org; Thu, 22 Mar 2012 07:52:14 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAgYH-0002nj-0N for qemu-devel@nongnu.org; Thu, 22 Mar 2012 07:51:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SAgYA-0004k0-N8 for qemu-devel@nongnu.org; Thu, 22 Mar 2012 07:51:32 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:56196) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAgYA-0004jE-EM for qemu-devel@nongnu.org; Thu, 22 Mar 2012 07:51:26 -0400 Received: by wibhr17 with SMTP id hr17so547967wib.10 for ; Thu, 22 Mar 2012 04:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=5bDCAmP6bF5QYdjTeoP5UbNC4SaweJ6wjPxXdlBguFg=; b=00aMMy1voFMf/VtYFKlgroKhvh3XQtgDEDxlaL1vtyd59arJO5+hi5mJ4oLy7sm5lt UShRMRaMqA+Jr3EYPbujJMFRSIdU4cJk96eUB1FPb/f9VbnXTu227WpsnlCz/w/wMr2J b2MFFWl6jgC1Im0rsDNYnnmQpXw0uu8GUNKbiPBKUNQUzpQTdZr18s+HLW2z+uxeZCLv Y/SNkinpVAwW8/ERnFPPwdq16LIxBuP72vETAc3FWVMmguiUppeogMgvGg5bTFuj+g7I 0PA1hsXls9XH2zIDaH7YpHbwnN9kWNhkI+o7f8YhsaYbu7ssf8viJkB9rd2FSJmrfOly b5PQ== Received: by 10.180.106.9 with SMTP id gq9mr4433989wib.17.1332417083524; Thu, 22 Mar 2012 04:51:23 -0700 (PDT) Received: from yakj.usersys.redhat.com (nat-pool-mxp-t.redhat.com. [209.132.186.18]) by mx.google.com with ESMTPS id k6sm4629912wie.9.2012.03.22.04.51.22 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Mar 2012 04:51:22 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 22 Mar 2012 12:51:06 +0100 Message-Id: <1332417072-20329-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1332417072-20329-1-git-send-email-pbonzini@redhat.com> References: <1332417072-20329-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.212.181 Cc: mdroth@linux.vnet.ibm.com, eblake@redhat.com, anthony@codemonkey.vs, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH 04/10] qapi: shortcut visits on errors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We can exit very soon if we enter a visitor with a preexisting error. This simplifies some cases because we will not have to deal with obj being non-NULL while *obj is NULL. Signed-off-by: Paolo Bonzini Reviewed-by: Anthony Liguori --- scripts/qapi-visit.py | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 54117d4..b242315 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -61,6 +61,9 @@ def generate_visit_struct(name, members): void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **errp) { + if (error_is_set(errp)) { + return; + } visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), errp); ''', name=name) @@ -81,6 +84,9 @@ void visit_type_%(name)sList(Visitor *m, %(name)sList ** obj, const char *name, { GenericList *i, **head = (GenericList **)obj; + if (error_is_set(errp)) { + return; + } visit_start_list(m, name, errp); for (*head = i = visit_next_list(m, head, errp); i; i = visit_next_list(m, &i, errp)) { @@ -112,6 +118,9 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error ** { Error *err = NULL; + if (error_is_set(errp)) { + return; + } visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err); visit_type_%(name)sKind(m, &(*obj)->kind, "type", &err); if (err) {