diff options
author | Lukas Fleischer <cgit@cryptocrack.de> | 2013-04-02 00:11:13 (JST) |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2013-04-08 22:43:17 (JST) |
commit | 996f86e664ab6d00a9304a42374e9c691b78ca6b (patch) | |
tree | 1f2358c286eedfb86c89ea812b0bcd45c71cd1d9 | |
parent | 849ecd961df9454d6f849eac34e6f501395c4f01 (diff) | |
download | cgit-996f86e664ab6d00a9304a42374e9c691b78ca6b.zip cgit-996f86e664ab6d00a9304a42374e9c691b78ca6b.tar.gz |
Return const char * in cgit_{httpscheme, hosturl, rooturl}()
The return values of these functions are essentially constant and should
never be modified.
Note that this will introduce a compiler warning when we try to free the
return value of any of these functions. However, given that all of these
currently return statically allocated strings in some cases, they need
to be refactored before this can be done anyway.
Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
-rw-r--r-- | ui-atom.c | 4 | ||||
-rw-r--r-- | ui-shared.c | 8 | ||||
-rw-r--r-- | ui-shared.h | 6 |
3 files changed, 9 insertions, 9 deletions
@@ -10,7 +10,7 @@ | |||
10 | #include "html.h" | 10 | #include "html.h" |
11 | #include "ui-shared.h" | 11 | #include "ui-shared.h" |
12 | 12 | ||
13 | static void add_entry(struct commit *commit, char *host) | 13 | static void add_entry(struct commit *commit, const char *host) |
14 | { | 14 | { |
15 | char delim = '&'; | 15 | char delim = '&'; |
16 | char *hex; | 16 | char *hex; |
@@ -79,7 +79,7 @@ static void add_entry(struct commit *commit, char *host) | |||
79 | 79 | ||
80 | void cgit_print_atom(char *tip, char *path, int max_count) | 80 | void cgit_print_atom(char *tip, char *path, int max_count) |
81 | { | 81 | { |
82 | char *host; | 82 | const char *host; |
83 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; | 83 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; |
84 | struct commit *commit; | 84 | struct commit *commit; |
85 | struct rev_info rev; | 85 | struct rev_info rev; |
diff --git a/ui-shared.c b/ui-shared.c index d4fb3d9..7a726c1 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -34,7 +34,7 @@ void cgit_print_error(const char *msg) | |||
34 | html("</div>\n"); | 34 | html("</div>\n"); |
35 | } | 35 | } |
36 | 36 | ||
37 | char *cgit_httpscheme() | 37 | const char *cgit_httpscheme() |
38 | { | 38 | { |
39 | if (ctx.env.https && !strcmp(ctx.env.https, "on")) | 39 | if (ctx.env.https && !strcmp(ctx.env.https, "on")) |
40 | return "https://"; | 40 | return "https://"; |
@@ -42,7 +42,7 @@ char *cgit_httpscheme() | |||
42 | return "http://"; | 42 | return "http://"; |
43 | } | 43 | } |
44 | 44 | ||
45 | char *cgit_hosturl() | 45 | const char *cgit_hosturl() |
46 | { | 46 | { |
47 | if (ctx.env.http_host) | 47 | if (ctx.env.http_host) |
48 | return ctx.env.http_host; | 48 | return ctx.env.http_host; |
@@ -53,7 +53,7 @@ char *cgit_hosturl() | |||
53 | return xstrdup(fmt("%s:%s", ctx.env.server_name, ctx.env.server_port)); | 53 | return xstrdup(fmt("%s:%s", ctx.env.server_name, ctx.env.server_port)); |
54 | } | 54 | } |
55 | 55 | ||
56 | char *cgit_rooturl() | 56 | const char *cgit_rooturl() |
57 | { | 57 | { |
58 | if (ctx.cfg.virtual_root) | 58 | if (ctx.cfg.virtual_root) |
59 | return fmt("%s/", ctx.cfg.virtual_root); | 59 | return fmt("%s/", ctx.cfg.virtual_root); |
@@ -651,7 +651,7 @@ void cgit_print_docstart(struct cgit_context *ctx) | |||
651 | return; | 651 | return; |
652 | } | 652 | } |
653 | 653 | ||
654 | char *host = cgit_hosturl(); | 654 | const char *host = cgit_hosturl(); |
655 | html(cgit_doctype); | 655 | html(cgit_doctype); |
656 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); | 656 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); |
657 | html("<head>\n"); | 657 | html("<head>\n"); |
diff --git a/ui-shared.h b/ui-shared.h index 87a7dac..0666388 100644 --- a/ui-shared.h +++ b/ui-shared.h | |||
@@ -1,9 +1,9 @@ | |||
1 | #ifndef UI_SHARED_H | 1 | #ifndef UI_SHARED_H |
2 | #define UI_SHARED_H | 2 | #define UI_SHARED_H |
3 | 3 | ||
4 | extern char *cgit_httpscheme(); | 4 | extern const char *cgit_httpscheme(); |
5 | extern char *cgit_hosturl(); | 5 | extern const char *cgit_hosturl(); |
6 | extern char *cgit_rooturl(); | 6 | extern const char *cgit_rooturl(); |
7 | extern char *cgit_repourl(const char *reponame); | 7 | extern char *cgit_repourl(const char *reponame); |
8 | extern char *cgit_fileurl(const char *reponame, const char *pagename, | 8 | extern char *cgit_fileurl(const char *reponame, const char *pagename, |
9 | const char *filename, const char *query); | 9 | const char *filename, const char *query); |