1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

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 <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme
2019-08-15 15:15:30 +02:00
committed by Jeremy Allison
parent 04f5dbb168
commit c9b38eb79c

View File

@ -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;
}