Received: from eggs.gnu.org ([208.118.235.92]:60060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDFuN-0006ys-VE for qemu-devel@nongnu.org; Wed, 06 Mar 2013 10:05:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UDFuI-0000r9-5j for qemu-devel@nongnu.org; Wed, 06 Mar 2013 10:05:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:31384) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDFuH-0000qv-SY for qemu-devel@nongnu.org; Wed, 06 Mar 2013 10:05:26 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r26F5PvW007193 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 6 Mar 2013 10:05:25 -0500 From: Markus Armbruster References: <1362566886-14073-1-git-send-email-kwolf@redhat.com> <513722BD.6010503@redhat.com> <20130306111126.GA2285@dhcp-200-207.str.redhat.com> Date: Wed, 06 Mar 2013 16:05:24 +0100 In-Reply-To: <20130306111126.GA2285@dhcp-200-207.str.redhat.com> (Kevin Wolf's message of "Wed, 6 Mar 2013 12:11:26 +0100") Message-ID: <871ubsbmbv.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] qemu-sockets: Fix assertion failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Paolo Bonzini , qemu-devel@nongnu.org Kevin Wolf writes: > Am 06.03.2013 um 12:04 hat Paolo Bonzini geschrieben: >> Il 06/03/2013 11:48, Kevin Wolf ha scritto: >> > inet_connect_opts() tries all possible addrinfos returned by >> > getaddrinfo(). If one fails with an error, the next one is tried. In >> > this case, the Error should be discarded because the whole operation is >> > successful if another addrinfo from the list succeeds; and if it >> > doesn't, setting an already set Error will trigger an assertion failure. >> > >> > Signed-off-by: Kevin Wolf >> > --- >> > util/qemu-sockets.c | 8 ++++++++ >> > 1 file changed, 8 insertions(+) >> > >> > diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c >> > index 1350ccc..32e609a 100644 >> > --- a/util/qemu-sockets.c >> > +++ b/util/qemu-sockets.c >> > @@ -373,6 +373,14 @@ int inet_connect_opts(QemuOpts *opts, Error **errp, >> > } >> > >> > for (e = res; e != NULL; e = e->ai_next) { >> > + >> > + /* Overwriting errors isn't allowed, so clear any error that may have >> > + * occured in the previous iteration */ >> > + if (error_is_set(errp)) { >> > + error_free(*errp); >> > + *errp = NULL; >> > + } >> > + >> > if (connect_state != NULL) { >> > connect_state->current_addr = e; >> > } >> > >> >> Should we also do nothing if errp is not NULL on entry? > > We could assert(!error_is_set(errp)) if we wanted. As soon as you've got > an Error, you must return instead of calling more functions with the > same error pointer. I wouldn't bother asserting this just here. It's a pervasive issue. We already got an assert() that covers actual error overwrites, in error_set().