threads / patch / 6222

patchRemove shadowing variable from traverse_trees()

Subject: [PATCH] Remove shadowing variable from traverse_trees()

## tl;dr

One message between Jan 4, 2007 and Jan 4, 2007. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

René Scharfe· Jan 4, 2007, 18:33 UTC · lore

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(-)
Show changes to tree-walk.c +0 −1
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;
 

← back to recent threads