From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZleVt-000248-6C for qemu-devel@nongnu.org; Mon, 12 Oct 2015 10:55:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZleVn-0005eY-Qg for qemu-devel@nongnu.org; Mon, 12 Oct 2015 10:55:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58230) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZleVn-0005eD-7u for qemu-devel@nongnu.org; Mon, 12 Oct 2015 10:55:39 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id BC3F4C0C9A68 for ; Mon, 12 Oct 2015 14:55:38 +0000 (UTC) References: <1444637004-20195-1-git-send-email-pbonzini@redhat.com> <1444637004-20195-2-git-send-email-pbonzini@redhat.com> From: Eric Blake Message-ID: <561BC9E4.4080004@redhat.com> Date: Mon, 12 Oct 2015 08:55:32 -0600 MIME-Version: 1.0 In-Reply-To: <1444637004-20195-2-git-send-email-pbonzini@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="V2duDC5BSIKjHuKd1DxG0PrxDFhGwnPAk" Subject: Re: [Qemu-devel] [PATCH 01/21] qemu-char: cleanup qmp_chardev_add List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: armbru@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --V2duDC5BSIKjHuKd1DxG0PrxDFhGwnPAk Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/12/2015 02:03 AM, Paolo Bonzini wrote: > Use the usual idioms for error propagation. >=20 > Signed-off-by: Paolo Bonzini > --- > qemu-char.c | 56 +++++++++++++++++++++++++++++++----------------------= --- > 1 file changed, 31 insertions(+), 25 deletions(-) >=20 > diff --git a/qemu-char.c b/qemu-char.c > index 653ea10..f51c0aa 100644 > --- a/qemu-char.c > +++ b/qemu-char.c > @@ -4214,6 +4214,7 @@ ChardevReturn *qmp_chardev_add(const char *id, Ch= ardevBackend *backend, > { > ChardevReturn *ret =3D g_new0(ChardevReturn, 1); > CharDriverState *base, *chr =3D NULL; > + Error *local_err =3D NULL; It's a toss-up on whether 'local_err' or 'err' is the preferred name for the local variable. I'm fine with either. > @@ -4303,25 +4304,30 @@ ChardevReturn *qmp_chardev_add(const char *id, = ChardevBackend *backend, > * error then. > * TODO full conversion to Error API > */ > - if (chr =3D=3D NULL && errp && !*errp) { > - error_setg(errp, "Failed to create chardev"); > - } > - if (chr) { > - chr->label =3D g_strdup(id); > - chr->avail_connections =3D > - (backend->kind =3D=3D CHARDEV_BACKEND_KIND_MUX) ? MAX_MUX = : 1; > - if (!chr->filename) { > - chr->filename =3D g_strdup(ChardevBackendKind_lookup[backe= nd->kind]); > - } > - if (!chr->explicit_be_open) { > - qemu_chr_be_event(chr, CHR_EVENT_OPENED); > + if (chr =3D=3D NULL) { I might write this as if (!chr), but that's cosmetic. Conversion looks sane. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --V2duDC5BSIKjHuKd1DxG0PrxDFhGwnPAk Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWG8nqAAoJEKeha0olJ0NqMGAH/0sReMQOxFqe8SsR0j7NVbay 1PqSx7RwqgmEuK+Pzq8BtMzg+JcMxbX8C5tOFqlxR3r8u6z9z6VFgjyiYPba0QZr flB5+JZIaS1+ojF/iIxlWZeO9lkFPAmMtPzyJoD1Hc66+K8Y6odbGYq5hxlUbrK3 Vz2m5ssJNCObdkx7Zv3fNU51MrCtAzRzfOJzfj0RLk02msd9qXsbI0ty1mxXGE0x ft4xOOBXPG9EwpzqszvcLHAzKH/XwzvSvIS7bR58m8m8spPKIT9IymsMvJFTbSGK yzKpvimzvAQRTGkNz6aibM9q5almvU0n6aEAuQYezkodBo/aWSumnzwwSwdQ4kQ= =sP/O -----END PGP SIGNATURE----- --V2duDC5BSIKjHuKd1DxG0PrxDFhGwnPAk--