From patchwork Mon Sep 23 16:12:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 11157367 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0425D912 for ; Mon, 23 Sep 2019 17:18:06 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD03C20820 for ; Mon, 23 Sep 2019 17:18:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD03C20820 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCRwd-0006Jf-Rh; Mon, 23 Sep 2019 17:16:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCQz7-0000v9-2b for xen-devel@lists.xenproject.org; Mon, 23 Sep 2019 16:14:45 +0000 X-Inumbo-ID: 3b4c1298-de1d-11e9-978d-bc764e2007e4 Received: from relay.sw.ru (unknown [185.231.240.75]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3b4c1298-de1d-11e9-978d-bc764e2007e4; Mon, 23 Sep 2019 16:14:34 +0000 (UTC) Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.2) (envelope-from ) id 1iCQwz-0001Fp-8w; Mon, 23 Sep 2019 19:12:33 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Date: Mon, 23 Sep 2019 19:12:25 +0300 Message-Id: <20190923161231.22028-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190923161231.22028-1-vsementsov@virtuozzo.com> References: <20190923161231.22028-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 23 Sep 2019 17:16:12 +0000 Subject: [Xen-devel] [RFC v2 3/9] errp: rename errp to errp_in where it is IN-argument X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: stefanha@redhat.com, codyprime@gmail.com, jan.kiszka@siemens.com, eblake@redhat.com, berto@igalia.com, zhang.zhanghailiang@huawei.com, qemu-block@nongnu.org, arikalo@wavecomp.com, pasic@linux.ibm.com, hpoussin@reactos.org, anthony.perard@citrix.com, samuel.thibault@ens-lyon.org, philmd@redhat.com, green@moxielogic.com, lvivier@redhat.com, ehabkost@redhat.com, xiechanglong.d@gmail.com, pl@kamp.de, dgilbert@redhat.com, b.galvani@gmail.com, eric.auger@redhat.com, alex.williamson@redhat.com, ronniesahlberg@gmail.com, jsnow@redhat.com, rth@twiddle.net, kwolf@redhat.com, vsementsov@virtuozzo.com, andrew@aj.id.au, crwulff@gmail.com, sundeep.lkml@gmail.com, michael@walle.cc, qemu-ppc@nongnu.org, kbastian@mail.uni-paderborn.de, imammedo@redhat.com, fam@euphon.net, peter.maydell@linaro.org, sheepdog@lists.wpkg.org, david@redhat.com, palmer@sifive.com, thuth@redhat.com, jcmvbkbc@gmail.com, den@openvz.org, hare@suse.com, sstabellini@kernel.org, arei.gonglei@huawei.com, marcel.apfelbaum@gmail.com, namei.unix@gmail.com, atar4qemu@gmail.com, farman@linux.ibm.com, amit@kernel.org, sw@weilnetz.de, groug@kaod.org, qemu-s390x@nongnu.org, qemu-arm@nongnu.org, peter.chubb@nicta.com.au, clg@kaod.org, shorne@gmail.com, qemu-riscv@nongnu.org, cohuck@redhat.com, amarkovic@wavecomp.com, aurelien@aurel32.net, pburton@wavecomp.com, sagark@eecs.berkeley.edu, jasowang@redhat.com, kraxel@redhat.com, edgar.iglesias@gmail.com, gxt@mprc.pku.edu.cn, ari@tuxera.com, quintela@redhat.com, mdroth@linux.vnet.ibm.com, lersek@redhat.com, borntraeger@de.ibm.com, antonynpavlov@gmail.com, dillaman@redhat.com, joel@jms.id.au, xen-devel@lists.xenproject.org, integration@gluster.org, balrogg@gmail.com, rjones@redhat.com, Andrew.Baumann@microsoft.com, mreitz@redhat.com, walling@linux.ibm.com, mst@redhat.com, mark.cave-ayland@ilande.co.uk, v.maffione@gmail.com, marex@denx.de, armbru@redhat.com, marcandre.lureau@redhat.com, alistair@alistair23.me, paul.durrant@citrix.com, pavel.dovgaluk@ispras.ru, g.lettieri@iet.unipi.it, rizzo@iet.unipi.it, david@gibson.dropbear.id.au, akrowiak@linux.ibm.com, berrange@redhat.com, xiaoguangrong.eric@gmail.com, pmorel@linux.ibm.com, wencongyang2@huawei.com, jcd@tribudubois.net, pbonzini@redhat.com, stefanb@linux.ibm.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Error **errp is almost always OUT-argument: it's assumed to be NULL, or pointer to NULL-initialized pointer, or pointer to error_abort or error_fatal, for callee to report error. But very few functions (most of the are error API) instead get Error **errp as IN-argument: it's assumed to be set, and callee should clean it. In such cases, rename errp to errp_in. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- include/monitor/hmp.h | 2 +- include/qapi/error.h | 8 ++++---- ui/vnc.h | 2 +- monitor/hmp-cmds.c | 8 ++++---- ui/vnc.c | 10 +++++----- util/error.c | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index a0e9511440..f929814f1a 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -16,7 +16,7 @@ #include "qemu/readline.h" -void hmp_handle_error(Monitor *mon, Error **errp); +void hmp_handle_error(Monitor *mon, Error **errp_in); void hmp_info_name(Monitor *mon, const QDict *qdict); void hmp_info_version(Monitor *mon, const QDict *qdict); diff --git a/include/qapi/error.h b/include/qapi/error.h index 551385aa91..4264d22223 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -283,7 +283,7 @@ void error_free(Error *err); /* * Convenience function to assert that *@errp is set, then silently free it. */ -void error_free_or_abort(Error **errp); +void error_free_or_abort(Error **errp_in); /* * Convenience function to warn_report() and free @err. @@ -301,19 +301,19 @@ void error_report_err(Error *err); * Functions to clean Error **errp: call corresponding Error *err cleaning * function an set pointer to NULL */ -static inline void error_free_errp(Error **errp) +static inline void error_free_errp(Error **errp_in) { error_free(*errp_in); *errp_in = NULL; } -static inline void error_report_errp(Error **errp) +static inline void error_report_errp(Error **errp_in) { error_report_err(*errp_in); *errp_in = NULL; } -static inline void warn_report_errp(Error **errp) +static inline void warn_report_errp(Error **errp_in) { warn_report_err(*errp_in); *errp_in = NULL; diff --git a/ui/vnc.h b/ui/vnc.h index fea79c2fc9..00e0b48f2f 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -547,7 +547,7 @@ uint32_t read_u32(uint8_t *data, size_t offset); /* Protocol stage functions */ void vnc_client_error(VncState *vs); -size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp); +size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp_in); void start_client_init(VncState *vs); void start_auth_vnc(VncState *vs); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index b2551c16d1..941d5d0a45 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -60,11 +60,11 @@ #include #endif -void hmp_handle_error(Monitor *mon, Error **errp) +void hmp_handle_error(Monitor *mon, Error **errp_in) { - assert(errp); - if (*errp) { - error_reportf_err(*errp, "Error: "); + assert(errp_in); + if (*errp_in) { + error_reportf_err(*errp_in, "Error: "); } } diff --git a/ui/vnc.c b/ui/vnc.c index 87b8045afe..9d6384d9b1 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1312,7 +1312,7 @@ void vnc_disconnect_finish(VncState *vs) g_free(vs); } -size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp) +size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp_in) { if (ret <= 0) { if (ret == 0) { @@ -1320,14 +1320,14 @@ size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp) vnc_disconnect_start(vs); } else if (ret != QIO_CHANNEL_ERR_BLOCK) { trace_vnc_client_io_error(vs, vs->ioc, - errp ? error_get_pretty(*errp) : + errp_in ? error_get_pretty(*errp_in) : "Unknown"); vnc_disconnect_start(vs); } - if (errp) { - error_free(*errp); - *errp = NULL; + if (errp_in) { + error_free(*errp_in); + *errp_in = NULL; } return 0; } diff --git a/util/error.c b/util/error.c index dfba091757..b3ff3832d6 100644 --- a/util/error.c +++ b/util/error.c @@ -271,7 +271,7 @@ void error_free(Error *err) } } -void error_free_or_abort(Error **errp) +void error_free_or_abort(Error **errp_in) { assert(errp_in && *errp_in); error_free(*errp_in);