r4791: used the new talloc type safety macros to make the "void *private"
authorAndrew Tridgell <tridge@samba.org>
Sun, 16 Jan 2005 23:23:45 +0000 (23:23 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:08:55 +0000 (13:08 -0500)
pointers in the composite code type safe.

This is a bit of an experiement, I'd be interested in comments on
whether we should use this more widely.
(This used to be commit 0e1da827b380998355f75f4ef4f424802059c278)

source4/libcli/composite/connect.c
source4/libcli/composite/loadfile.c
source4/libcli/composite/savefile.c
source4/libcli/composite/sesssetup.c
source4/libcli/raw/clisocket.c

index bc39cc99fc5817bae709e15fdc168cbdd07d267c..bdb1b4d263131b61178b90fa8bda925fb9bf6d5c 100644 (file)
@@ -53,7 +53,7 @@ static void composite_handler(struct smbcli_composite *);
 static NTSTATUS connect_send_negprot(struct smbcli_composite *c, 
                                     struct smb_composite_connect *io)
 {
-       struct connect_state *state = c->private;
+       struct connect_state *state = talloc_get_type(c->private, struct connect_state);
 
        state->req = smb_raw_negotiate_send(state->transport, lp_maxprotocol());
        NT_STATUS_HAVE_NO_MEMORY(state->req);
@@ -72,7 +72,7 @@ static NTSTATUS connect_send_negprot(struct smbcli_composite *c,
 static NTSTATUS connect_tcon(struct smbcli_composite *c, 
                             struct smb_composite_connect *io)
 {
-       struct connect_state *state = c->private;
+       struct connect_state *state = talloc_get_type(c->private, struct connect_state);
        NTSTATUS status;
 
        status = smb_tree_connect_recv(state->req, c, state->io_tcon);
@@ -104,7 +104,7 @@ static NTSTATUS connect_tcon(struct smbcli_composite *c,
 static NTSTATUS connect_session_setup(struct smbcli_composite *c, 
                                      struct smb_composite_connect *io)
 {
-       struct connect_state *state = c->private;
+       struct connect_state *state = talloc_get_type(c->private, struct connect_state);
        NTSTATUS status;
 
        status = smb_composite_sesssetup_recv(state->creq);
@@ -151,7 +151,7 @@ static NTSTATUS connect_session_setup(struct smbcli_composite *c,
 static NTSTATUS connect_negprot(struct smbcli_composite *c, 
                                struct smb_composite_connect *io)
 {
-       struct connect_state *state = c->private;
+       struct connect_state *state = talloc_get_type(c->private, struct connect_state);
        NTSTATUS status;
 
        status = smb_raw_negotiate_recv(state->req);
@@ -191,7 +191,7 @@ static NTSTATUS connect_negprot(struct smbcli_composite *c,
 static NTSTATUS connect_session_request(struct smbcli_composite *c, 
                                        struct smb_composite_connect *io)
 {
-       struct connect_state *state = c->private;
+       struct connect_state *state = talloc_get_type(c->private, struct connect_state);
        NTSTATUS status;
 
        status = smbcli_transport_connect_recv(state->req);
@@ -207,7 +207,7 @@ static NTSTATUS connect_session_request(struct smbcli_composite *c,
 static NTSTATUS connect_socket(struct smbcli_composite *c, 
                               struct smb_composite_connect *io)
 {
-       struct connect_state *state = c->private;
+       struct connect_state *state = talloc_get_type(c->private, struct connect_state);
        NTSTATUS status;
        struct nmb_name calling, called;
 
@@ -245,7 +245,7 @@ static NTSTATUS connect_socket(struct smbcli_composite *c,
 */
 static void state_handler(struct smbcli_composite *c)
 {
-       struct connect_state *state = c->private;
+       struct connect_state *state = talloc_get_type(c->private, struct connect_state);
 
        switch (c->stage) {
        case CONNECT_SOCKET:
@@ -338,7 +338,7 @@ NTSTATUS smb_composite_connect_recv(struct smbcli_composite *c, TALLOC_CTX *mem_
        status = smb_composite_wait(c);
 
        if (NT_STATUS_IS_OK(status)) {
-               struct connect_state *state = c->private;
+               struct connect_state *state = talloc_get_type(c->private, struct connect_state);
                talloc_steal(mem_ctx, state->io->out.tree);
        }
 
index 2d38096c88968019bc33c88c848e9ab7234f40ac..82908762243274db6987db38bd7ebc976195091f 100644 (file)
@@ -45,7 +45,7 @@ struct loadfile_state {
 static NTSTATUS setup_close(struct smbcli_composite *c, 
                            struct smbcli_tree *tree, uint16_t fnum)
 {
-       struct loadfile_state *state = c->private;
+       struct loadfile_state *state = talloc_get_type(c->private, struct loadfile_state);
        union smb_close *io_close;
 
        /* nothing to read, setup the close */
@@ -74,7 +74,7 @@ static NTSTATUS setup_close(struct smbcli_composite *c,
 static NTSTATUS loadfile_open(struct smbcli_composite *c, 
                              struct smb_composite_loadfile *io)
 {
-       struct loadfile_state *state = c->private;
+       struct loadfile_state *state = talloc_get_type(c->private, struct loadfile_state);
        struct smbcli_tree *tree = state->req->tree;
        NTSTATUS status;
 
@@ -128,7 +128,7 @@ static NTSTATUS loadfile_open(struct smbcli_composite *c,
 static NTSTATUS loadfile_read(struct smbcli_composite *c, 
                              struct smb_composite_loadfile *io)
 {
-       struct loadfile_state *state = c->private;
+       struct loadfile_state *state = talloc_get_type(c->private, struct loadfile_state);
        struct smbcli_tree *tree = state->req->tree;
        NTSTATUS status;
 
@@ -162,7 +162,7 @@ static NTSTATUS loadfile_read(struct smbcli_composite *c,
 static NTSTATUS loadfile_close(struct smbcli_composite *c, 
                               struct smb_composite_loadfile *io)
 {
-       struct loadfile_state *state = c->private;
+       struct loadfile_state *state = talloc_get_type(c->private, struct loadfile_state);
        NTSTATUS status;
 
        status = smbcli_request_simple_recv(state->req);
@@ -183,7 +183,7 @@ static NTSTATUS loadfile_close(struct smbcli_composite *c,
 static void loadfile_handler(struct smbcli_request *req)
 {
        struct smbcli_composite *c = req->async.private;
-       struct loadfile_state *state = c->private;
+       struct loadfile_state *state = talloc_get_type(c->private, struct loadfile_state);
 
        /* when this handler is called, the stage indicates what
           call has just finished */
@@ -271,7 +271,7 @@ NTSTATUS smb_composite_loadfile_recv(struct smbcli_composite *c, TALLOC_CTX *mem
        status = smb_composite_wait(c);
 
        if (NT_STATUS_IS_OK(status)) {
-               struct loadfile_state *state = c->private;
+               struct loadfile_state *state = talloc_get_type(c->private, struct loadfile_state);
                talloc_steal(mem_ctx, state->io->out.data);
        }
 
index f516939c2bf3bd1dc4484840a7bccbbf7f47724a..06eb13bb017a95473ed662c7042fe9107403c221 100644 (file)
@@ -47,7 +47,7 @@ struct savefile_state {
 static NTSTATUS setup_close(struct smbcli_composite *c, 
                            struct smbcli_tree *tree, uint16_t fnum)
 {
-       struct savefile_state *state = c->private;
+       struct savefile_state *state = talloc_get_type(c->private, struct savefile_state);
        union smb_close *io_close;
 
        /* nothing to write, setup the close */
@@ -76,7 +76,7 @@ static NTSTATUS setup_close(struct smbcli_composite *c,
 static NTSTATUS savefile_open(struct smbcli_composite *c, 
                              struct smb_composite_savefile *io)
 {
-       struct savefile_state *state = c->private;
+       struct savefile_state *state = talloc_get_type(c->private, struct savefile_state);
        union smb_write *io_write;
        struct smbcli_tree *tree = state->req->tree;
        NTSTATUS status;
@@ -122,7 +122,7 @@ static NTSTATUS savefile_open(struct smbcli_composite *c,
 static NTSTATUS savefile_write(struct smbcli_composite *c, 
                              struct smb_composite_savefile *io)
 {
-       struct savefile_state *state = c->private;
+       struct savefile_state *state = talloc_get_type(c->private, struct savefile_state);
        struct smbcli_tree *tree = state->req->tree;
        NTSTATUS status;
        uint32_t max_xmit = tree->session->transport->negotiate.max_xmit;
@@ -160,7 +160,7 @@ static NTSTATUS savefile_write(struct smbcli_composite *c,
 static NTSTATUS savefile_close(struct smbcli_composite *c, 
                               struct smb_composite_savefile *io)
 {
-       struct savefile_state *state = c->private;
+       struct savefile_state *state = talloc_get_type(c->private, struct savefile_state);
        NTSTATUS status;
 
        status = smbcli_request_simple_recv(state->req);
@@ -185,7 +185,7 @@ static NTSTATUS savefile_close(struct smbcli_composite *c,
 static void savefile_handler(struct smbcli_request *req)
 {
        struct smbcli_composite *c = req->async.private;
-       struct savefile_state *state = c->private;
+       struct savefile_state *state = talloc_get_type(c->private, struct savefile_state);
 
        /* when this handler is called, the stage indicates what
           call has just finished */
index fdc638837c8395e0c435f8359abd46a801af2177..771f85e541863bc11eaab4fd8b10abe5ac7b9a9f 100644 (file)
@@ -94,7 +94,7 @@ static void use_nt1_session_keys(struct smbcli_session *session,
 static void request_handler(struct smbcli_request *req)
 {
        struct smbcli_composite *c = req->async.private;
-       struct sesssetup_state *state = c->private;
+       struct sesssetup_state *state = talloc_get_type(c->private, struct sesssetup_state);
        struct smbcli_session *session = req->session;
        DATA_BLOB session_key = data_blob(NULL, 0);
        DATA_BLOB null_data_blob = data_blob(NULL, 0);
@@ -168,7 +168,7 @@ static struct smbcli_request *session_setup_nt1(struct smbcli_composite *c,
                                                struct smbcli_session *session, 
                                                struct smb_composite_sesssetup *io) 
 {
-       struct sesssetup_state *state = c->private;
+       struct sesssetup_state *state = talloc_get_type(c->private, struct sesssetup_state);
 
        state->setup.nt1.level           = RAW_SESSSETUP_NT1;
        state->setup.nt1.in.bufsize      = session->transport->options.max_xmit;
@@ -207,7 +207,7 @@ static struct smbcli_request *session_setup_old(struct smbcli_composite *c,
                                                struct smbcli_session *session,
                                                struct smb_composite_sesssetup *io)
 {
-       struct sesssetup_state *state = c->private;
+       struct sesssetup_state *state = talloc_get_type(c->private, struct sesssetup_state);
 
        state->setup.old.level      = RAW_SESSSETUP_OLD;
        state->setup.old.in.bufsize = session->transport->options.max_xmit;
@@ -241,7 +241,7 @@ static struct smbcli_request *session_setup_spnego(struct smbcli_composite *c,
                                                   struct smbcli_session *session,
                                                   struct smb_composite_sesssetup *io)
 {
-       struct sesssetup_state *state = c->private;
+       struct sesssetup_state *state = talloc_get_type(c->private, struct sesssetup_state);
        NTSTATUS status;
        DATA_BLOB session_key = data_blob(NULL, 0);
        DATA_BLOB null_data_blob = data_blob(NULL, 0);
index ad1c6a13b820a5b3c1fd73f6709d1d2e86238767..66555695d304a2caf27f2621522f406a5571a0de 100644 (file)
@@ -66,8 +66,8 @@ static NTSTATUS smbcli_sock_connect_one(struct smbcli_socket *sock,
 static void smbcli_sock_connect_handler(struct event_context *ev, struct fd_event *fde, 
                                        struct timeval t, uint16_t flags)
 {
-       struct smbcli_composite *c = fde->private;
-       struct clisocket_connect *conn = c->private;
+       struct smbcli_composite *c = talloc_get_type(fde->private, struct smbcli_composite);
+       struct clisocket_connect *conn = talloc_get_type(c->private, struct clisocket_connect);
        int i;
        
        c->status = socket_connect_complete(conn->sock->sock, 0);