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

[PATCH 2/2] commit.c: rename variable named 'n' which masks previous declaration

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Aug 27, 2009, 16:16 UTC
Message-ID
<vODpKBYr5sNtCfB7C_mUMqn8szqSz58pySpTHpAGYAe6MTvKrSPNr0gs14tbOkuPF97cDvuGi2M@cipher.nrlssc.navy.mil>
In-Reply-To
<vODpKBYr5sNtCfB7C_mUMmQyYO9vzbX98QMYSBId5GcwHT7q6zvrKlJpRNwoJvTTF7qKScin5PA@cipher.nrlssc.navy.mil>
From: Brandon Casey <drafnel@gmail.com>

The variable named 'n' was initially declared to be of type int. The name 'n' was reused inside inner blocks as a different type. Rename the uses within inner blocks to avoid confusion and give them a slightly more descriptive name.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 commit.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/commit.c b/commit.c
index e2bcbe8..a6c6f70 100644
--- a/commit.c
+++ b/commit.c
@@ -564,13 +564,13 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct co
 	while (interesting(list)) {
 		struct commit *commit;
 		struct commit_list *parents;
-		struct commit_list *n;
+		struct commit_list *next;
 		int flags;
 
 		commit = list->item;
-		n = list->next;
+		next = list->next;
 		free(list);
-		list = n;
+		list = next;
 
 		flags = commit->object.flags & (PARENT1 | PARENT2 | STALE);
 		if (flags == (PARENT1 | PARENT2)) {
@@ -598,11 +598,11 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct co
 	free_commit_list(list);
 	list = result; result = NULL;
 	while (list) {
-		struct commit_list *n = list->next;
+		struct commit_list *next = list->next;
 		if (!(list->item->object.flags & STALE))
 			insert_by_date(list->item, &result);
 		free(list);
-		list = n;
+		list = next;
 	}
 	return result;
 }
-- 
1.6.4
Previous: Brandon Casey
Message 3 of 3 in “Two janitorial patches”
  1. 0/2 Two janitorial patchesBrandon Casey, Aug 27, 2009
  2. 1/2 abspath.c: move declaration of 'len' into inner block and use appropriate typeBrandon Casey, Aug 27, 2009
  3. 2/2 commit.c: rename variable named 'n' which masks previous declarationBrandon Casey, Aug 27, 2009

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.