kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 5e21de3a4c621b3ade384ec9a272eadb41c4acab
parent 25ea10fea7e33a5b94e1dea9e135a5175c69841e
Author: Daniel Fahlgren <daniel@fahlgren.se>
Date:   Wed, 17 Aug 2022 13:16:18 +0200

Add printf format attributes and fix fallout

Diffstat:
include/kore/jsonrpc.h | 3++-
include/kore/kore.h | 18++++++++++++------
src/cli.c | 14+++++++++-----
src/http.c | 2+-
src/keymgr_openssl.c | 3++-
src/log.c | 3++-
src/pool.c | 2+-
src/worker.c | 2+-
8 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/include/kore/jsonrpc.h b/include/kore/jsonrpc.h @@ -73,7 +73,8 @@ enum jsonrpc_error_code JSONRPC_LIMIT_REACHED = -31997 }; -void jsonrpc_log(struct jsonrpc_request *, int, const char *, ...); +void jsonrpc_log(struct jsonrpc_request *, int, const char *, ...) + __attribute__((format (printf, 3, 4))); int jsonrpc_read_request(struct http_request *, struct jsonrpc_request *); void jsonrpc_destroy_request(struct jsonrpc_request *); int jsonrpc_error(struct jsonrpc_request *, int, const char *); diff --git a/include/kore/kore.h b/include/kore/kore.h @@ -927,9 +927,12 @@ void kore_pool_init(struct kore_pool *, const char *, void kore_pool_cleanup(struct kore_pool *); /* utils.c */ -void kore_debug_internal(char *, int, const char *, ...); -void fatal(const char *, ...) __attribute__((noreturn)); -void fatalx(const char *, ...) __attribute__((noreturn)); +void kore_debug_internal(char *, int, const char *, ...) + __attribute__((format (printf, 3, 4))); +void fatal(const char *, ...) __attribute__((noreturn)) + __attribute__((format (printf, 1, 2))); +void fatalx(const char *, ...) __attribute__((noreturn)) + __attribute__((format (printf, 1, 2))); u_int64_t kore_time_ms(void); char *kore_time_to_date(time_t); @@ -942,7 +945,8 @@ size_t kore_strlcpy(char *, const char *, const size_t); void kore_server_disconnect(struct connection *); int kore_split_string(char *, const char *, char **, size_t); void kore_strip_chars(char *, const char, char **); -int kore_snprintf(char *, size_t, int *, const char *, ...); +int kore_snprintf(char *, size_t, int *, const char *, ...) + __attribute__((format (printf, 4, 5))); long long kore_strtonum(const char *, int, long long, long long, int *); double kore_strtodouble(const char *, long double, long double, int *); int kore_base64_encode(const void *, size_t, char **); @@ -1105,8 +1109,10 @@ void kore_buf_reset(struct kore_buf *); void kore_buf_cleanup(struct kore_buf *); char *kore_buf_stringify(struct kore_buf *, size_t *); -void kore_buf_appendf(struct kore_buf *, const char *, ...); -void kore_buf_appendv(struct kore_buf *, const char *, va_list); +void kore_buf_appendf(struct kore_buf *, const char *, ...) + __attribute__((format (printf, 2, 3))); +void kore_buf_appendv(struct kore_buf *, const char *, va_list) + __attribute__((format (printf, 2, 0))); void kore_buf_replace_string(struct kore_buf *, const char *, const void *, size_t); diff --git a/src/cli.c b/src/cli.c @@ -124,9 +124,10 @@ static struct cli_buf *cli_buf_alloc(size_t); static void cli_buf_free(struct cli_buf *); static char *cli_buf_stringify(struct cli_buf *, size_t *); static void cli_buf_append(struct cli_buf *, const void *, size_t); -static void cli_buf_appendf(struct cli_buf *, const char *, ...); +static void cli_buf_appendf(struct cli_buf *, const char *, ...) + __attribute__((format (printf, 2, 3))); static void cli_buf_appendv(struct cli_buf *, const char *, - va_list); + va_list) __attribute__((format (printf, 2, 0))); static void *cli_malloc(size_t); static char *cli_strdup(const char *); @@ -138,7 +139,8 @@ static long long cli_strtonum(const char *, long long, long long); static int cli_split_string(char *, const char *, char **, size_t); static void usage(void) __attribute__((noreturn)); -static void fatal(const char *, ...) __attribute__((noreturn)); +static void fatal(const char *, ...) __attribute__((noreturn)) + __attribute__((format (printf, 1, 2))); static void cli_file_close(int); static void cli_run_kore(void); @@ -154,12 +156,14 @@ static void cli_build_cflags(struct buildopt *); static void cli_build_cxxflags(struct buildopt *); static void cli_build_ldflags(struct buildopt *); static void cli_file_read(int, char **, size_t *); -static void cli_file_writef(int, const char *, ...); +static void cli_file_writef(int, const char *, ...) + __attribute__((format (printf, 2, 3))); static void cli_file_open(const char *, int, int *); static void cli_file_remove(char *, struct dirent *); static void cli_build_asset(char *, struct dirent *); static void cli_file_write(int, const void *, size_t); -static int cli_vasprintf(char **, const char *, ...); +static int cli_vasprintf(char **, const char *, ...) + __attribute__((format (printf, 2, 3))); static void cli_spawn_proc(void (*cb)(void *), void *); static void cli_write_asset(const char *, const char *, struct buildopt *); diff --git a/src/http.c b/src/http.c @@ -1351,7 +1351,7 @@ http_body_digest(struct http_request *req, char *out, size_t len) int slen; if (len != HTTP_BODY_DIGEST_STRLEN) { - fatal("http_body_digest: bad len:%zu wanted:%zu", + fatal("http_body_digest: bad len:%zu wanted:%u", len, HTTP_BODY_DIGEST_STRLEN); } diff --git a/src/keymgr_openssl.c b/src/keymgr_openssl.c @@ -219,7 +219,8 @@ static void keymgr_acme_order_redo(void *, u_int64_t); static void keymgr_acme_order_start(void *, u_int64_t); static void keymgr_x509_ext(STACK_OF(X509_EXTENSION) *, - int, const char *, ...); + int, const char *, ...) + __attribute__((format (printf, 3, 4))); static void keymgr_acme_csr(const struct kore_keyreq *, struct key *); static void keymgr_acme_install_cert(const void *, size_t, struct key *); diff --git a/src/log.c b/src/log.c @@ -28,7 +28,8 @@ struct kore_wlog { char logmsg[]; }; -static void log_print(int, const char *, ...); +static void log_print(int, const char *, ...) + __attribute__((format (printf, 2, 3))); static void log_from_worker(struct kore_msg *, const void *); static FILE *fp = NULL; diff --git a/src/pool.c b/src/pool.c @@ -92,7 +92,7 @@ kore_pool_get(struct kore_pool *pool) entry = LIST_FIRST(&(pool->freelist)); if (entry->state != POOL_ELEMENT_FREE) - fatal("%s: element %p was not free", pool->name, entry); + fatal("%s: element %p was not free", pool->name, (void*) entry); LIST_REMOVE(entry, list); entry->state = POOL_ELEMENT_BUSY; diff --git a/src/worker.c b/src/worker.c @@ -839,7 +839,7 @@ worker_domain_check(struct kore_domain *dom) if (stat(dom->cafile, &st) == -1) fatalx("'%s': %s", dom->cafile, errno_s); if (access(dom->cafile, R_OK) == -1) - fatalx("'%s': not readable", dom->cafile, errno_s); + fatalx("'%s': not readable", dom->cafile); } }