From patchwork Thu Jun 9 16:48:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 633023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rQWdB6ySmz9sBl for ; Fri, 10 Jun 2016 02:55:10 +1000 (AEST) Received: from localhost ([::1]:35827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bB3Ea-0000m3-7m for incoming@patchwork.ozlabs.org; Thu, 09 Jun 2016 12:55:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bB38i-0003iY-Q4 for qemu-devel@nongnu.org; Thu, 09 Jun 2016 12:49:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bB38d-00023w-4e for qemu-devel@nongnu.org; Thu, 09 Jun 2016 12:49:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37027) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bB38U-0001zs-NY; Thu, 09 Jun 2016 12:48:50 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B1BDC062C93; Thu, 9 Jun 2016 16:48:50 +0000 (UTC) Received: from red.redhat.com (ovpn-116-88.phx2.redhat.com [10.3.116.88]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u59GmmCk016618; Thu, 9 Jun 2016 12:48:49 -0400 From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 9 Jun 2016 10:48:33 -0600 Message-Id: <1465490926-28625-3-git-send-email-eblake@redhat.com> In-Reply-To: <1465490926-28625-1-git-send-email-eblake@redhat.com> References: <1465490926-28625-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 09 Jun 2016 16:48:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v5 02/15] qemu-img: Don't leak errors when outputting JSON X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , armbru@redhat.com, "open list:Block layer core" , Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" If our JSON output ever encounters an error, we would just silently leak the error object. Instead, assert that our usage won't fail. Signed-off-by: Eric Blake --- v5: commit message wording tweak v4: new patch (split out from v3 14/18) --- qemu-img.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 251386b..c4a8647 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -483,12 +483,11 @@ fail: static void dump_json_image_check(ImageCheck *check, bool quiet) { - Error *local_err = NULL; QString *str; QmpOutputVisitor *ov = qmp_output_visitor_new(); QObject *obj; visit_type_ImageCheck(qmp_output_get_visitor(ov), NULL, &check, - &local_err); + &error_abort); obj = qmp_output_get_qobject(ov); str = qobject_to_json_pretty(obj); assert(str != NULL); @@ -2174,12 +2173,11 @@ static void dump_snapshots(BlockDriverState *bs) static void dump_json_image_info_list(ImageInfoList *list) { - Error *local_err = NULL; QString *str; QmpOutputVisitor *ov = qmp_output_visitor_new(); QObject *obj; visit_type_ImageInfoList(qmp_output_get_visitor(ov), NULL, &list, - &local_err); + &error_abort); obj = qmp_output_get_qobject(ov); str = qobject_to_json_pretty(obj); assert(str != NULL); @@ -2191,11 +2189,11 @@ static void dump_json_image_info_list(ImageInfoList *list) static void dump_json_image_info(ImageInfo *info) { - Error *local_err = NULL; QString *str; QmpOutputVisitor *ov = qmp_output_visitor_new(); QObject *obj; - visit_type_ImageInfo(qmp_output_get_visitor(ov), NULL, &info, &local_err); + visit_type_ImageInfo(qmp_output_get_visitor(ov), NULL, &info, + &error_abort); obj = qmp_output_get_qobject(ov); str = qobject_to_json_pretty(obj); assert(str != NULL);