Re: [PATCH v4 05/10] unpack-trees: fix nested sparse-dir search
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Aug 25, 2021, 01:09 UTC
- Message-ID
- <249acb56-99bc-4a2a-b3d8-6b697643cf4d@gmail.com>
- In-Reply-To
- <51c11512-fb71-277e-790b-88ae3d5a358f@web.de>
On 8/24/2021 6:21 PM, René Scharfe wrote:
Show 15 quoted lines
> Am 24.08.21 um 23:51 schrieb Derrick Stolee via GitGitGadget:
>> - struct cache_entry *ce;
>> + const char *path;
>> + struct cache_entry *ce = NULL;
> ^^^^^^^
> This added initialization doesn't seem to be needed...
>
>> int pos = find_cache_pos(info, p->path, p->pathlen);
>> struct unpack_trees_options *o = info->data;
>>
>> @@ -1283,7 +1284,9 @@ static struct cache_entry *find_cache_entry(struct traverse_info *info,
>> while (pos >= 0) {
>> ce = o->src_index->cache[pos];
>
> ... because ce is set here before it's used.Better yet, 'ce' is only used within the while loop, so its declaration can be moved to this line instead.
Thanks, -Stolee