libsmb: Avoid a separate "cblobs" var sending smb2 create
authorVolker Lendecke <vl@samba.org>
Wed, 20 Feb 2019 16:06:32 +0000 (17:06 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 1 Mar 2019 00:32:12 +0000 (00:32 +0000)
Less lines of code, and we will add custom cblobs soon. This change
makes that logic easier.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/cli_smb2_fnum.c

index 8122cd6cb3039324c479a501c962005e9c2e9c13..181078507a1260cb2bac0001d5952e79933244c2 100644 (file)
@@ -158,6 +158,7 @@ static uint8_t flags_to_smb2_oplock(uint32_t create_flags)
 
 struct cli_smb2_create_fnum_state {
        struct cli_state *cli;
+       struct smb2_create_blobs cblobs;
        struct smb_create_returns cr;
        uint16_t fnum;
        struct tevent_req *subreq;
@@ -185,7 +186,6 @@ struct tevent_req *cli_smb2_create_fnum_send(
        const char *startp = NULL;
        const char *endp = NULL;
        time_t tstamp = (time_t)0;
-       struct smb2_create_blobs *cblobs = NULL;
 
        req = tevent_req_create(mem_ctx, &state,
                                struct cli_smb2_create_fnum_state);
@@ -227,13 +227,11 @@ struct tevent_req *cli_smb2_create_fnum_send(
                unix_to_nt_time(&ntt, tstamp);
                twrp_blob = data_blob_const((const void *)&ntt, 8);
 
-               cblobs = talloc_zero(state, struct smb2_create_blobs);
-               if (tevent_req_nomem(cblobs, req)) {
-                       return tevent_req_post(req, ev);
-               }
-
-               status = smb2_create_blob_add(state, cblobs,
-                               SMB2_CREATE_TAG_TWRP, twrp_blob);
+               status = smb2_create_blob_add(
+                       state,
+                       &state->cblobs,
+                       SMB2_CREATE_TAG_TWRP,
+                       twrp_blob);
                if (!NT_STATUS_IS_OK(status)) {
                        tevent_req_nterror(req, status);
                        return tevent_req_post(req, ev);
@@ -270,7 +268,7 @@ struct tevent_req *cli_smb2_create_fnum_send(
                                     share_access,
                                     create_disposition,
                                     create_options,
-                                    cblobs);
+                                    &state->cblobs);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }