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