mirror of
https://github.com/samba-team/samba.git
synced 2025-08-05 12:22:11 +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:
committed by
Jeremy Allison
parent
04f5dbb168
commit
c9b38eb79c
@ -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_new(struct smbd_server_connection *sconn)
|
||||||
{
|
{
|
||||||
connection_struct *conn;
|
connection_struct *conn = NULL;
|
||||||
|
|
||||||
if (!(conn=talloc_zero(NULL, connection_struct)) ||
|
conn = talloc_zero(NULL, connection_struct);
|
||||||
!(conn->params = talloc(conn, struct share_params)) ||
|
if (conn == NULL) {
|
||||||
!(conn->vuid_cache = talloc_zero(conn, struct vuid_cache)) ||
|
DBG_ERR("talloc_zero failed\n");
|
||||||
!(conn->connectpath = talloc_strdup(conn, "")) ||
|
return NULL;
|
||||||
!(conn->origpath = talloc_strdup(conn, ""))) {
|
}
|
||||||
DEBUG(0,("TALLOC_ZERO() failed!\n"));
|
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);
|
TALLOC_FREE(conn);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user