Simplify async programming a bit with helper routines
[amitay/samba.git] / source3 / libsmb / clireadwrite.c
index ec632816303bd37e06f22740c4bbf2c595263c3f..ecf49396d119a0e23122bfb3da2c5fc6cf4a0192 100644 (file)
@@ -70,10 +70,10 @@ struct async_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
        SSVAL(vwv + 8, 0, 0);
        SSVAL(vwv + 9, 0, 0);
 
-       if ((SMB_BIG_UINT)offset >> 32) {
+       if ((uint64_t)offset >> 32) {
                bigoffset = True;
                SIVAL(vwv + 10, 0,
-                     (((SMB_BIG_UINT)offset)>>32) & 0xffffffff);
+                     (((uint64_t)offset)>>32) & 0xffffffff);
                wct += 2;
        }
 
@@ -112,9 +112,8 @@ NTSTATUS cli_read_andx_recv(struct async_req *req, ssize_t *received,
        NTSTATUS status;
        size_t size;
 
-       SMB_ASSERT(req->state >= ASYNC_REQ_DONE);
-       if (req->state == ASYNC_REQ_ERROR) {
-               return req->status;
+       if (async_req_is_error(req, &status)) {
+               return status;
        }
 
        status = cli_pull_reply(req, &wct, &vwv, &num_bytes, &bytes);
@@ -405,10 +404,10 @@ NTSTATUS cli_pull_recv(struct async_req *req, SMB_OFF_T *received)
 {
        struct cli_pull_state *state = talloc_get_type_abort(
                req->private_data, struct cli_pull_state);
+       NTSTATUS status;
 
-       SMB_ASSERT(req->state >= ASYNC_REQ_DONE);
-       if (req->state == ASYNC_REQ_ERROR) {
-               return req->status;
+       if (async_req_is_error(req, &status)) {
+               return status;
        }
        *received = state->pushed;
        return NT_STATUS_OK;
@@ -543,7 +542,7 @@ static bool cli_issue_write(struct cli_state *cli,
              smb_buf(cli->outbuf) - smb_base(cli->outbuf) + 1);
 
        if (large_writex) {
-               SIVAL(cli->outbuf,smb_vwv12,(((SMB_BIG_UINT)offset)>>32) & 0xffffffff);
+               SIVAL(cli->outbuf,smb_vwv12,(((uint64_t)offset)>>32) & 0xffffffff);
        }
 
        p = smb_base(cli->outbuf) + SVAL(cli->outbuf,smb_vwv11) -1;