* [PATCH] builtin/config.c: compilation fix
@ 2013-08-09 4:41 Junio C Hamano
2013-08-09 5:38 ` Kyle J. McKay
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2013-08-09 4:41 UTC (permalink / raw)
To: git; +Cc: Kyle J. McKay
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 []".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/config.c | 2 +-
test-urlmatch-normalization.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/config.c b/builtin/config.c
index c046f54..ae199e9 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -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, '.');
diff --git a/test-urlmatch-normalization.c b/test-urlmatch-normalization.c
index 2603899..78c8b3a 100644
--- a/test-urlmatch-normalization.c
+++ b/test-urlmatch-normalization.c
@@ -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;
--
1.8.3.3-1049-g890a991
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] builtin/config.c: compilation fix
2013-08-09 4:41 [PATCH] builtin/config.c: compilation fix Junio C Hamano
@ 2013-08-09 5:38 ` Kyle J. McKay
2013-08-09 6:31 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Kyle J. McKay @ 2013-08-09 5:38 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Aug 8, 2013, at 21:41, Junio C Hamano wrote:
> 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 []".
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> builtin/config.c | 2 +-
> test-urlmatch-normalization.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/config.c b/builtin/config.c
> index c046f54..ae199e9 100644
> --- a/builtin/config.c
> +++ b/builtin/config.c
> @@ -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, '.');
> diff --git a/test-urlmatch-normalization.c b/test-urlmatch-
> normalization.c
> index 2603899..78c8b3a 100644
> --- a/test-urlmatch-normalization.c
> +++ b/test-urlmatch-normalization.c
> @@ -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;
>
> --
> 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:
diff --git a/test-urlmatch-normalization.c b/test-urlmatch-
normalization.c
index 2603899b..39017c20 100644
--- a/test-urlmatch-normalization.c
+++ b/test-urlmatch-normalization.c
@@ -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.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] builtin/config.c: compilation fix
2013-08-09 5:38 ` Kyle J. McKay
@ 2013-08-09 6:31 ` Junio C Hamano
0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2013-08-09 6:31 UTC (permalink / raw)
To: Kyle J. McKay; +Cc: git
On Thu, Aug 8, 2013 at 10:38 PM, Kyle J. McKay <mackyle@gmail.com> wrote:
>> + 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:
>
> diff --git a/test-urlmatch-normalization.c b/test-urlmatch-normalization.c
> index 2603899b..39017c20 100644
> --- a/test-urlmatch-normalization.c
> +++ b/test-urlmatch-normalization.c
> @@ -42,7 +42,7 @@ int main(int argc, char **argv)
> }
>
> if (opt_p || opt_l)
> - die(usage);
> + die("%s", usage);
>
> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-09 6:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-09 4:41 [PATCH] builtin/config.c: compilation fix Junio C Hamano
2013-08-09 5:38 ` Kyle J. McKay
2013-08-09 6:31 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).