From nobody Wed May 1 22:13:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1574880177; cv=none; d=zohomail.com; s=zohoarc; b=mUDaPf5S29DFX0jSN5FlpexIjdvHR6mb6NgEzhuI6bYPqy4aUSJbLew0w3kI8HrhSGibBaIdoEy1iLJv5fEFMWAaCHspTzPKyrJPIanRwsvnIip/KK8SqPhNxNGYYeDX/v3Hiramf1f6AaJbHV7Eszfb4jkAiN9YF0XnHDU5BJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574880177; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=uAjKz/jkpkyu3g+S80YruqzRx18h1/m/euiVMmB5RfE=; b=KTRVHswZOiiPMSeM+N8e+EjQjOdyY3bvfY5aAqJwm5TteMYiaSrxWDKXuFcEskdbIeM5DVrKeEvF75/adn+RqoCWbrB5vSsxptNGKGpFCvssCKP9snvIlI5qI5eQPOOMzDs9HAstdgPSprJBG5uJmtIX68997T/O6MTISXHSMRg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574880177753287.90904821225763; Wed, 27 Nov 2019 10:42:57 -0800 (PST) Received: from localhost ([::1]:41739 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia2HA-0003Yh-8Q for importer@patchew.org; Wed, 27 Nov 2019 13:42:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42172) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia2Bg-0007jc-6G for qemu-devel@nongnu.org; Wed, 27 Nov 2019 13:37:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ia2Be-0000C2-Hf for qemu-devel@nongnu.org; Wed, 27 Nov 2019 13:37:15 -0500 Received: from relay.sw.ru ([185.231.240.75]:51034) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ia2Be-0000B8-9F for qemu-devel@nongnu.org; Wed, 27 Nov 2019 13:37:14 -0500 Received: from vovaso.qa.sw.ru ([10.94.3.0] helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1ia2BV-0002k8-1Q; Wed, 27 Nov 2019 21:37:05 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Subject: [PATCH v6] error: rename errp to errp_in where it is IN-argument Date: Wed, 27 Nov 2019 21:37:04 +0300 Message-Id: <20191127183704.14825-1-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vsementsov@virtuozzo.com, mdroth@linux.vnet.ibm.com, armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 instead get Error **errp as IN-argument: it's assumed to be set (or, maybe, NULL), and callee should clean it, or add some information. In such cases, rename errp to errp_in. This patch updates only error API functions. There still a few functions with errp-in semantics, they will be updated in further commits. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- v6: fix s/errp/errp_in/ in comments corresponding to changed functions [Eric] add Eric's r-b include/qapi/error.h | 16 ++++++++-------- util/error.c | 30 +++++++++++++++--------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/qapi/error.h b/include/qapi/error.h index 3f95141a01..df518644fc 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -230,16 +230,16 @@ void error_propagate_prepend(Error **dst_errp, Error = *local_err, const char *fmt, ...); =20 /* - * Prepend some text to @errp's human-readable error message. + * Prepend some text to @errp_in's human-readable error message. * The text is made by formatting @fmt, @ap like vprintf(). */ -void error_vprepend(Error **errp, const char *fmt, va_list ap); +void error_vprepend(Error **errp_in, const char *fmt, va_list ap); =20 /* - * Prepend some text to @errp's human-readable error message. + * Prepend some text to @errp_in's human-readable error message. * The text is made by formatting @fmt, ... like printf(). */ -void error_prepend(Error **errp, const char *fmt, ...) +void error_prepend(Error **errp_in, const char *fmt, ...) GCC_FMT_ATTR(2, 3); =20 /* @@ -250,13 +250,13 @@ void error_prepend(Error **errp, const char *fmt, ...) * Intended use is adding helpful hints on the human user interface, * e.g. a list of valid values. It's not for clarifying a confusing * error message. - * @errp may be NULL, but not &error_fatal or &error_abort. + * @errp_in may be NULL, but not &error_fatal or &error_abort. * Trivially the case if you call it only after error_setg() or * error_propagate(). * May be called multiple times. The resulting hint should end with a * newline. */ -void error_append_hint(Error **errp, const char *fmt, ...) +void error_append_hint(Error **errp_in, const char *fmt, ...) GCC_FMT_ATTR(2, 3); =20 /* @@ -281,9 +281,9 @@ Error *error_copy(const Error *err); void error_free(Error *err); =20 /* - * Convenience function to assert that *@errp is set, then silently free i= t. + * Convenience function to assert that *@errp_in is set, then silently fre= e it. */ -void error_free_or_abort(Error **errp); +void error_free_or_abort(Error **errp_in); =20 /* * Convenience function to warn_report() and free @err. diff --git a/util/error.c b/util/error.c index d4532ce318..275586faa8 100644 --- a/util/error.c +++ b/util/error.c @@ -121,41 +121,41 @@ void error_setg_file_open_internal(Error **errp, "Could not open '%s'", filename); } =20 -void error_vprepend(Error **errp, const char *fmt, va_list ap) +void error_vprepend(Error **errp_in, const char *fmt, va_list ap) { GString *newmsg; =20 - if (!errp) { + if (!errp_in) { return; } =20 newmsg =3D g_string_new(NULL); g_string_vprintf(newmsg, fmt, ap); - g_string_append(newmsg, (*errp)->msg); - g_free((*errp)->msg); - (*errp)->msg =3D g_string_free(newmsg, 0); + g_string_append(newmsg, (*errp_in)->msg); + g_free((*errp_in)->msg); + (*errp_in)->msg =3D g_string_free(newmsg, 0); } =20 -void error_prepend(Error **errp, const char *fmt, ...) +void error_prepend(Error **errp_in, const char *fmt, ...) { va_list ap; =20 va_start(ap, fmt); - error_vprepend(errp, fmt, ap); + error_vprepend(errp_in, fmt, ap); va_end(ap); } =20 -void error_append_hint(Error **errp, const char *fmt, ...) +void error_append_hint(Error **errp_in, const char *fmt, ...) { va_list ap; int saved_errno =3D errno; Error *err; =20 - if (!errp) { + if (!errp_in) { return; } - err =3D *errp; - assert(err && errp !=3D &error_abort && errp !=3D &error_fatal); + err =3D *errp_in; + assert(err && errp_in !=3D &error_abort && errp_in !=3D &error_fatal); =20 if (!err->hint) { err->hint =3D g_string_new(NULL); @@ -271,11 +271,11 @@ void error_free(Error *err) } } =20 -void error_free_or_abort(Error **errp) +void error_free_or_abort(Error **errp_in) { - assert(errp && *errp); - error_free(*errp); - *errp =3D NULL; + assert(errp_in && *errp_in); + error_free(*errp_in); + *errp_in =3D NULL; } =20 void error_propagate(Error **dst_errp, Error *local_err) --=20 2.21.0