From: Ralph Boehme Date: Thu, 15 Aug 2019 13:15:30 +0000 (+0200) Subject: s3:smbd: modernize conn_new() X-Git-Tag: tdb-1.4.2~103 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9b38eb79c99ad054231950e6d56a86da1061f8c;p=thirdparty%2Fsamba.git s3:smbd: modernize conn_new() Split the monstrous if into individual allocations. I'm going to add more talloc allocations in a subsequent commit, so it's time to split this up. Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c index 8f472c0d245..ca973b0d6aa 100644 --- a/source3/smbd/conn.c +++ b/source3/smbd/conn.c @@ -59,14 +59,34 @@ bool conn_snum_used(struct smbd_server_connection *sconn, connection_struct *conn_new(struct smbd_server_connection *sconn) { - connection_struct *conn; + connection_struct *conn = NULL; - if (!(conn=talloc_zero(NULL, connection_struct)) || - !(conn->params = talloc(conn, struct share_params)) || - !(conn->vuid_cache = talloc_zero(conn, struct vuid_cache)) || - !(conn->connectpath = talloc_strdup(conn, "")) || - !(conn->origpath = talloc_strdup(conn, ""))) { - DEBUG(0,("TALLOC_ZERO() failed!\n")); + conn = talloc_zero(NULL, connection_struct); + if (conn == NULL) { + DBG_ERR("talloc_zero failed\n"); + return NULL; + } + conn->params = talloc(conn, struct share_params); + if (conn->params == NULL) { + DBG_ERR("talloc_zero failed\n"); + TALLOC_FREE(conn); + return NULL; + } + conn->vuid_cache = talloc_zero(conn, struct vuid_cache); + if (conn->vuid_cache == NULL) { + DBG_ERR("talloc_zero failed\n"); + TALLOC_FREE(conn); + return NULL; + } + conn->connectpath = talloc_strdup(conn, ""); + if (conn->connectpath == NULL) { + DBG_ERR("talloc_zero failed\n"); + TALLOC_FREE(conn); + return NULL; + } + conn->origpath = talloc_strdup(conn, ""); + if (conn->origpath == NULL) { + DBG_ERR("talloc_zero failed\n"); TALLOC_FREE(conn); return NULL; }