{"thread":{"id":"34648","subject":"[PATCH] builtin/config.c: compilation fix","startedAt":"2013-08-09T04:41:44Z","lastAt":"2013-08-09T06:31:59Z","messageCount":3,"participants":["Junio C Hamano","Kyle J. McKay"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"224878","messageId":"7vli4b79x3.fsf@alter.siamese.dyndns.org","threadId":"34648","inReplyTo":null,"subject":"[PATCH] builtin/config.c: compilation fix","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-08-09T04:41:44Z","receivedAt":"2013-08-09T04:41:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Do not feed a random string as the first parameter to die(); use \"%s\"\nas the format string instead.\n\nDo the same for test-urlmatch-normalization.c while saving a single\npointer variable by turning a \"const char *\" constant string into\n\"const char []\".\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/config.c              | 2 +-\n test-urlmatch-normalization.c | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/config.c b/builtin/config.c\nindex c046f54..ae199e9 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -404,7 +404,7 @@ static int get_urlmatch(const char *var, const char *url)\n \tconfig.cb = &values;\n \n \tif (!url_normalize(url, &config.url))\n-\t\tdie(config.url.err);\n+\t\tdie(\"%s\", config.url.err);\n \n \tconfig.section = dup_downcase(var);\n \tsection_tail = strchr(config.section, '.');\ndiff --git a/test-urlmatch-normalization.c b/test-urlmatch-normalization.c\nindex 2603899..78c8b3a 100644\n--- a/test-urlmatch-normalization.c\n+++ b/test-urlmatch-normalization.c\n@@ -3,7 +3,7 @@\n \n int main(int argc, char **argv)\n {\n-\tconst char *usage = \"test-urlmatch-normalization [-p | -l] <url1> | <url1> <url2>\";\n+\tconst char usage[] = \"test-urlmatch-normalization [-p | -l] <url1> | <url1> <url2>\";\n \tchar *url1, *url2;\n \tint opt_p = 0, opt_l = 0;\n \n-- \n1.8.3.3-1049-g890a991\n"},{"id":"224879","messageId":"866829AC-DD63-462B-B12F-BF868D0ED5C0@gmail.com","threadId":"34648","inReplyTo":"7vli4b79x3.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] builtin/config.c: compilation fix","fromName":"Kyle J. McKay","fromEmail":"mackyle@gmail.com","sentAt":"2013-08-09T05:38:26Z","receivedAt":"2013-08-09T05:38:26Z","isPatch":true,"sender":{"key":"mackyle@gmail.com","avatar":"https://avatars.githubusercontent.com/u/813346?v=4"},"body":"On Aug 8, 2013, at 21:41, Junio C Hamano wrote:\n> Do not feed a random string as the first parameter to die(); use \"%s\"\n> as the format string instead.\n>\n> Do the same for test-urlmatch-normalization.c while saving a single\n> pointer variable by turning a \"const char *\" constant string into\n> \"const char []\".\n>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n> builtin/config.c              | 2 +-\n> test-urlmatch-normalization.c | 2 +-\n> 2 files changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/builtin/config.c b/builtin/config.c\n> index c046f54..ae199e9 100644\n> --- a/builtin/config.c\n> +++ b/builtin/config.c\n> @@ -404,7 +404,7 @@ static int get_urlmatch(const char *var, const  \n> char *url)\n> \tconfig.cb = &values;\n>\n> \tif (!url_normalize(url, &config.url))\n> -\t\tdie(config.url.err);\n> +\t\tdie(\"%s\", config.url.err);\n>\n> \tconfig.section = dup_downcase(var);\n> \tsection_tail = strchr(config.section, '.');\n> diff --git a/test-urlmatch-normalization.c b/test-urlmatch- \n> normalization.c\n> index 2603899..78c8b3a 100644\n> --- a/test-urlmatch-normalization.c\n> +++ b/test-urlmatch-normalization.c\n> @@ -3,7 +3,7 @@\n>\n> int main(int argc, char **argv)\n> {\n> -\tconst char *usage = \"test-urlmatch-normalization [-p | -l] <url1>  \n> | <url1> <url2>\";\n> +\tconst char usage[] = \"test-urlmatch-normalization [-p | -l] <url1>  \n> | <url1> <url2>\";\n> \tchar *url1, *url2;\n> \tint opt_p = 0, opt_l = 0;\n>\n> -- \n> 1.8.3.3-1049-g890a991\n>\n\nLooks good to me except that there seems to be a missing part of the  \npatch.  Did you also mean to include:\n\ndiff --git a/test-urlmatch-normalization.c b/test-urlmatch- \nnormalization.c\nindex 2603899b..39017c20 100644\n--- a/test-urlmatch-normalization.c\n+++ b/test-urlmatch-normalization.c\n@@ -42,7 +42,7 @@ int main(int argc, char **argv)\n  \t}\n\n  \tif (opt_p || opt_l)\n-\t\tdie(usage);\n+\t\tdie(\"%s\", usage);\n\n  \turl1 = url_normalize(argv[1], NULL);\n  \turl2 = url_normalize(argv[2], NULL);\n\n\nThat's not terribly important here since we know the string will never  \ncontain any '%' characters, but the comment on the patch led me to  \nbelieve that test-urlmatch-normalization would also get the die()  \nchange.\n"},{"id":"224882","messageId":"CAPc5daVoNef=EVxt+HAnVP9vSuQdTVHC=CRyc7_tqygxoiZeng@mail.gmail.com","threadId":"34648","inReplyTo":"866829AC-DD63-462B-B12F-BF868D0ED5C0@gmail.com","subject":"Re: [PATCH] builtin/config.c: compilation fix","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-08-09T06:31:59Z","receivedAt":"2013-08-09T06:31:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"On Thu, Aug 8, 2013 at 10:38 PM, Kyle J. McKay <mackyle@gmail.com> wrote:\n>> +       const char usage[] = \"test-urlmatch-normalization [-p | -l] <url1>\n\n> Looks good to me except that there seems to be a missing part of the patch.\n> Did you also mean to include:\n>\n> diff --git a/test-urlmatch-normalization.c b/test-urlmatch-normalization.c\n> index 2603899b..39017c20 100644\n> --- a/test-urlmatch-normalization.c\n> +++ b/test-urlmatch-normalization.c\n> @@ -42,7 +42,7 @@ int main(int argc, char **argv)\n>         }\n>\n>         if (opt_p || opt_l)\n> -               die(usage);\n> +               die(\"%s\", usage);\n>\n> That's not terribly important here since we know the string will never\n> contain any '%' characters, but the comment on the patch led me to believe\n> that test-urlmatch-normalization would also get the die() change.\n\nIt appears that \"const char usage[] = ...\" is enough to convince Gcc\nthat usage _is_\na constant and can never contain anything funky. But I agree that the\nusage string\ncould be updated, and I agree that it is prudent to do the same\ndie(\"%s\", ...) there.\n"}]}