summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-08-16 15:16:01 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-08-16 15:25:40 +1000
commit345b980c3e55645009150ef9a7ab35245e8e55db (patch)
treeb7af7e24b93b86a3d0fafbf49a65279161885ff9 /source3
parent43255a1d18b714ab108b21f5a1065a82e44e3490 (diff)
downloadsamba-345b980c3e55645009150ef9a7ab35245e8e55db.tar.gz
samba-345b980c3e55645009150ef9a7ab35245e8e55db.tar.bz2
samba-345b980c3e55645009150ef9a7ab35245e8e55db.zip
s3-torture: Use talloc more in vfstest
This matches the rest of Samba, which allocates many of these structures with talloc. Andrew Bartlett
Diffstat (limited to 'source3')
-rw-r--r--source3/torture/cmd_vfs.c19
-rw-r--r--source3/torture/vfstest.c35
2 files changed, 25 insertions, 29 deletions
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c
index 268e5c1135..f92efb9778 100644
--- a/source3/torture/cmd_vfs.c
+++ b/source3/torture/cmd_vfs.c
@@ -318,14 +318,13 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
}
}
- fsp = SMB_MALLOC_P(struct files_struct);
+ fsp = talloc_zero(vfs, struct files_struct);
if (fsp == NULL) {
return NT_STATUS_NO_MEMORY;
}
- fsp->fh = SMB_MALLOC_P(struct fd_handle);
+ fsp->fh = talloc_zero(fsp, struct fd_handle);
if (fsp->fh == NULL) {
- SAFE_FREE(fsp->fsp_name);
- SAFE_FREE(fsp);
+ TALLOC_FREE(fsp);
return NT_STATUS_NO_MEMORY;
}
fsp->conn = vfs->conn;
@@ -333,7 +332,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
status = create_synthetic_smb_fname_split(NULL, argv[1], NULL,
&smb_fname);
if (!NT_STATUS_IS_OK(status)) {
- SAFE_FREE(fsp);
+ TALLOC_FREE(fsp);
return status;
}
@@ -342,8 +341,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
fsp->fh->fd = SMB_VFS_OPEN(vfs->conn, smb_fname, fsp, flags, mode);
if (fsp->fh->fd == -1) {
printf("open: error=%d (%s)\n", errno, strerror(errno));
- SAFE_FREE(fsp->fh);
- SAFE_FREE(fsp);
+ TALLOC_FREE(fsp);
TALLOC_FREE(smb_fname);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -363,8 +361,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
if (!NT_STATUS_IS_OK(status)) {
SMB_VFS_CLOSE(fsp);
- SAFE_FREE(fsp->fh);
- SAFE_FREE(fsp);
+ TALLOC_FREE(fsp);
TALLOC_FREE(smb_fname);
return status;
}
@@ -448,9 +445,7 @@ static NTSTATUS cmd_close(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
else
printf("close: ok\n");
- TALLOC_FREE(vfs->files[fd]->fsp_name);
- SAFE_FREE(vfs->files[fd]->fh);
- SAFE_FREE(vfs->files[fd]);
+ TALLOC_FREE(vfs->files[fd]);
vfs->files[fd] = NULL;
return NT_STATUS_OK;
}
diff --git a/source3/torture/vfstest.c b/source3/torture/vfstest.c
index 40e78e87f2..3b474597e9 100644
--- a/source3/torture/vfstest.c
+++ b/source3/torture/vfstest.c
@@ -446,7 +446,7 @@ int main(int argc, char *argv[])
{
char *cmdstr = NULL;
struct cmd_set **cmd_set;
- struct vfs_state vfs = { 0, };
+ struct vfs_state *vfs;
int i;
char *filename = NULL;
char cwd[MAXPATHLEN];
@@ -501,21 +501,22 @@ int main(int argc, char *argv[])
init_guest_info();
locking_init();
serverid_parent_init(NULL);
- vfs.conn = talloc_zero(NULL, connection_struct);
- vfs.conn->share_access = FILE_GENERIC_ALL;
- vfs.conn->params = talloc_zero(vfs.conn, struct share_params);
- vfs.conn->sconn = talloc_zero(NULL, struct smbd_server_connection);
- vfs.conn->sconn->msg_ctx = messaging_init(vfs.conn->sconn, ev);
- vfs.conn->sconn->ev_ctx = ev;
- serverid_register(messaging_server_id(vfs.conn->sconn->msg_ctx), 0);
- make_session_info_guest(NULL, &vfs.conn->session_info);
- file_init(vfs.conn->sconn);
- set_conn_connectpath(vfs.conn, getcwd(cwd, sizeof(cwd)));
+ vfs = talloc_zero(NULL, struct vfs_state);
+ vfs->conn = talloc_zero(vfs, connection_struct);
+ vfs->conn->share_access = FILE_GENERIC_ALL;
+ vfs->conn->params = talloc_zero(vfs->conn, struct share_params);
+ vfs->conn->sconn = talloc_zero(NULL, struct smbd_server_connection);
+ vfs->conn->sconn->msg_ctx = messaging_init(vfs->conn->sconn, ev);
+ vfs->conn->sconn->ev_ctx = ev;
+ serverid_register(messaging_server_id(vfs->conn->sconn->msg_ctx), 0);
+ make_session_info_guest(NULL, &vfs->conn->session_info);
+ file_init(vfs->conn->sconn);
+ set_conn_connectpath(vfs->conn, getcwd(cwd, sizeof(cwd)));
for (i=0; i < 1024; i++)
- vfs.files[i] = NULL;
+ vfs->files[i] = NULL;
/* some advanced initialization stuff */
- smbd_vfs_init(vfs.conn);
+ smbd_vfs_init(vfs->conn);
if (!posix_locking_init(false)) {
return 1;
@@ -523,7 +524,7 @@ int main(int argc, char *argv[])
/* Do we have a file input? */
if (filename && filename[0]) {
- process_file(&vfs, filename);
+ process_file(vfs, filename);
return 0;
}
@@ -533,7 +534,7 @@ int main(int argc, char *argv[])
char *p = cmdstr;
while((cmd=next_command(frame, &p)) != NULL) {
- status = process_cmd(&vfs, cmd);
+ status = process_cmd(vfs, cmd);
}
TALLOC_FREE(cmd);
@@ -552,12 +553,12 @@ int main(int argc, char *argv[])
}
if (line[0] != '\n') {
- status = process_cmd(&vfs, line);
+ status = process_cmd(vfs, line);
}
SAFE_FREE(line);
}
- TALLOC_FREE(vfs.conn);
+ TALLOC_FREE(vfs);
TALLOC_FREE(frame);
return NT_STATUS_IS_OK(status) ? 0 : 1;
}