diff options
author | Michael McVady <femtonaut@gmail.com> | 2023-01-02 07:45:09 -0600 |
---|---|---|
committer | Michael McVady <femtonaut@gmail.com> | 2023-01-02 07:45:09 -0600 |
commit | a1c84126f36527dc4ac1c7f1f5473ca536d56f48 (patch) | |
tree | 091aa501e32f8227baa0ea2e6d10af39f388fce8 /src | |
parent | 270cee4e9b9b77e13eabcb59c5aabaad2159c79f (diff) |
const correctness
Diffstat (limited to 'src')
-rw-r--r-- | src/clog.c | 36 |
1 files changed, 22 insertions, 14 deletions
@@ -15,6 +15,7 @@ KORE_SECCOMP_FILTER("clog", KORE_SYSCALL_ALLOW(bind), KORE_SYSCALL_ALLOW(getdents64), + KORE_SYSCALL_ALLOW(newfstatat), KORE_SYSCALL_ALLOW(sendmmsg), KORE_SYSCALL_ALLOW(uname) ) @@ -26,10 +27,12 @@ int posts(struct http_request *); int render_posts_html(struct http_request *, const char *); int render_posts_json(struct http_request *, const char *); static void process_md_output(const MD_CHAR *, MD_SIZE size, void *); -static int render_md(char *, struct kore_buf *); +static int render_md(const char *, struct kore_buf *); static const char *database = "db"; +static const char *accept_json = "application/json"; + int redirect(struct http_request *req) { @@ -54,7 +57,7 @@ post(struct http_request *req) if (err == KORE_RESULT_OK) { kore_log(LOG_DEBUG, "Accept: %s", accept); - if (strcmp(accept, "application/json") == 0) + if (strncmp(accept, accept_json, sizeof(*accept_json)) == 0) { return render_posts_json(req, resource); } @@ -74,7 +77,7 @@ posts(struct http_request *req) if (err == KORE_RESULT_OK) { kore_log(LOG_DEBUG, "Accept: %s", accept); - if (strcmp(accept, "application/json") == 0) + if (strncmp(accept, accept_json, sizeof(*accept_json)) == 0) { return render_posts_json(req, NULL); } @@ -86,19 +89,23 @@ posts(struct http_request *req) int render_posts_html(struct http_request *req, const char *resource) { - int err; + int err = 0; + + int row = 0, rows = 0; + + const char *id = NULL; + const char *title = NULL; + const char *created_at = NULL; + const char *body = NULL; struct kore_buf *resp_buf = kore_buf_alloc(0); struct kore_pgsql sql; - int row, rows; - char *id, *title, *created_at, *body; + kore_pgsql_init(&sql); kore_buf_append(resp_buf, asset_index_begin_html, asset_len_index_begin_html); - kore_pgsql_init(&sql); - // Initialize our kore_pgsql data structure with the database name // we want to connect to (note that we registered this earlier with // kore_pgsql_register()). We also say we will perform a synchronous @@ -199,14 +206,15 @@ out: ; int render_posts_json(struct http_request *req, const char *resource) { - int err; + int err = 0; + + int rows = 0; + + const char *json = NULL; struct kore_buf *resp_buf = kore_buf_alloc(0); struct kore_pgsql sql; - int rows; - - char *json; kore_pgsql_init(&sql); @@ -280,9 +288,9 @@ out: ; } static int -render_md(char *in, struct kore_buf *out) +render_md(const char *in, struct kore_buf *out) { - int err; + int err = 0; static unsigned parser_flags = 0; static unsigned renderer_flags = MD_HTML_FLAG_DEBUG; |