diff options
context:
space:
mode:
Diffstat (limited to 'source/cmd.c')
-rw-r--r--source/cmd.c13
1 file changed, 6 insertions, 7 deletions
diff --git a/source/cmd.c b/source/cmd.c
index 510c957..c17d8d9 100644
--- a/source/cmd.c
+++ b/source/cmd.c
@@ -26,6 +26,8 @@
#include "ui-summary.h"
#include "ui-tag.h"
#include "ui-tree.h"
+#define def_cmd(name, want_repo, want_vpath, is_clone) \
+ {#name, name##_fn, want_repo, want_vpath, is_clone}
static void HEAD_fn(void)
{
@@ -46,7 +48,7 @@ static void about_fn(void)
ctx.qry.url[strlen(ctx.qry.url) - 1] != '/') &&
(!path_info_len || ctx.env.path_info[path_info_len - 1] != '/')) {
char *currenturl = cgit_currenturl();
- char *redirect = fmtalloc("%s/", currenturl);
+ char *redirect = cgit_fmtalloc("%s/", currenturl);
cgit_redirect(redirect, true);
free(currenturl);
free(redirect);
@@ -56,7 +58,7 @@ static void about_fn(void)
cgit_redirect(ctx.repo->homepage, false);
else {
char *currenturl = cgit_currenturl();
- char *redirect = fmtalloc("%s../", currenturl);
+ char *redirect = cgit_fmtalloc("%s../", currenturl);
cgit_redirect(redirect, false);
free(currenturl);
free(redirect);
@@ -174,9 +176,6 @@ static void tree_fn(void)
cgit_print_tree(ctx.qry.oid, ctx.qry.path);
}
-#define def_cmd(name, want_repo, want_vpath, is_clone) \
- {#name, name##_fn, want_repo, want_vpath, is_clone}
-
struct cgit_cmd *cgit_get_cmd(void)
{
static struct cgit_cmd cmds[] = {
@@ -202,7 +201,7 @@ struct cgit_cmd *cgit_get_cmd(void)
def_cmd(tag, 1, 0, 0),
def_cmd(tree, 1, 1, 0),
};
- int i;
+ size_t i;
if (ctx.qry.page == NULL) {
if (ctx.repo)
@@ -211,7 +210,7 @@ struct cgit_cmd *cgit_get_cmd(void)
ctx.qry.page = "repolist";
}
- for (i = 0; i < sizeof(cmds)/sizeof(*cmds); i++)
+ for (i = 0; i < ARRAY_SIZE(cmds); i++)
if (!strcmp(ctx.qry.page, cmds[i].name))
return &cmds[i];
return NULL;