Re: [PATCH 1/6] New function null_stream

Luis Machado
2017-01-18T14:53:43Z

On 01/18/2017 08:45 AM, Yao Qi wrote:
> On 17-01-17 07:49:07, Luis Machado wrote:
>>>
>>> +struct ui_file *
>>> +null_stream (void)
>>> +{
>>> + static struct ui_file *stream = NULL;
>>> +
>>> + if (stream == NULL)
>>> + {
>>> + stream = ui_file_new ();
>>> + make_final_cleanup (do_ui_file_delete, stream);
>>> + }
>>
>> Since we're explicitly setting stream to NULL, we will always
>> execute the conditional block, so it is not needed. Unless this is
>> supposed to reuse a stream, but in that case the code would be
>> incorrect.
>>
>
> It is a reused null stream. Different parts of gdb can use it. Why
> is it incorrect?
>

We're setting stream to NULL at the top of the function and then
checking if it is NULL (it obviously is) right after that? Am i missing
something?