Skip to content

Commit a04f819

Browse files
stefanbellergitster
authored andcommitted
traverse_trees(): clarify return value of the callback
The variable name "ret" sounds like the variable to be returned, but since e6c111b 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent edca415 commit a04f819

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

tree-walk.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ static inline int prune_traversal(struct name_entry *e,
323323

324324
int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
325325
{
326-
int ret = 0;
327326
int error = 0;
328327
struct name_entry *entry = xmalloc(n*sizeof(*entry));
329328
int i;
@@ -341,6 +340,7 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
341340
strbuf_setlen(&base, info->pathlen);
342341
}
343342
for (;;) {
343+
int trees_used;
344344
unsigned long mask, dirmask;
345345
const char *first = NULL;
346346
int first_len = 0;
@@ -404,15 +404,14 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
404404
if (interesting < 0)
405405
break;
406406
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;
410410
if (!info->show_all_errors)
411411
break;
412412
}
413-
mask &= ret;
413+
mask &= trees_used;
414414
}
415-
ret = 0;
416415
for (i = 0; i < n; i++)
417416
if (mask & (1ul << i))
418417
update_extended_entry(tx + i, entry + i);

0 commit comments

Comments
 (0)