qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH 3/7] trace: move qemu_trace_opts to trace/contro


From: Stefan Hajnoczi
Subject: Re: [Qemu-block] [PATCH 3/7] trace: move qemu_trace_opts to trace/control.c
Date: Fri, 17 Jun 2016 14:48:22 +0100
User-agent: Mutt/1.6.1 (2016-04-27)

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: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]