s4/smdb: cppcheck: fix nullPointer: Possible null pointer dereference warning.
[samba.git] / source4 / smbd / server.c
index badc21270c08b90081719b7981676bd09abaad9c..eb43f28e6b86f414f854e10ae4665723e59cb5a8 100644 (file)
@@ -381,7 +381,9 @@ static NTSTATUS setup_parent_messaging(struct server_state *state,
 {
        struct imessaging_context *msg;
        NTSTATUS status;
-
+       if (state == NULL) {
+               return NT_STATUS_UNSUCCESSFUL;
+       }
        msg = imessaging_init(state->event_ctx,
                              lp_ctx,
                              cluster_id(getpid(), SAMBA_PARENT_TASKID),
@@ -645,6 +647,11 @@ static int binary_smbd_main(const char *binary_name,
        state = talloc_zero(NULL, struct server_state);
        if (state == NULL) {
                exit_daemon("Samba cannot create server state", ENOMEM);
+               /*
+                * return is never reached but is here to satisfy static
+                * checkers
+                */
+               return 1;
        };
        state->binary_name = binary_name;
 
@@ -666,6 +673,11 @@ static int binary_smbd_main(const char *binary_name,
                        TALLOC_FREE(state);
                        exit_daemon("Samba cannot open schannel store "
                                "for secured NETLOGON operations.", EACCES);
+                       /*
+                        * return is never reached but is here to satisfy static
+                        * checkers
+                        */
+                       return 1;
                }
        }
 
@@ -674,6 +686,11 @@ static int binary_smbd_main(const char *binary_name,
                TALLOC_FREE(state);
                exit_daemon("Samba failed to disable recusive "
                        "winbindd calls.", EACCES);
+               /*
+                * return is never reached but is here to satisfy static
+                * checkers
+                */
+               return 1;
        }
 
        gensec_init(); /* FIXME: */
@@ -694,6 +711,11 @@ static int binary_smbd_main(const char *binary_name,
        if (state->event_ctx == NULL) {
                TALLOC_FREE(state);
                exit_daemon("Initializing event context failed", EACCES);
+               /*
+                * return is never reached but is here to satisfy static
+                * checkers
+                */
+               return 1;
        }
 
        talloc_set_destructor(state->event_ctx, event_ctx_destructor);
@@ -724,6 +746,11 @@ static int binary_smbd_main(const char *binary_name,
                TALLOC_FREE(state);
                exit_daemon("Samba failed to set standard input handler",
                                ENOTTY);
+               /*
+                * return is never reached but is here to satisfy static
+                * checkers
+                */
+               return 1;
        }
 
        if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) {
@@ -736,6 +763,11 @@ static int binary_smbd_main(const char *binary_name,
                if (fde == NULL) {
                        TALLOC_FREE(state);
                        exit_daemon("Initializing stdin failed", ENOMEM);
+                       /*
+                        * return is never reached but is here to
+                        * satisfy static checkers
+                        */
+                       return 1;
                }
        }
 
@@ -752,7 +784,12 @@ static int binary_smbd_main(const char *binary_name,
                if (te == NULL) {
                        TALLOC_FREE(state);
                        exit_daemon("Maxruntime handler failed", ENOMEM);
-               }
+                       /*
+                        * return is never reached but is here to
+                        * satisfy static checkers
+                        */
+                       return 1;
+                       }
        }
 
        se = tevent_add_signal(state->event_ctx,
@@ -764,6 +801,11 @@ static int binary_smbd_main(const char *binary_name,
        if (se == NULL) {
                TALLOC_FREE(state);
                exit_daemon("Initialize SIGTERM handler failed", ENOMEM);
+               /*
+                * return is never reached but is here to satisfy static
+                * checkers
+                */
+               return 1;
        }
 
        if (lpcfg_server_role(cmdline_lp_ctx) != ROLE_ACTIVE_DIRECTORY_DC
@@ -790,12 +832,22 @@ static int binary_smbd_main(const char *binary_name,
        if (ret != LDB_SUCCESS) {
                TALLOC_FREE(state);
                exit_daemon("Samba failed to prime database", EINVAL);
+               /*
+                * return is never reached but is here to satisfy static
+                * checkers
+                */
+               return 1;
        }
 
        if (db_is_backup) {
                TALLOC_FREE(state);
                exit_daemon("Database is a backup. Please run samba-tool domain"
                            " backup restore", EINVAL);
+               /*
+                * return is never reached but is here to satisfy static
+                * checkers
+                */
+               return 1;
        }
 
        status = setup_parent_messaging(state, cmdline_lp_ctx);
@@ -803,6 +855,11 @@ static int binary_smbd_main(const char *binary_name,
                TALLOC_FREE(state);
                exit_daemon("Samba failed to setup parent messaging",
                        NT_STATUS_V(status));
+               /*
+                * return is never reached but is here to satisfy static
+                * checkers
+                */
+               return 1;
        }
 
        DBG_ERR("%s: using '%s' process model\n", binary_name, model);
@@ -817,6 +874,11 @@ static int binary_smbd_main(const char *binary_name,
                        TALLOC_FREE(state);
                        exit_daemon("Samba failed to open process control pipe",
                                    errno);
+                       /*
+                        * return is never reached but is here to satisfy static
+                        * checkers
+                        */
+                       return 1;
                }
                smb_set_close_on_exec(child_pipe[0]);
                smb_set_close_on_exec(child_pipe[1]);
@@ -853,6 +915,11 @@ static int binary_smbd_main(const char *binary_name,
                                TALLOC_FREE(state);
                                exit_daemon("Samba failed to start services",
                                NT_STATUS_V(status));
+                               /*
+                                * return is never reached but is here to
+                                * satisfy static checkers
+                                */
+                               return 1;
                        }
                }
        }