From: Peter Maydell <peter.maydell@linaro.org>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: qemu-trivial@nongnu.org, aliguori@us.ibm.com,
Amos Kong <akong@redhat.com>,
qemu-devel@nongnu.org, quintela@redhat.com
Subject: Re: [Qemu-devel] [Qemu-trivial] [RESEND PATCH 1/3] socket: remove redundant check
Date: Wed, 1 Aug 2012 12:23:02 +0100 [thread overview]
Message-ID: <CAFEAcA9_ATmjm95ottBKtpbaB5uEzOS2KNk19v6_vyngR8ZUKA@mail.gmail.com> (raw)
In-Reply-To: <20120801105011.GC17816@stefanha-thinkpad.localdomain>
On 1 August 2012 11:50, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> This isn't obvious. It looks like the intent of the if (!e->ai_next) is
> to suppress the error so that the next iteration of the *outer* loop can
> succeed.
Yeah, we only call it an error on the last time round. This
loop is a bit confusingly structured, since we're effectively
handling the failure in several places at once: we always
fprintf() something, then we set the error on the last time
round the loop, then at the end of the loop we fprintf again.
We also duplicate the loop termination condition.
It might be better to have an Error *local_err in this function.
Then we could unconditionally call error_set() for any failures,
passing &local_err. Then at the end of the loop we can call
error_propagate(errp, local_err) to pass an error up if we
didn't succeed at all. Unfortunately you'd have to do
if (error_is_set(&local_err)) {
error_free(&local_err);
}
error_set(&local_err, QERR_whatever);
for the error setting, since error_set() will assert if you try
to set an error twice.
[Another demonstration of the fprintf errors being much more
useful than the error_set mechanisms at the moment, incidentally.
We can get away with the fprintfs because the only caller of this
function which passes in a non-NULL errp is the migration code
called from vl.c, which is just going to fprintf and exit on
error anyway.]
-- PMM
next prev parent reply other threads:[~2012-08-01 11:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-17 15:45 [Qemu-devel] [PATCH 0/2] trivial fix of qemu-sockets.c Amos Kong
2012-07-17 15:45 ` [Qemu-devel] [PATCH 1/2] socket: remove redundant check Amos Kong
2012-07-17 15:45 ` [Qemu-devel] [PATCH 2/2] remove unused include of error.h Amos Kong
2012-08-01 8:59 ` [Qemu-devel] [RESEND PATCH 0/3] trivial fix of qemu-sockets.c Amos Kong
2012-08-01 8:59 ` [Qemu-devel] [RESEND PATCH 1/3] socket: remove redundant check Amos Kong
2012-08-01 10:50 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
2012-08-01 11:23 ` Peter Maydell [this message]
2012-08-01 11:50 ` Markus Armbruster
2012-08-01 11:48 ` Markus Armbruster
2012-08-03 2:59 ` Amos Kong
2012-08-01 8:59 ` [Qemu-devel] [RESEND PATCH 2/3] remove unused include of error.h Amos Kong
2012-08-01 8:59 ` [Qemu-devel] [RESEND PATCH 3/3] socket: clean up redundant assignment Amos Kong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFEAcA9_ATmjm95ottBKtpbaB5uEzOS2KNk19v6_vyngR8ZUKA@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=akong@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=quintela@redhat.com \
--cc=stefanha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).