Re: [PATCH v3 02/25] Convert git_snpath() to strbuf_git_path()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 20, 2014, 03:41 UTC
- Message-ID
- <xmqqa9dm78n3.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <CACsJy8BJ=OKzGDFwWQF_k_Gp9XeNwf7pe7c6_ebduJXN=xeOxw@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> writes:
Show 17 quoted lines
>>> - }
>>> + if (old->path && old->name &&
>>> + !file_exists(git_path("%s", old->path)) &&
>>> + file_exists(git_path("logs/%s", old->path)))
>>> + remove_path(git_path("logs/%s", old->path));
>>
>> Hmph. Is this conversion safe?
>>
>> This adds three uses of the round-robin path buffer; if a caller of
>> this function used two or more path buffers obtained from
>> get_pathname() and expected their contents to remain stable across
>> the call to this, it will silently break.
>
> three round-robin buffers but not all required at the same time, once
> the first file_exists() returns the first round-robin buffer could be
> free, and remove_path() calls git_path again, not reusing the result
> from the second file_exists, so the second buffer is free to go too.I know these three callers to git_path() will not step on each other's toes. But that is not the question I asked.