Skip to contentSkip to conversation

commit-graph: Fix missing closedir in expire_commit_graphs

PATCH In review Miaoqian Lin 3 participants 3 messages Sep 19, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 commit-graph: Fix missing closedir in expire_commit_graphs

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

---
changes in v2:
- add if (dir) before closedir(), as suggested by Derrick.

---
 commit-graph.c | 2 ++
 1 file changed, 2 insertions(+)
commit-graph.c +2 -0
index 06f7d9e0b6af..a7d875593288 100644
@@ -2265,6 +2265,8 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
 	}
 
 out:
+	if(dir)
+		closedir(dir);
 	strbuf_release(&path);
 }
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 3 lines · Miaoqian Lin

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.

commit-graph.c static void expire_commit_graphs(struct write_commit_graph_context *ctx) · line 2271

Quoted 5 lines

out:

commit-graph.c +2 -0
+	if(dir)
+		closedir(dir);
 	strbuf_release(&path);
 }

This change looks correct to me. Thanks!
-Stolee

#2 lore raw
Quoted 13 lines · Derrick Stolee
Quoted 3 lines · Miaoqian Lin

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.

Quoted 8 lines

commit-graph.c static void expire_commit_graphs(struct write_commit_graph_context *ctx) · line 2271

Quoted 5 lines

out:

commit-graph.c +2 -0
+	if(dir)
+		closedir(dir);
 	strbuf_release(&path);
 }

This change looks correct to me. Thanks!
-Stolee

Thanks, both. Looking good.