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

3 messages from 2022-09-19 to 2022-09-19. Participants: Miaoqian Lin, Derrick Stolee, Junio C Hamano.
Thread: https://gitlist.dev/t/58455

## Miaoqian Lin, 2022-09-19 14:14

Subject: [PATCH v2] commit-graph: Fix missing closedir in expire_commit_graphs
Message-ID: <20220919141441.5644-1-linmq006@gmail.com>
URL: https://gitlist.dev/e/20220919141441.5644-1-linmq006%40gmail.com

```
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(+)

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, 2022-09-19 15:04

Subject: Re: [PATCH v2] commit-graph: Fix missing closedir in expire_commit_graphs
Message-ID: <4f1cf64e-2864-a979-6f75-d9d4148d57da@github.com>
URL: https://gitlist.dev/e/4f1cf64e-2864-a979-6f75-d9d4148d57da%40github.com
In-Reply-To: <20220919141441.5644-1-linmq006@gmail.com>

```
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

```

## Junio C Hamano, 2022-09-19 17:41

Subject: Re: [PATCH v2] commit-graph: Fix missing closedir in expire_commit_graphs
Message-ID: <xmqq7d1zb6ta.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqq7d1zb6ta.fsf%40gitster.g
In-Reply-To: <4f1cf64e-2864-a979-6f75-d9d4148d57da@github.com>

```
Derrick Stolee <derrickstolee@github.com> writes:

> 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.

```
