git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Remove shadowing variable from traverse_trees()

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Jan 4, 2007, 18:33 UTC
Message-ID
<459D4880.9070804@lsrfire.ath.cx>

The variable named entry is allocated using malloc() and then forgotten, it being shadowed by an automatic variable of the same name. Fixing the array size at 3 worked so far because the only caller of traverse_trees() needed only as much entries. Simply remove the shadowing varaible and we're able to traverse more than three trees and save stack space at the same time!

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 tree-walk.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/tree-walk.c b/tree-walk.c
index 14cc5ae..22f4550 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -113,7 +113,6 @@ void traverse_trees(int n, struct tree_desc *t, const char *base, traverse_callb
 	struct name_entry *entry = xmalloc(n*sizeof(*entry));
 
 	for (;;) {
-		struct name_entry entry[3];
 		unsigned long mask = 0;
 		int i, last;
 
Message 1 of 1 in “Remove shadowing variable from traverse_trees()”
  1. Remove shadowing variable from traverse_trees()René Scharfe, Jan 4, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.