Skip to content

Commit 6667a6a

Browse files
committed
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 []", which is sufficient to squelch compilation warning (the compiler can see usage[] given to die() is a constant and will never have conversion specifiers that cause trouble). But for a good measure, give them the same "%s" treatment as well. Signed-off-by: Junio C Hamano <[email protected]>
1 parent d477096 commit 6667a6a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

builtin/config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ static int get_urlmatch(const char *var, const char *url)
404404
config.cb = &values;
405405

406406
if (!url_normalize(url, &config.url))
407-
die(config.url.err);
407+
die("%s", config.url.err);
408408

409409
config.section = dup_downcase(var);
410410
section_tail = strchr(config.section, '.');

test-urlmatch-normalization.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
int main(int argc, char **argv)
55
{
6-
const char *usage = "test-urlmatch-normalization [-p | -l] <url1> | <url1> <url2>";
6+
const char usage[] = "test-urlmatch-normalization [-p | -l] <url1> | <url1> <url2>";
77
char *url1, *url2;
88
int opt_p = 0, opt_l = 0;
99

@@ -27,7 +27,7 @@ int main(int argc, char **argv)
2727
}
2828

2929
if (argc < 2 || argc > 3)
30-
die(usage);
30+
die("%s", usage);
3131

3232
if (argc == 2) {
3333
struct url_info info;
@@ -42,7 +42,7 @@ int main(int argc, char **argv)
4242
}
4343

4444
if (opt_p || opt_l)
45-
die(usage);
45+
die("%s", usage);
4646

4747
url1 = url_normalize(argv[1], NULL);
4848
url2 = url_normalize(argv[2], NULL);

0 commit comments

Comments
 (0)