# [PATCH] fsck: cleanup unused variable

2 messages from 2017-07-26 to 2017-07-26. Participants: Jonathan Tan, Jeff King.
Thread: https://gitlist.dev/t/46471

## Jonathan Tan, 2017-07-26 01:34

Subject: [PATCH] fsck: cleanup unused variable
Message-ID: <20170726013456.4187-1-jonathantanmy@google.com>
URL: https://gitlist.dev/e/20170726013456.4187-1-jonathantanmy%40google.com

```
Remove the unused variable "heads" from cmd_fsck().

This variable was made unused in commit c3271a0 ("fsck: do not fallback
"git fsck <bogus>" to "git fsck"", 2017-01-17).

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
---
While working on fsck, I noticed one more possible cleanup.
---
 builtin/fsck.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/builtin/fsck.c b/builtin/fsck.c
index 99dea7adf..cc5a5cfab 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -667,7 +667,7 @@ static struct option fsck_opts[] = {
 
 int cmd_fsck(int argc, const char **argv, const char *prefix)
 {
-	int i, heads;
+	int i;
 	struct alternate_object_database *alt;
 
 	errors_found = 0;
@@ -735,7 +735,6 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 		}
 	}
 
-	heads = 0;
 	for (i = 0; i < argc; i++) {
 		const char *arg = argv[i];
 		unsigned char sha1[20];
@@ -753,7 +752,6 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 				add_decoration(fsck_walk_options.object_names,
 					obj, xstrdup(arg));
 			mark_object_reachable(obj);
-			heads++;
 			continue;
 		}
 		error("invalid parameter: expected sha1, got '%s'", arg);
-- 
2.14.0.rc0.400.g1c36432dff-goog


```

## Jeff King, 2017-07-26 13:17

Subject: Re: [PATCH] fsck: cleanup unused variable
Message-ID: <20170726131729.o6bp2qmlqpl674zt@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20170726131729.o6bp2qmlqpl674zt%40sigill.intra.peff.net
In-Reply-To: <20170726013456.4187-1-jonathantanmy@google.com>

```
On Tue, Jul 25, 2017 at 06:34:56PM -0700, Jonathan Tan wrote:

> Remove the unused variable "heads" from cmd_fsck().
> 
> This variable was made unused in commit c3271a0 ("fsck: do not fallback
> "git fsck <bogus>" to "git fsck"", 2017-01-17).

Thanks, I should have caught this then.

The patch is obviously correct, though I'm curious why gcc's
-Wunused-but-set-variable didn't catch this.

-Peff

```
