summaryrefslogtreecommitdiffstats
path: root/source3/torture/vfstest.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2014-02-26 20:16:26 +0100
committerAndrew Bartlett <abartlet@samba.org>2014-04-02 09:03:43 +0200
commit9e971068d002758be67a26dbc76fb4be949fb009 (patch)
tree2759daf8124c5a328200aa409a8b52aa097aeb5d /source3/torture/vfstest.c
parent5686c80966f3f58dbe7601c72f07662fd6cedbef (diff)
downloadsamba-9e971068d002758be67a26dbc76fb4be949fb009.tar.gz
samba-9e971068d002758be67a26dbc76fb4be949fb009.tar.xz
samba-9e971068d002758be67a26dbc76fb4be949fb009.zip
s3:torture: avoid compiler warnings in vfstest.c
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source3/torture/vfstest.c')
-rw-r--r--source3/torture/vfstest.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/source3/torture/vfstest.c b/source3/torture/vfstest.c
index 40d44c3ffe..b039ac408b 100644
--- a/source3/torture/vfstest.c
+++ b/source3/torture/vfstest.c
@@ -276,11 +276,11 @@ static void add_command_set(struct cmd_set *cmd_set)
static NTSTATUS do_cmd(struct vfs_state *vfs, struct cmd_set *cmd_entry, char *cmd)
{
const char *p = cmd;
- char **argv = NULL;
+ const char **argv = NULL;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
char *buf;
TALLOC_CTX *mem_ctx = talloc_stackframe();
- int argc = 0, i;
+ int argc = 0;
/* Count number of arguments first time through the loop then
allocate memory and strdup them. */
@@ -288,7 +288,7 @@ static NTSTATUS do_cmd(struct vfs_state *vfs, struct cmd_set *cmd_entry, char *c
again:
while(next_token_talloc(mem_ctx, &p, &buf, " ")) {
if (argv) {
- argv[argc] = SMB_STRDUP(buf);
+ argv[argc] = talloc_strdup(argv, buf);
}
argc++;
}
@@ -296,10 +296,8 @@ static NTSTATUS do_cmd(struct vfs_state *vfs, struct cmd_set *cmd_entry, char *c
if (!argv) {
/* Create argument list */
- argv = SMB_MALLOC_ARRAY(char *, argc);
- memset(argv, 0, sizeof(char *) * argc);
-
- if (!argv) {
+ argv = talloc_zero_array(mem_ctx, const char *, argc);
+ if (argv == NULL) {
fprintf(stderr, "out of memory\n");
result = NT_STATUS_NO_MEMORY;
goto done;
@@ -326,10 +324,9 @@ static NTSTATUS do_cmd(struct vfs_state *vfs, struct cmd_set *cmd_entry, char *c
/* Cleanup */
if (argv) {
- for (i = 0; i < argc; i++)
- SAFE_FREE(argv[i]);
-
- SAFE_FREE(argv);
+ char **_argv = discard_const_p(char *, argv);
+ TALLOC_FREE(_argv);
+ argv = NULL;
}
if (memreports != 0) {
@@ -418,12 +415,14 @@ static void process_file(struct vfs_state *pvfs, char *filename) {
}
}
+static void vfstest_exit_server(const char * const reason) _NORETURN_;
static void vfstest_exit_server(const char * const reason)
{
DEBUG(3,("Server exit (%s)\n", (reason ? reason : "")));
exit(0);
}
+static void vfstest_exit_server_cleanly(const char * const reason) _NORETURN_;
static void vfstest_exit_server_cleanly(const char * const reason)
{
vfstest_exit_server("normal exit");
@@ -433,6 +432,7 @@ struct smb_request *vfstest_get_smbreq(TALLOC_CTX *mem_ctx,
struct vfs_state *vfs)
{
struct smb_request *result;
+ uint8_t *inbuf;
result = talloc_zero(mem_ctx, struct smb_request);
if (result == NULL) {
@@ -441,12 +441,13 @@ struct smb_request *vfstest_get_smbreq(TALLOC_CTX *mem_ctx,
result->sconn = vfs->conn->sconn;
result->mid = ++vfs->mid;
- result->inbuf = talloc_array(result, uint8_t, smb_size);
- if (result->inbuf == NULL) {
+ inbuf = talloc_array(result, uint8_t, smb_size);
+ if (inbuf == NULL) {
goto fail;
}
- SSVAL(result->inbuf, smb_mid, result->mid);
- smb_setlen(result->inbuf, smb_size-4);
+ SSVAL(inbuf, smb_mid, result->mid);
+ smb_setlen(inbuf, smb_size-4);
+ result->inbuf = inbuf;
return result;
fail:
TALLOC_FREE(result);
@@ -455,7 +456,7 @@ fail:
/* Main function */
-int main(int argc, char *argv[])
+int main(int argc, const char *argv[])
{
char *cmdstr = NULL;
struct cmd_set **cmd_set;
@@ -490,8 +491,7 @@ int main(int argc, char *argv[])
setlinebuf(stdout);
- pc = poptGetContext("vfstest", argc, (const char **) argv,
- long_options, 0);
+ pc = poptGetContext("vfstest", argc, argv, long_options, 0);
while(poptGetNextOpt(pc) != -1);