From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCmtq-0003Tl-LA for qemu-devel@nongnu.org; Mon, 10 Feb 2014 04:11:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCmtk-00086U-K6 for qemu-devel@nongnu.org; Mon, 10 Feb 2014 04:11:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:10598) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCmtk-00086M-Bh for qemu-devel@nongnu.org; Mon, 10 Feb 2014 04:11:28 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1A9BMSv007205 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 10 Feb 2014 04:11:26 -0500 Date: Mon, 10 Feb 2014 17:11:29 +0800 From: Fam Zheng Message-ID: <20140210091129.GA1147@T430.nay.redhat.com> References: <1391939335-31580-1-git-send-email-pbonzini@redhat.com> <1391939335-31580-3-git-send-email-pbonzini@redhat.com> <20140210073807.GD15707@T430.nay.redhat.com> <52F88CA3.7010207@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52F88CA3.7010207@redhat.com> Subject: Re: [Qemu-devel] [PATCH 02/20] nbd: correctly propagate errors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, mreitz@redhat.com On Mon, 02/10 09:24, Paolo Bonzini wrote: > Il 10/02/2014 08:38, Fam Zheng ha scritto: > >>> if (s->client.is_unix) { > >>> - sock = unix_socket_outgoing(qemu_opt_get(s->socket_opts, "path")); > >>> + sock = unix_connect(qemu_opt_get(s->socket_opts, "path"), errp); > >Why not use unix_connect_opts like below? > > Right! > > >>> } else { > >>> - sock = tcp_socket_outgoing_opts(s->socket_opts); > >>> + sock = inet_connect_opts(s->socket_opts, errp, NULL, NULL); > >>> if (sock >= 0) { > >>> socket_set_nodelay(sock); > >>> } > >>> @@ -255,17 +251,19 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, > >>> BDRVNBDState *s = bs->opaque; > >>> char *export = NULL; > >>> int result, sock; > >>> + Error *local_err = NULL; > >>> > >>> /* Pop the config into our state object. Exit if invalid. */ > >>> - result = nbd_config(s, options, &export); > >>> - if (result != 0) { > >>> - return result; > >>> + nbd_config(s, options, &export, &local_err); > >>> + if (local_err) { > >Isn't error_is_set() better here? > > No, error_is_set(&foo) is the same as foo != NULL. > > So we use error_is_set only with Error**, which really should never happen > because you miss errors if the errp is NULL. :) > Clear! Thanks for the explanation! Fam