{"thread":{"id":"38677","subject":"[PATCH] git: make was_alias and done_help non-static","startedAt":"2015-03-02T12:02:37Z","lastAt":"2015-03-03T10:58:49Z","messageCount":3,"participants":["Alexander Kuleshov","Jeff King","Stefan Näwe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"256834","messageId":"1425297757-16431-1-git-send-email-kuleshovmail@gmail.com","threadId":"38677","inReplyTo":null,"subject":"[PATCH] git: make was_alias and done_help non-static","fromName":"Alexander Kuleshov","fromEmail":"kuleshovmail@gmail.com","sentAt":"2015-03-02T12:02:37Z","receivedAt":"2015-03-02T12:02:37Z","isPatch":true,"sender":{"key":"kuleshovmail@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2699235?v=4"},"body":"'was_alias' variable does not need to store it's value on each\niteration in the loop, anyway this variable changes it's value with run_argv.\n\n'done_help' variable does not need to be static variable too if we'll move it\nout the loop.\n\nSo these variables do not need to be static.\n\nSigned-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\nHelped-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n git.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 1780233..96723b8 100644\n--- a/git.c\n+++ b/git.c\n@@ -619,6 +619,7 @@ int main(int argc, char **av)\n {\n \tconst char **argv = (const char **) av;\n \tconst char *cmd;\n+\tint done_help, was_alias;\n \n \tstartup_info = &git_startup_info;\n \n@@ -681,8 +682,6 @@ int main(int argc, char **av)\n \tsetup_path();\n \n \twhile (1) {\n-\t\tstatic int done_help = 0;\n-\t\tstatic int was_alias = 0;\n \t\twas_alias = run_argv(&argc, &argv);\n \t\tif (errno != ENOENT)\n \t\t\tbreak;\n-- \n2.3.1.422.ge618558\n"},{"id":"256864","messageId":"20150302202918.GA22211@peff.net","threadId":"38677","inReplyTo":"1425297757-16431-1-git-send-email-kuleshovmail@gmail.com","subject":"Re: [PATCH] git: make was_alias and done_help non-static","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-03-02T20:29:18Z","receivedAt":"2015-03-02T20:29:18Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Mar 02, 2015 at 06:02:37PM +0600, Alexander Kuleshov wrote:\n\n> 'was_alias' variable does not need to store it's value on each\n> iteration in the loop, anyway this variable changes it's value with run_argv.\n> \n> 'done_help' variable does not need to be static variable too if we'll move it\n> out the loop.\n> \n> So these variables do not need to be static.\n\nAgreed, but...\n\n> diff --git a/git.c b/git.c\n> index 1780233..96723b8 100644\n> --- a/git.c\n> +++ b/git.c\n> @@ -619,6 +619,7 @@ int main(int argc, char **av)\n>  {\n>  \tconst char **argv = (const char **) av;\n>  \tconst char *cmd;\n> +\tint done_help, was_alias;\n\nNow done_help is not initialized, but we read from it before assigning\nit. And I think there is no need for was_alias to go outside the loop,\nright?\n\n>  \tstartup_info = &git_startup_info;\n>  \n> @@ -681,8 +682,6 @@ int main(int argc, char **av)\n>  \tsetup_path();\n>  \n>  \twhile (1) {\n> -\t\tstatic int done_help = 0;\n> -\t\tstatic int was_alias = 0;\n>  \t\twas_alias = run_argv(&argc, &argv);\n\nDropping the initialization of was_alias is fine, since we always assign\nto it before reading. That becomes more obvious if we leave it in the\nloop, and we can even assign in its declaration.\n\nSo all together, like:\n\ndiff --git a/git.c b/git.c\nindex acde36a..8dbe12f 100644\n--- a/git.c\n+++ b/git.c\n@@ -635,6 +635,7 @@ int main(int argc, char **av)\n {\n \tconst char **argv = (const char **) av;\n \tconst char *cmd;\n+\tint done_help = 0;\n \n \tstartup_info = &git_startup_info;\n \n@@ -697,9 +698,7 @@ int main(int argc, char **av)\n \tsetup_path();\n \n \twhile (1) {\n-\t\tstatic int done_help = 0;\n-\t\tstatic int was_alias = 0;\n-\t\twas_alias = run_argv(&argc, &argv);\n+\t\tint was_alias = run_argv(&argc, &argv);\n \t\tif (errno != ENOENT)\n \t\t\tbreak;\n \t\tif (was_alias) {\n"},{"id":"256890","messageId":"54F593E9.2070209@atlas-elektronik.com","threadId":"38677","inReplyTo":"1425297757-16431-1-git-send-email-kuleshovmail@gmail.com","subject":"Re: [PATCH] git: make was_alias and done_help non-static","fromName":"Stefan Näwe","fromEmail":"stefan.naewe@atlas-elektronik.com","sentAt":"2015-03-03T10:58:49Z","receivedAt":"2015-03-03T10:58:49Z","isPatch":true,"sender":{"key":"stefan.naewe@gmail.com","avatar":"https://avatars.githubusercontent.com/u/4468?v=4"},"body":"Am 02.03.2015 um 13:02 schrieb Alexander Kuleshov:\n> 'was_alias' variable does not need to store it's value on each\n> iteration in the loop, anyway this variable changes it's value with run_argv.\n\ns/it's/its/\n\n\n> 'done_help' variable does not need to be static variable too if we'll move it\n> out the loop.\n> \n> So these variables do not need to be static.\n> \n> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n> Helped-by: Eric Sunshine <sunshine@sunshineco.com>\n> ---\n>  git.c | 3 +--\n>  1 file changed, 1 insertion(+), 2 deletions(-)\n> \n> diff --git a/git.c b/git.c\n> index 1780233..96723b8 100644\n> --- a/git.c\n> +++ b/git.c\n> @@ -619,6 +619,7 @@ int main(int argc, char **av)\n>  {\n>  \tconst char **argv = (const char **) av;\n>  \tconst char *cmd;\n> +\tint done_help, was_alias;\n>  \n>  \tstartup_info = &git_startup_info;\n>  \n> @@ -681,8 +682,6 @@ int main(int argc, char **av)\n>  \tsetup_path();\n>  \n>  \twhile (1) {\n> -\t\tstatic int done_help = 0;\n> -\t\tstatic int was_alias = 0;\n>  \t\twas_alias = run_argv(&argc, &argv);\n>  \t\tif (errno != ENOENT)\n>  \t\t\tbreak;\n> \n\n/S\n-- \n----------------------------------------------------------------\n/dev/random says: Recovery program for excessive talkers: On-and-on-Anon.\npython -c \"print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')\" \nGPG Key fingerprint = 2DF5 E01B 09C3 7501 BCA9  9666 829B 49C5 9221 27AF\n"}]}