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

[PATCH 1/3] treewalk.c: Rename variable ret to cb_bits and remove some dead lines.

From
Stefan Beller <stefanbeller@googlemail.com>
Date
Jul 18, 2013, 21:35 UTC
Message-ID
<1374183327-14939-1-git-send-email-stefanbeller@googlemail.com>

The variable name ret sounds like the variable to be returned, but since e6c111b4 we return error. Hence the variable name is miss leading. As this variable is used only to extract the bits from the callback of a tree object, I named it cb_bits for callback bits.

Also the assignment to 0 was removed at the start of the function as well after the if(interesting) block. Those were 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>
---
 tree-walk.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/tree-walk.c b/tree-walk.c
index c366852..3c323d1 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -324,7 +324,6 @@ static inline int prune_traversal(struct name_entry *e,
 
 int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
 {
-	int ret = 0;
 	int error = 0;
 	struct name_entry *entry = xmalloc(n*sizeof(*entry));
 	int i;
@@ -342,6 +341,7 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
 		strbuf_setlen(&base, info->pathlen);
 	}
 	for (;;) {
+		int cb_bits;
 		unsigned long mask, dirmask;
 		const char *first = NULL;
 		int first_len = 0;
@@ -405,15 +405,14 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
 		if (interesting < 0)
 			break;
 		if (interesting) {
-			ret = info->fn(n, mask, dirmask, entry, info);
-			if (ret < 0) {
-				error = ret;
+			cb_bits = info->fn(n, mask, dirmask, entry, info);
+			if (cb_bits < 0) {
+				error = cb_bits;
 				if (!info->show_all_errors)
 					break;
 			}
-			mask &= ret;
+			mask &= cb_bits;
 		}
-		ret = 0;
 		for (i = 0; i < n; i++)
 			if (mask & (1ul << i))
 				update_extended_entry(tx + i, entry + i);
-- 
1.8.3.3.754.g9c3c367.dirty
Next: Stefan Beller
Message 1 of 8 in “treewalk.c: Rename variable ret to cb_bits and remove some dead lines.”
  1. 1/3 treewalk.c: Rename variable ret to cb_bits and remove some dead lines.Stefan Beller, Jul 18, 2013
  2. 2/3 http-push.c, add_send_request: Do not initialize transfer_request.Stefan Beller, Jul 18, 2013
  3. Junio C HamanoJul 19, 2013
  4. 3/3 apply, find_name_traditional: Do not initialize len to the lines length.Stefan Beller, Jul 18, 2013
  5. Junio C HamanoJul 19, 2013
  6. Stefan BellerJul 19, 2013
  7. traverse_trees(): clarify return value of the callback.Stefan Beller, Jul 19, 2013
  8. Junio C HamanoJul 19, 2013

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.