Skip to contentSkip to conversation

git: make was_alias non-static

PATCH In review Alexander Kuleshov 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git: make was_alias non-static

'was_alias' variable does not need to store it's value each iteration in the loop, anyway this variable changes it's value with run_argv. So it does not need to be static.

---
 git.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git.c +1 -1
index 1780233..b8b6520 100644
@@ -682,7 +682,7 @@ int main(int argc, char **av)
 
 	while (1) {
 		static int done_help = 0;
-		static int was_alias = 0;
+		int was_alias = 0;
 		was_alias = run_argv(&argc, &argv);
 		if (errno != ENOENT)
 			break;
Signature · 1 line
2.3.1.422.ge618558.dirty
#1 lore raw
Quoted 14 lines · Alexander Kuleshov

'was_alias' variable does not need to store it's value each iteration in the loop, anyway this variable changes it's value with run_argv. So it does not need to be static.

---
 git.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git.c +0 -0
index 1780233..b8b6520 100644

git.c int main(int argc, char **av) · line 684

Quoted 3 lines
git.c +0 -0
@@ -682,7 +682,7 @@ int main(int argc, char **av)
 
        while (1) {
                static int done_help = 0;

'done_help' could receive similar treatment by dropping 'static' and moving it outside the 'while' loop. Doing so would make the logic easier to understand.

git.c int main(int argc, char **av) · line 685

Quoted 2 lines
git.c +1 -1
-               static int was_alias = 0;
+               int was_alias = 0;

No need for the 0 initialization since 'was_alias' is being assigned immediately below.

Quoted 5 lines
git.c +0 -1
                was_alias = run_argv(&argc, &argv);
                if (errno != ENOENT)
                        break;
--

2.3.1.422.ge618558.dirty