From: Volker Lendecke Date: Sun, 27 Dec 2020 07:50:34 +0000 (+0100) Subject: lib: Initialize pointers in server_prefork.c X-Git-Tag: samba-4.14.0rc1~142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56737df462d70397b436e3b91f1b643f5854adf1;p=thirdparty%2Fsamba.git lib: Initialize pointers in server_prefork.c Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/lib/server_prefork.c b/source3/lib/server_prefork.c index 8fa3cce7746..344bff0efa2 100644 --- a/source3/lib/server_prefork.c +++ b/source3/lib/server_prefork.c @@ -61,7 +61,7 @@ bool prefork_create_pool(TALLOC_CTX *mem_ctx, prefork_main_fn_t *main_fn, void *private_data, struct prefork_pool **pf_pool) { - struct prefork_pool *pfp; + struct prefork_pool *pfp = NULL; pid_t pid; time_t now = time(NULL); size_t data_size; @@ -152,7 +152,7 @@ fail: */ int prefork_expand_pool(struct prefork_pool *pfp, int new_max) { - struct prefork_pool *pool; + struct prefork_pool *pool = NULL; size_t old_size; size_t new_size; int ret; @@ -255,7 +255,7 @@ int prefork_retire_children(struct messaging_context *msg_ctx, { const DATA_BLOB ping = data_blob_null; time_t now = time(NULL); - struct prefork_oldest *oldest; + struct prefork_oldest *oldest = NULL; int i, j; oldest = talloc_array(pfp, struct prefork_oldest, pfp->pool_size); @@ -460,9 +460,8 @@ static void prefork_sigchld_handler(struct tevent_context *ev_ctx, int signum, int count, void *siginfo, void *pvt) { - struct prefork_pool *pfp; - - pfp = talloc_get_type_abort(pvt, struct prefork_pool); + struct prefork_pool *pfp = talloc_get_type_abort( + pvt, struct prefork_pool); /* run the cleanup function to make sure all dead children are * properly and timely retired. */ @@ -476,7 +475,7 @@ static void prefork_sigchld_handler(struct tevent_context *ev_ctx, static bool prefork_setup_sigchld_handler(struct tevent_context *ev_ctx, struct prefork_pool *pfp) { - struct tevent_signal *se; + struct tevent_signal *se = NULL; se = tevent_add_signal(ev_ctx, pfp, SIGCHLD, 0, prefork_sigchld_handler, pfp); @@ -530,11 +529,11 @@ struct tevent_req *prefork_listen_send(TALLOC_CTX *mem_ctx, int listen_fd_size, struct pf_listen_fd *listen_fds) { - struct tevent_req *req; - struct pf_listen_state *state; - struct pf_listen_ctx *ctx; - struct tevent_fd *fde; - TALLOC_CTX *fde_ctx; + struct tevent_req *req = NULL; + struct pf_listen_state *state = NULL; + struct pf_listen_ctx *ctx = NULL; + struct tevent_fd *fde = NULL; + TALLOC_CTX *fde_ctx = NULL; int i; req = tevent_req_create(mem_ctx, &state, struct pf_listen_state); @@ -583,9 +582,11 @@ static void prefork_listen_accept_handler(struct tevent_context *ev, struct tevent_fd *fde, uint16_t flags, void *pvt) { - struct pf_listen_state *state; - struct tevent_req *req; - struct pf_listen_ctx *ctx; + struct pf_listen_ctx *ctx = talloc_get_type_abort( + pvt, struct pf_listen_ctx); + struct tevent_req *req = ctx->req; + struct pf_listen_state *state = tevent_req_data( + ctx->req, struct pf_listen_state); struct sockaddr_storage addr; socklen_t addrlen; int soerr = 0; @@ -593,10 +594,6 @@ static void prefork_listen_accept_handler(struct tevent_context *ev, int sd = -1; int ret; - ctx = talloc_get_type_abort(pvt, struct pf_listen_ctx); - req = ctx->req; - state = tevent_req_data(ctx->req, struct pf_listen_state); - if ((state->pf->cmds == PF_SRV_MSG_EXIT) && (state->pf->num_clients <= 0)) { /* We have been asked to exit, so drop here and the next @@ -669,11 +666,10 @@ int prefork_listen_recv(struct tevent_req *req, struct tsocket_address **srv_addr, struct tsocket_address **cli_addr) { - struct pf_listen_state *state; + struct pf_listen_state *state = tevent_req_data( + req, struct pf_listen_state); int ret = 0; - state = tevent_req_data(req, struct pf_listen_state); - if (state->error) { ret = state->error; } else {