]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Initialize pointers in server_prefork.c
authorVolker Lendecke <vl@samba.org>
Sun, 27 Dec 2020 07:50:34 +0000 (08:50 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 8 Jan 2021 20:31:33 +0000 (20:31 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/lib/server_prefork.c

index 8fa3cce7746891186610cbe35e082d02e4da3cb9..344bff0efa22e9554daae6866ac037d7734852fe 100644 (file)
@@ -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 {