threads / patch / 58455

v2commit-graph: Fix missing closedir in expire_commit_graphs

Subject: [PATCH v2] commit-graph: Fix missing closedir in expire_commit_graphs

## tl;dr

3 messages between Sep 19, 2022 and Sep 19, 2022. Diffs are folded; open one to read it.

replies: 2people: 3as markdown or json

Miaoqian Lin· Sep 19, 2022, 14:14 UTC · lore

The function calls opendir() but missing the corresponding closedir() before exit the function. Add missing closedir() to fix it.

Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
changes in v2:
- add if (dir) before closedir(), as suggested by Derrick.
---
 commit-graph.c | 2 ++
 1 file changed, 2 insertions(+)
Show changes to commit-graph.c +2 −0
diff --git a/commit-graph.c b/commit-graph.c
index 06f7d9e0b6af..a7d875593288 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -2265,6 +2265,8 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
 	}
 
 out:
+	if(dir)
+		closedir(dir);
 	strbuf_release(&path);
 }
 
-- 
2.25.1
Derrick Stolee· Sep 19, 2022, 15:04 UTC · re: Miaoqian Lin · lore

Re: [PATCH v2] commit-graph: Fix missing closedir in expire_commit_graphs

On 9/19/2022 10:14 AM, Miaoqian Lin wrote:
> The function calls opendir() but missing the corresponding
> closedir() before exit the function.
> Add missing closedir() to fix it.
Thanks for the patch, Miaoqian.

I only have a very tiny nitpick with the line breaks in your commit message. Either the "Add missing..." sentence should start immediately after the previous sentence or have another line break between the paragraphs. This shouldn't merit a re-roll, but keep it in mind for future contributions.

Show 5 quoted lines
>  out:
> +	if(dir)
> +		closedir(dir);
>  	strbuf_release(&path);
>  }

This change looks correct to me. Thanks! -Stolee

Junio C Hamano· Sep 19, 2022, 17:41 UTC · re: Derrick Stolee · lore

Re: [PATCH v2] commit-graph: Fix missing closedir in expire_commit_graphs

Derrick Stolee <derrickstolee@github.com> writes:
Show 21 quoted lines
> On 9/19/2022 10:14 AM, Miaoqian Lin wrote:
>> The function calls opendir() but missing the corresponding
>> closedir() before exit the function.
>> Add missing closedir() to fix it.
>
> Thanks for the patch, Miaoqian.
>
> I only have a very tiny nitpick with the line breaks in your
> commit message. Either the "Add missing..." sentence should
> start immediately after the previous sentence or have another
> line break between the paragraphs. This shouldn't merit a
> re-roll, but keep it in mind for future contributions.
>
>>  out:
>> +	if(dir)
>> +		closedir(dir);
>>  	strbuf_release(&path);
>>  }
>
> This change looks correct to me. Thanks!
> -Stolee
Thanks, both.  Looking good.

← back to recent threads