qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Tracing][PATCH] Add options to specify trace file nam


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [Tracing][PATCH] Add options to specify trace file name at startup and runtime.
Date: Wed, 4 Aug 2010 10:53:10 +0100

On Wed, Aug 4, 2010 at 10:33 AM, Prerna Saxena
<address@hidden> wrote:
> On 08/03/2010 07:45 PM, Stefan Hajnoczi wrote:
>> On Tue, Aug 3, 2010 at 6:37 AM, Prerna Saxena<address@hidden>
>>  wrote:
>>> @@ -2590,6 +2597,12 @@ int main(int argc, char **argv, char **envp)
>>>                 }
>>>                 xen_mode = XEN_ATTACH;
>>>                 break;
>>> +#ifdef CONFIG_SIMPLE_TRACE
>>> +            case QEMU_OPTION_trace:
>>> +                trace_file = (char *) qemu_malloc(strlen(optarg) + 1);
>>> +                strcpy(trace_file, optarg);
>>> +                break;
>>> +#endif
>>
>> Malloc isn't necessary, just hold the optarg pointer like gdbstub_dev
>> and other string options do.
>
> It wouldnt be corect to use optarg directly here. If this optional argument
> is not specified, st_set_file_name() is called with a NULL argument, and the
> filename defaults to config-specified name.
> (This is how gdbstub_dev works too. The optional argument is copied to
> gdbstub_dev if provided.)

const char *trace_file = NULL;
...
switch (...) {
    case QEMU_OPTION_trace:
        trace_file = optarg;
        break;
}
...
st_set_trace_file(trace_file);

There is no need to malloc/strcpy/free.

Stefan



reply via email to

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