builtin/config.c: compilation fix
PATCH 1/1 builtin/config.c: compilation fix
Do not feed a random string as the first parameter to die(); use "%s" as the format string instead.
Do the same for test-urlmatch-normalization.c while saving a single pointer variable by turning a "const char *" constant string into "const char []".
--- builtin/config.c | 2 +- test-urlmatch-normalization.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
builtin/config.c +1 -1
@@ -404,7 +404,7 @@ static int get_urlmatch(const char *var, const char *url) config.cb = &values;if (!url_normalize (url, &config.url)) -die (config.url.err); +die ("%s" , config.url.err); config.section =dup_downcase (var); section_tail =strchr (config.section,'.' );
test-urlmatch-normalization.c +1 -1
@@ -3,7 +3,7 @@int main (int argc,char **argv) { -const char *usage ="test-urlmatch-normalization [-p | -l] <url1> | <url1> <url2>" ; +const char usage[] ="test-urlmatch-normalization [-p | -l] <url1> | <url1> <url2>" ;char *url1, *url2;int opt_p =0 , opt_l =0 ;
Signature · 1 line
1.8.3.3-1049-g890a991
Quoted 40 lines · Junio C Hamano
Do not feed a random string as the first parameter to
die(); use "%s" as the format string instead.Do the same for
test-urlmatch-normalization.cwhile saving a single pointer variable by turning a "const char *" constant string into "const char []".Signed-off-by Junio C Hamano <[email protected]>---
builtin/config.c| 2 +-test-urlmatch-normalization.c| 2 +-2 files changed, 2 insertions(+), 2 deletions(-)builtin/config.c +1
-1@@ -404,7 +404,7 @@ static int get_urlmatch(const char *var, const char *url) config.cb = &values;if (!url_normalize (url, &config.url)) -die (config.url.err); +die ("%s" , config.url.err); config.section =dup_downcase (var);section_tail = strchr(config.section, '.');test-urlmatch-normalization.c +1
-1@@ -3,7 +3,7 @@int main (int argc,char **argv) { -const char *usage ="test-urlmatch-normalization [-p | -l] <url1> | <url1> <url2>"; + const char usage[] = "test-urlmatch-normalization [-p | -l] <url1> | <url1> <url2>";char *url1, *url2;
Quoted 5 lines
int opt_p = 0, opt_l = 0;Signature · 1 line
1.8.3.3-1049-g890a991
Looks good to me except that there seems to be a missing part of the patch. Did you also mean to include:
test-urlmatch-normalization.c +1 -1
@@ -42,7 +42,7 @@ int main(int argc, char **argv) }if (opt_p || opt_l) -die (usage); +die ("%s" , usage); url1 =url_normalize (argv[1 ],NULL ); url2 =url_normalize (argv[2 ],NULL );
That's not terribly important here since we know the string will never contain any '%' characters, but the comment on the patch led me to believe that test-urlmatch-normalization would also get the die() change.
Quoted 16 lines · Kyle J. McKay
Quoted 1 line
+ const char usage[] = "test-urlmatch-normalization [-p | -l] <url1>
Looks good to me except that there seems to be a missing part of the patch. Did you also mean to include:
test-urlmatch-normalization.c +1
-1@@ -42,7 +42,7 @@ int main(int argc, char **argv) }if (opt_p || opt_l) -die (usage); +die ("%s" , usage);
Quoted 3 lines
That's not terribly important here since we know the string will never contain any '%' characters, but the comment on the patch led me to believe that test-urlmatch-normalization would also get the
die()change.
It appears that "const char usage[] = ..." is enough to convince Gcc that usage _is_
a constant and can never contain anything funky. But I agree that the usage string
could be updated, and I agree that it is prudent to do the same die("%s", ...) there.