All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: "Denis V. Lunev" <den@openvz.org>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
	Paolo Bonzini <pbonzini@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 3/7] trace: move qemu_trace_opts to trace/control.c
Date: Fri, 17 Jun 2016 14:48:22 +0100	[thread overview]
Message-ID: <20160617134822.GE28550@stefanha-x1.localdomain> (raw)
In-Reply-To: <1466061312-7373-4-git-send-email-den@openvz.org>

[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]

On Thu, Jun 16, 2016 at 10:15:08AM +0300, Denis V. Lunev wrote:
> +/**
> + * Definition of QEMU options describing trace subsystem configuration
> + */
> +extern QemuOptsList qemu_trace_opts;
> +
> +/**
> + * trace_opt_parse:
> + * @optarg: A string argument of --trace command line argument
> + * @trace_file: current filename to save traces to
> + *
> + * Initialize tracing subsystem.

+Returns the filename to save trace to.  It must be freed with g_free().

> @@ -3867,23 +3847,8 @@ int main(int argc, char **argv, char **envp)
>                  xen_mode = XEN_ATTACH;
>                  break;
>              case QEMU_OPTION_trace:
> -            {
> -                opts = qemu_opts_parse_noisily(qemu_find_opts("trace"),
> -                                               optarg, true);
> -                if (!opts) {
> -                    exit(1);
> -                }
> -                if (qemu_opt_get(opts, "enable")) {
> -                    trace_enable_events(qemu_opt_get(opts, "enable"));
> -                }
> -                trace_init_events(qemu_opt_get(opts, "events"));
> -                if (trace_file) {
> -                    g_free(trace_file);
> -                }
> -                trace_file = g_strdup(qemu_opt_get(opts, "file"));
> -                qemu_opts_del(opts);
> +                trace_file = trace_opt_parse(optarg, trace_file);

It's clearer if the caller frees trace_file:

  g_free(trace_file);
  trace_file = trace_opt_parse(optarg);

Now the memory management is explicit and there is no need to pass
trace_file to trace_opt_parse().

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2016-06-17 13:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16  7:15 [Qemu-devel] [PATCH v7 0/7] trace: enable tracing in qemu-io/qemu-nbd/qemu-img Denis V. Lunev
2016-06-16  7:15 ` [Qemu-devel] [PATCH 1/7] doc: sync help descriprion for --trace with man for qemu.1 Denis V. Lunev
2016-06-17 13:48   ` Stefan Hajnoczi
2016-06-16  7:15 ` [Qemu-devel] [PATCH 2/7] doc: move text describing --trace to specific .texi file Denis V. Lunev
2016-06-17 13:36   ` Stefan Hajnoczi
2016-06-17 13:41     ` Denis V. Lunev
2016-06-16  7:15 ` [Qemu-devel] [PATCH 3/7] trace: move qemu_trace_opts to trace/control.c Denis V. Lunev
2016-06-17 13:48   ` Stefan Hajnoczi [this message]
2016-06-16  7:15 ` [Qemu-devel] [PATCH 4/7] trace: enable tracing in qemu-io Denis V. Lunev
2016-06-17 13:55   ` Stefan Hajnoczi
2016-06-16  7:15 ` [Qemu-devel] [PATCH 5/7] trace: enable tracing in qemu-nbd Denis V. Lunev
2016-06-17 13:55   ` Stefan Hajnoczi
2016-06-16  7:15 ` [Qemu-devel] [PATCH 6/7] qemu-img: move common options parsing before commands processing Denis V. Lunev
2016-06-17 13:55   ` Stefan Hajnoczi
2016-06-16  7:15 ` [Qemu-devel] [PATCH 7/7] trace: enable tracing in qemu-img Denis V. Lunev
2016-06-17 13:55   ` Stefan Hajnoczi
  -- strict thread matches above, loose matches on Subject: below --
2016-06-17 14:44 [Qemu-devel] [PATCH v9 0/7] trace: enable tracing in qemu-io/qemu-nbd/qemu-img Denis V. Lunev
2016-06-17 14:44 ` [Qemu-devel] [PATCH 3/7] trace: move qemu_trace_opts to trace/control.c Denis V. Lunev
2016-06-17 13:48 [Qemu-devel] [PATCH v8 0/7] trace: enable tracing in qemu-io/qemu-nbd/qemu-img Denis V. Lunev
2016-06-17 13:48 ` [Qemu-devel] [PATCH 3/7] trace: move qemu_trace_opts to trace/control.c Denis V. Lunev
2016-06-14 10:08 [Qemu-devel] [PATCH v6 0/7] trace: enable tracing in qemu-io/qemu-nbd/qemu-img Denis V. Lunev
2016-06-14 10:08 ` [Qemu-devel] [PATCH 3/7] trace: move qemu_trace_opts to trace/control.c Denis V. Lunev
2016-06-14  9:16 [Qemu-devel] [PATCH v5 0/7] trace: enable tracing in qemu-io/qemu-nbd/qemu-img Denis V. Lunev
2016-06-14  9:16 ` [Qemu-devel] [PATCH 3/7] trace: move qemu_trace_opts to trace/control.c Denis V. Lunev

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=20160617134822.GE28550@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=den@openvz.org \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.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.