From: Eric Blake <eblake@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, aliguori@amazon.com
Subject: Re: [Qemu-devel] [PATCH 2/2] vl.c: reduce exit on error code duplication
Date: Wed, 15 Oct 2014 08:35:53 -0600 [thread overview]
Message-ID: <543E8649.7050006@redhat.com> (raw)
In-Reply-To: <1413371003-43597-3-git-send-email-imammedo@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1782 bytes --]
On 10/15/2014 05:03 AM, Igor Mammedov wrote:
> use exit_if_error() helper instead of a bunch of
> if (local_err) {
> error_report(foo);
> error_free(local_err);
> exit(1);
> }
> code blocks
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> vl.c | 58 ++++++++++++++++++++++++++++++----------------------------
> 1 file changed, 30 insertions(+), 28 deletions(-)
Not much net change, but I like the refactoring.
> static int default_driver_check(QemuOpts *opts, void *opaque)
> {
> const char *driver = qemu_opt_get(opts, "driver");
> @@ -2380,11 +2404,7 @@ static int chardev_init_func(QemuOpts *opts, void *opaque)
> Error *local_err = NULL;
>
> qemu_chr_new_from_opts(opts, NULL, &local_err);
> - if (local_err) {
> - error_report("%s", error_get_pretty(local_err));
> - error_free(local_err);
> - return -1;
> - }
> + exit_if_error(local_err, NULL);
> return 0;
> }
Idea for followup patch: this function now always returns 0 (if it
returns at all); therefore, change its signature to void and simplify
further.
>
> @@ -2790,12 +2810,7 @@ static int machine_set_property(const char *name, const char *value,
> string_input_visitor_cleanup(siv);
> g_free(qom_name);
>
> - if (local_err) {
> - qerror_report_err(local_err);
> - error_free(local_err);
> - return -1;
> - }
> -
> + exit_if_error(local_err, NULL);
> return 0;
> }
Same idea for simplification.
But as that should be a separate patch, this one is:
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
next prev parent reply other threads:[~2014-10-15 14:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-15 11:03 [Qemu-devel] [PATCH 0/2] vl.c: unify exit on error handling Igor Mammedov
2014-10-15 11:03 ` [Qemu-devel] [PATCH 1/2] vl.c: use single local_err throughout main() Igor Mammedov
2014-10-15 14:29 ` Eric Blake
2014-10-15 11:03 ` [Qemu-devel] [PATCH 2/2] vl.c: reduce exit on error code duplication Igor Mammedov
2014-10-15 14:35 ` Eric Blake [this message]
2014-10-20 9:37 ` Igor Mammedov
2014-10-20 8:38 ` Markus Armbruster
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=543E8649.7050006@redhat.com \
--to=eblake@redhat.com \
--cc=aliguori@amazon.com \
--cc=imammedo@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.