diff options
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/mod_authn_sasl.c | 4 | ||||
-rw-r--r-- | src/mod_deflate.c | 2 | ||||
-rw-r--r-- | src/mod_skeleton.c | 2 | ||||
-rw-r--r-- | src/plugin.c | 72 | ||||
-rw-r--r-- | src/plugin.h | 2 | ||||
-rw-r--r-- | src/stat_cache.c | 2 | ||||
-rw-r--r-- | src/t/test_common.c | 2 | ||||
-rw-r--r-- | src/t/test_mod.c | 2 |
9 files changed, 57 insertions, 33 deletions
diff --git a/configure.ac b/configure.ac index 7fcba4b3..8aa15dad 100644 --- a/configure.ac +++ b/configure.ac @@ -1525,7 +1525,7 @@ if test "$ac_cv_func_sendfile" = yes; then #include <sys/types.h> #include <sys/socket.h> #include <sys/uio.h> - int main() { + int main(void) { int o = 0; if (-1 == sendfile(-1, 0, &o, 0) && errno == ENOSYS) return -1; return 0; diff --git a/src/mod_authn_sasl.c b/src/mod_authn_sasl.c index 43d6e5b0..4c0a2335 100644 --- a/src/mod_authn_sasl.c +++ b/src/mod_authn_sasl.c @@ -258,8 +258,8 @@ static handler_t mod_authn_sasl_query(request_st * const r, void *p_d, const buf plugin_data *p = (plugin_data *)p_d; sasl_conn_t *sc; sasl_callback_t const cb[] = { - { SASL_CB_GETOPT, (int(*)())mod_authn_sasl_cb_getopt, (void *) p }, - { SASL_CB_LOG, (int(*)())mod_authn_sasl_cb_log, (void *) r }, + { SASL_CB_GETOPT, (int(*)(void))(uintptr_t)mod_authn_sasl_cb_getopt, (void *) p }, + { SASL_CB_LOG, (int(*)(void))(uintptr_t)mod_authn_sasl_cb_log, (void *) r }, { SASL_CB_LIST_END, NULL, NULL } }; int rc; diff --git a/src/mod_deflate.c b/src/mod_deflate.c index 6eac8d20..d8322d32 100644 --- a/src/mod_deflate.c +++ b/src/mod_deflate.c @@ -239,7 +239,7 @@ typedef struct { chunkqueue in_queue; } handler_ctx; -static handler_ctx *handler_ctx_init() { +static handler_ctx *handler_ctx_init(void) { handler_ctx * const hctx = ck_calloc(1, sizeof(*hctx)); chunkqueue_init(&hctx->in_queue); hctx->cache_fd = -1; diff --git a/src/mod_skeleton.c b/src/mod_skeleton.c index f461ccb8..793e0dfa 100644 --- a/src/mod_skeleton.c +++ b/src/mod_skeleton.c @@ -41,7 +41,7 @@ typedef struct { size_t foo; } handler_ctx; -static handler_ctx * handler_ctx_init() { +static handler_ctx * handler_ctx_init(void) { return ck_calloc(1, sizeof(handler_ctx)); } diff --git a/src/plugin.c b/src/plugin.c index 1fc1d00d..18a2f54e 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -251,17 +251,41 @@ int plugins_load(server *srv) { #endif /* defined(LIGHTTPD_STATIC) */ +typedef handler_t(*pl_cb_t)(void *, void *); + +/*(alternative to multiple structs would be union for fn ptr type)*/ + typedef struct { - handler_t(*fn)(); + pl_cb_t fn; plugin_data_base *data; } plugin_fn_data; +typedef struct { + handler_t(*fn)(request_st *, void *); + plugin_data_base *data; +} plugin_fn_req_data; + +typedef struct { + handler_t(*fn)(connection *, void *); + plugin_data_base *data; +} plugin_fn_con_data; + +typedef struct { + handler_t(*fn)(server *, void *); + plugin_data_base *data; +} plugin_fn_srv_data; + +typedef struct { + handler_t(*fn)(server *, void *, pid_t, int); + plugin_data_base *data; +} plugin_fn_waitpid_data; + __attribute_hot__ static handler_t plugins_call_fn_req_data(request_st * const r, const int e) { const void * const plugin_slots = r->con->plugin_slots; const uint32_t offset = ((const uint16_t *)plugin_slots)[e]; if (0 == offset) return HANDLER_GO_ON; - const plugin_fn_data *plfd = (const plugin_fn_data *) + const plugin_fn_req_data *plfd = (const plugin_fn_req_data *) (((uintptr_t)plugin_slots) + offset); handler_t rc = HANDLER_GO_ON; while (plfd->fn && (rc = plfd->fn(r, plfd->data)) == HANDLER_GO_ON) @@ -274,7 +298,7 @@ static handler_t plugins_call_fn_con_data(connection * const con, const int e) { const void * const plugin_slots = con->plugin_slots; const uint32_t offset = ((const uint16_t *)plugin_slots)[e]; if (0 == offset) return HANDLER_GO_ON; - const plugin_fn_data *plfd = (const plugin_fn_data *) + const plugin_fn_con_data *plfd = (const plugin_fn_con_data *) (((uintptr_t)plugin_slots) + offset); handler_t rc = HANDLER_GO_ON; while (plfd->fn && (rc = plfd->fn(con, plfd->data)) == HANDLER_GO_ON) @@ -285,7 +309,7 @@ static handler_t plugins_call_fn_con_data(connection * const con, const int e) { static handler_t plugins_call_fn_srv_data(server * const srv, const int e) { const uint32_t offset = ((const uint16_t *)srv->plugin_slots)[e]; if (0 == offset) return HANDLER_GO_ON; - const plugin_fn_data *plfd = (const plugin_fn_data *) + const plugin_fn_srv_data *plfd = (const plugin_fn_srv_data *) (((uintptr_t)srv->plugin_slots) + offset); handler_t rc = HANDLER_GO_ON; while (plfd->fn && (rc = plfd->fn(srv,plfd->data)) == HANDLER_GO_ON) @@ -296,7 +320,7 @@ static handler_t plugins_call_fn_srv_data(server * const srv, const int e) { static void plugins_call_fn_srv_data_all(server * const srv, const int e) { const uint32_t offset = ((const uint16_t *)srv->plugin_slots)[e]; if (0 == offset) return; - const plugin_fn_data *plfd = (const plugin_fn_data *) + const plugin_fn_srv_data *plfd = (const plugin_fn_srv_data *) (((uintptr_t)srv->plugin_slots) + offset); for (; plfd->fn; ++plfd) plfd->fn(srv, plfd->data); @@ -368,7 +392,7 @@ handler_t plugins_call_handle_waitpid(server *srv, pid_t pid, int status) { const uint32_t offset = ((const uint16_t *)srv->plugin_slots)[PLUGIN_FUNC_HANDLE_WAITPID]; if (0 == offset) return HANDLER_GO_ON; - const plugin_fn_data *plfd = (const plugin_fn_data *) + const plugin_fn_waitpid_data *plfd = (const plugin_fn_waitpid_data *) (((uintptr_t)srv->plugin_slots) + offset); handler_t rc = HANDLER_GO_ON; while (plfd->fn&&(rc=plfd->fn(srv,plfd->data,pid,status))==HANDLER_GO_ON) @@ -407,7 +431,7 @@ static void plugins_call_init_reverse(server *srv, const uint32_t offset) { } __attribute_cold__ -static void plugins_call_init_slot(server *srv, handler_t(*fn)(), void *data, const uint32_t offset) { +static void plugins_call_init_slot(server *srv, pl_cb_t fn, void *data, const uint32_t offset) { if (fn) { plugin_fn_data *plfd = (plugin_fn_data *) (((uintptr_t)srv->plugin_slots) + offset); @@ -502,7 +526,7 @@ handler_t plugins_call_init(server *srv) { /* add handle_uri_raw before handle_uri_clean, but in same slot */ for (uint32_t i = 0; i < srv->plugins.used; ++i) { plugin * const p = ps[i]; - plugins_call_init_slot(srv, p->handle_uri_raw, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->handle_uri_raw, p->data, offsets[PLUGIN_FUNC_HANDLE_URI_CLEAN]); } @@ -510,37 +534,37 @@ handler_t plugins_call_init(server *srv) { plugin * const p = ps[i]; if (!p->handle_uri_raw) - plugins_call_init_slot(srv, p->handle_uri_clean, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->handle_uri_clean, p->data, offsets[PLUGIN_FUNC_HANDLE_URI_CLEAN]); - plugins_call_init_slot(srv, p->handle_request_env, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->handle_request_env, p->data, offsets[PLUGIN_FUNC_HANDLE_REQUEST_ENV]); - plugins_call_init_slot(srv, p->handle_request_done, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->handle_request_done, p->data, offsets[PLUGIN_FUNC_HANDLE_REQUEST_DONE]); - plugins_call_init_slot(srv, p->handle_connection_accept, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->handle_connection_accept, p->data, offsets[PLUGIN_FUNC_HANDLE_CONNECTION_ACCEPT]); - plugins_call_init_slot(srv, p->handle_connection_shut_wr, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->handle_connection_shut_wr, p->data, offsets[PLUGIN_FUNC_HANDLE_CONNECTION_SHUT_WR]); - plugins_call_init_slot(srv, p->handle_connection_close, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->handle_connection_close, p->data, offsets[PLUGIN_FUNC_HANDLE_CONNECTION_CLOSE]); - plugins_call_init_slot(srv, p->handle_trigger, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->handle_trigger, p->data, offsets[PLUGIN_FUNC_HANDLE_TRIGGER]); - plugins_call_init_slot(srv, p->handle_sighup, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->handle_sighup, p->data, offsets[PLUGIN_FUNC_HANDLE_SIGHUP]); - plugins_call_init_slot(srv, p->handle_waitpid, p->data, + plugins_call_init_slot(srv, (pl_cb_t)(uintptr_t)p->handle_waitpid, p->data, offsets[PLUGIN_FUNC_HANDLE_WAITPID]); - plugins_call_init_slot(srv, p->handle_subrequest_start, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->handle_subrequest_start, p->data, offsets[PLUGIN_FUNC_HANDLE_SUBREQUEST_START]); - plugins_call_init_slot(srv, p->handle_response_start, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->handle_response_start, p->data, offsets[PLUGIN_FUNC_HANDLE_RESPONSE_START]); - plugins_call_init_slot(srv, p->handle_docroot, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->handle_docroot, p->data, offsets[PLUGIN_FUNC_HANDLE_DOCROOT]); - plugins_call_init_slot(srv, p->handle_physical, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->handle_physical, p->data, offsets[PLUGIN_FUNC_HANDLE_PHYSICAL]); - plugins_call_init_slot(srv, p->handle_request_reset, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->handle_request_reset, p->data, offsets[PLUGIN_FUNC_HANDLE_REQUEST_RESET]); - plugins_call_init_slot(srv, p->set_defaults, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->set_defaults, p->data, offsets[PLUGIN_FUNC_SET_DEFAULTS]); - plugins_call_init_slot(srv, p->worker_init, p->data, + plugins_call_init_slot(srv, (pl_cb_t)p->worker_init, p->data, offsets[PLUGIN_FUNC_WORKER_INIT]); } diff --git a/src/plugin.h b/src/plugin.h index 1f64034c..13bf1ee5 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -63,7 +63,7 @@ struct plugin { handler_t (* handle_sighup) (server *srv, void *p_d); /* at a sighup */ handler_t (* handle_waitpid) (server *srv, void *p_d, pid_t pid, int status); /* upon a child process exit */ - void *(* init) (); + void *(* init) (void); handler_t (* priv_defaults) (server *srv, void *p_d); handler_t (* set_defaults) (server *srv, void *p_d); handler_t (* worker_init) (server *srv, void *p_d); /* at server startup (each worker after fork()) */ diff --git a/src/stat_cache.c b/src/stat_cache.c index ed52fca2..6d12b7eb 100644 --- a/src/stat_cache.c +++ b/src/stat_cache.c @@ -294,7 +294,7 @@ static void fam_dir_tag_refcnt(splay_tree *t, int *keys, int *ndx) } __attribute_noinline__ -static void fam_dir_periodic_cleanup() { +static void fam_dir_periodic_cleanup(void) { stat_cache_fam * const scf = sc.scf; int max_ndx, i; int keys[512]; /* 2k size on stack */ diff --git a/src/t/test_common.c b/src/t/test_common.c index edd850b9..6a968b53 100644 --- a/src/t/test_common.c +++ b/src/t/test_common.c @@ -12,7 +12,7 @@ void test_http_kv (void); void test_keyvalue (void); void test_request (void); -int main() { +int main(void) { test_array(); test_base64(); test_buffer(); diff --git a/src/t/test_mod.c b/src/t/test_mod.c index 19a58261..8eedf47f 100644 --- a/src/t/test_mod.c +++ b/src/t/test_mod.c @@ -12,7 +12,7 @@ void test_mod_ssi (void); void test_mod_staticfile (void); void test_mod_userdir (void); -int main() { +int main(void) { test_mod_access(); test_mod_alias(); test_mod_evhost(); |