]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Remove the one-line conn_free() wrapper function
authorVolker Lendecke <vl@samba.org>
Fri, 17 Oct 2025 12:10:49 +0000 (14:10 +0200)
committerVolker Lendecke <vl@samba.org>
Wed, 7 Jan 2026 09:57:40 +0000 (09:57 +0000)
In case there's more things to do here we should put it into the
destructor.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/rpc_server/mdssvc/mdssvc.c
source3/smbd/conn.c
source3/smbd/msdfs.c
source3/smbd/proto.h
source3/smbd/smb1_service.c
source3/smbd/smb2_service.c

index 2f75e2dc61b67fe2e736cb8fa7e21ee56ad8c4ed..8704623a30f624b1d80322aab45a69b1db7b7cc3 100644 (file)
@@ -1622,7 +1622,7 @@ static int mds_ctx_destructor_cb(struct mds_ctx *mds_ctx)
 
        if (mds_ctx->conn != NULL) {
                SMB_VFS_DISCONNECT(mds_ctx->conn);
-               conn_free(mds_ctx->conn);
+               TALLOC_FREE(mds_ctx->conn);
        }
 
        ZERO_STRUCTP(mds_ctx);
index f1c75e292051245276a1583a0af3ad03f70c46f2..f4169b36eb14da032881aa7364df267eb77c17ea 100644 (file)
@@ -131,10 +131,6 @@ connection_struct *conn_new(struct smbd_server_connection *sconn)
        DLIST_ADD(sconn->connections, conn);
        sconn->num_connections++;
 
-       /*
-        * Catches the case where someone forgets to call
-        * conn_free().
-        */
        talloc_set_destructor(conn, conn_struct_destructor);
        return conn;
 
@@ -241,15 +237,6 @@ static void conn_free_internal(connection_struct *conn)
        ZERO_STRUCTP(conn);
 }
 
-/****************************************************************************
- Free a conn structure.
-****************************************************************************/
-
-void conn_free(connection_struct *conn)
-{
-       TALLOC_FREE(conn);
-}
-
 /*
  * Correctly initialize a share with case options.
  */
index 5761725264385e80d713e24fdda1f6f591ba0135..e09c2a83a61441659f390a224df3153fec6a4333 100644 (file)
@@ -272,7 +272,7 @@ static NTSTATUS create_conn_struct_as_root(TALLOC_CTX *ctx,
                                    "denied due to security "
                                    "descriptor.\n",
                                    servicename);
-                       conn_free(conn);
+                       TALLOC_FREE(conn);
                        return NT_STATUS_ACCESS_DENIED;
                }
                conn->read_only = true;
@@ -281,21 +281,21 @@ static NTSTATUS create_conn_struct_as_root(TALLOC_CTX *ctx,
        if (!smbd_vfs_init(conn)) {
                NTSTATUS status = map_nt_error_from_unix(errno);
                DBG_ERR("smbd_vfs_init failed.\n");
-               conn_free(conn);
+               TALLOC_FREE(conn);
                return status;
        }
 
        /* this must be the first filesystem operation that we do */
        if (SMB_VFS_CONNECT(conn, servicename, vfs_user) < 0) {
                DBG_ERR("VFS connect failed!\n");
-               conn_free(conn);
+               TALLOC_FREE(conn);
                return NT_STATUS_UNSUCCESSFUL;
        }
 
        ok = canonicalize_connect_path(conn);
        if (!ok) {
                DBG_ERR("Failed to canonicalize sharepath\n");
-               conn_free(conn);
+               TALLOC_FREE(conn);
                return NT_STATUS_ACCESS_DENIED;
        }
 
@@ -313,7 +313,7 @@ static int conn_struct_tos_destructor(struct conn_struct_tos *c)
                TALLOC_FREE(c->oldcwd_fname);
        }
        SMB_VFS_DISCONNECT(c->conn);
-       conn_free(c->conn);
+       TALLOC_FREE(c->conn);
        return 0;
 }
 
index 2c71a246aeb8d34f3d193ff8e38c12c539f2f9eb..7e34cd4443ef975ba9357579436d7c887ed44693 100644 (file)
@@ -157,7 +157,6 @@ bool conn_using_smb2(struct smbd_server_connection *sconn);
 connection_struct *conn_new(struct smbd_server_connection *sconn);
 bool conn_idle_all(struct smbd_server_connection *sconn, time_t t);
 void conn_clear_vuid_caches(struct smbd_server_connection *sconn, uint64_t vuid);
-void conn_free(connection_struct *conn);
 void conn_setup_case_options(connection_struct *conn);
 void conn_force_tdis(
        struct smbd_server_connection *sconn,
index 99541010c40d1a27f26871f3133085cc8a4f27d1..fc4fa11b75a4b89a6eab5ed7e9eef9f6b15fb346 100644 (file)
@@ -104,7 +104,7 @@ static connection_struct *make_connection_smb1(struct smb_request *req,
                                        req->session,
                                        pdev);
        if (!NT_STATUS_IS_OK(*pstatus)) {
-               conn_free(conn);
+               TALLOC_FREE(conn);
                TALLOC_FREE(tcon);
                return NULL;
        }
index e43c3d9faa2a4b4db95aca1a3f74cedf96e52a16..9f4035efce3287436b4999a539d9fa64060556f1 100644 (file)
@@ -899,7 +899,7 @@ connection_struct *make_connection_smb2(struct smbd_smb2_request *req,
                                        req->session,
                                        pdev);
        if (!NT_STATUS_IS_OK(*pstatus)) {
-               conn_free(conn);
+               TALLOC_FREE(conn);
                return NULL;
        }
        return conn;
@@ -970,5 +970,5 @@ void close_cnum(connection_struct *conn,
                TALLOC_FREE(cmd);
        }
 
-       conn_free(conn);
+       TALLOC_FREE(conn);
 }