s3:smbd: modernize conn_new()
[samba.git] / source3 / smbd / conn.c
index 8f472c0d2458f742edccf441a90840f2900a442a..ca973b0d6aa6f8dc918813424b720917a0620a80 100644 (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;
        }