traverse_trees(): clarify return value of the callback
The variable name "ret" sounds like the variable to be returned, but since e6c111b4 we return error, and it is misleading. As this variable tells us which trees in t[] array were used in the callback function, so that this caller can know the entries in which of the trees need advancing, "trees_used" is a better name. Also the assignment to 0 was removed at the start of the function as well after the "if (interesting)" block. Those are unneeded as that variable is set to the callback return value any time we enter the "if (interesting)" block, so we'd overwrite old values anyway. Signed-off-by: Stefan Beller <stefanbeller@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Jul 19, 2013 at 22:26 UTC
a04f8196a8f067b6c36415a0d934a46465140c34
1 file changed
+5
-6
tree-walk.c
+5
-6
@@ -323,7 +323,6 @@ static inline int prune_traversal(struct name_entry *e,
323
324
int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
325
{
326
- int ret = 0;
326
int error = 0;
327
struct name_entry *entry = xmalloc(n*sizeof(*entry));
328
int i;
@@ -341,6 +340,7 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
340
strbuf_setlen(&base, info->pathlen);
341
}
342
for (;;) {
343
+ int trees_used;
344
unsigned long mask, dirmask;
345
const char *first = NULL;
346
int first_len = 0;
@@ -404,15 +404,14 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
404
if (interesting < 0)
405
break;
406
if (interesting) {
407
- ret = info->fn(n, mask, dirmask, entry, info);
408
- if (ret < 0) {
409
- error = ret;
407
+ trees_used = info->fn(n, mask, dirmask, entry, info);
408
+ if (trees_used < 0) {
409
+ error = trees_used;
410
if (!info->show_all_errors)
411
break;
412
}
413
- mask &= ret;
413
+ mask &= trees_used;
414
}
415
- ret = 0;
415
for (i = 0; i < n; i++)
416
if (mask & (1ul << i))
417
update_extended_entry(tx + i, entry + i);