{"id":833272,"url":"http://patchwork.ozlabs.org/api/1.2/patches/833272/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1509617407-21191-2-git-send-email-thuth@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.2/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1509617407-21191-2-git-send-email-thuth@redhat.com>","list_archive_url":null,"date":"2017-11-02T10:10:05","name":"[v3,1/2] qdev_monitor: Simplify error handling in qdev_device_add()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e6406d848ebe4f60d9a306353467176576b3abef","submitter":{"id":66152,"url":"http://patchwork.ozlabs.org/api/1.2/people/66152/?format=json","name":"Thomas Huth","email":"thuth@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1509617407-21191-2-git-send-email-thuth@redhat.com/mbox/","series":[{"id":11465,"url":"http://patchwork.ozlabs.org/api/1.2/series/11465/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=11465","date":"2017-11-02T10:10:05","name":"[v3,1/2] qdev_monitor: Simplify error handling in qdev_device_add()","version":3,"mbox":"http://patchwork.ozlabs.org/series/11465/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/833272/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/833272/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=thuth@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3ySLT03zT7z9t34\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu,  2 Nov 2017 21:10:57 +1100 (AEDT)","from localhost ([::1]:59479 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1eACSc-0000QU-9t\n\tfor incoming@patchwork.ozlabs.org; Thu, 02 Nov 2017 06:10:54 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:41534)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <thuth@redhat.com>) id 1eACS3-0000PN-N7\n\tfor qemu-devel@nongnu.org; Thu, 02 Nov 2017 06:10:20 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <thuth@redhat.com>) id 1eACRz-0002dy-RV\n\tfor qemu-devel@nongnu.org; Thu, 02 Nov 2017 06:10:19 -0400","from mx1.redhat.com ([209.132.183.28]:40014)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <thuth@redhat.com>) id 1eACRz-0002cD-Le\n\tfor qemu-devel@nongnu.org; Thu, 02 Nov 2017 06:10:15 -0400","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id D26BF81E1A\n\tfor <qemu-devel@nongnu.org>; Thu,  2 Nov 2017 10:10:14 +0000 (UTC)","from thh440s.redhat.com (ovpn-116-111.ams2.redhat.com\n\t[10.36.116.111])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id D73A3600C0;\n\tThu,  2 Nov 2017 10:10:12 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com D26BF81E1A","From":"Thomas Huth <thuth@redhat.com>","To":"qemu-devel@nongnu.org, Eduardo Habkost <ehabkost@redhat.com>,\n\tIgor Mammedov <imammedo@redhat.com>,\n\t\"Dr. David Alan Gilbert\" <dgilbert@redhat.com>","Date":"Thu,  2 Nov 2017 11:10:05 +0100","Message-Id":"<1509617407-21191-2-git-send-email-thuth@redhat.com>","In-Reply-To":"<1509617407-21191-1-git-send-email-thuth@redhat.com>","References":"<1509617407-21191-1-git-send-email-thuth@redhat.com>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.11","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.25]);\n\tThu, 02 Nov 2017 10:10:14 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"[Qemu-devel] [PATCH v3 1/2] qdev_monitor: Simplify error handling\n\tin qdev_device_add()","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Paolo Bonzini <pbonzini@redhat.com>,\n\tMarkus Armbruster <armbru@redhat.com>, david@redhat.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"Instead of doing the clean-ups on errors multiple times, introduce\na jump label at the end of the function that can be used by all\nerror paths that need this cleanup.\n\nSuggested-by: Igor Mammedov <imammedo@redhat.com>\nSigned-off-by: Thomas Huth <thuth@redhat.com>\n---\n qdev-monitor.c | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)","diff":"diff --git a/qdev-monitor.c b/qdev-monitor.c\nindex 8fd6df9..9188d20 100644\n--- a/qdev-monitor.c\n+++ b/qdev-monitor.c\n@@ -620,22 +620,22 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)\n \n     /* set properties */\n     if (qemu_opt_foreach(opts, set_property, dev, &err)) {\n-        error_propagate(errp, err);\n-        object_unparent(OBJECT(dev));\n-        object_unref(OBJECT(dev));\n-        return NULL;\n+        goto err_del_dev;\n     }\n \n     dev->opts = opts;\n     object_property_set_bool(OBJECT(dev), true, \"realized\", &err);\n     if (err != NULL) {\n-        error_propagate(errp, err);\n         dev->opts = NULL;\n-        object_unparent(OBJECT(dev));\n-        object_unref(OBJECT(dev));\n-        return NULL;\n+        goto err_del_dev;\n     }\n     return dev;\n+\n+err_del_dev:\n+    error_propagate(errp, err);\n+    object_unparent(OBJECT(dev));\n+    object_unref(OBJECT(dev));\n+    return NULL;\n }\n \n \n","prefixes":["v3","1/2"]}