diff options
author | Tim Beale <timbeale@catalyst.net.nz> | 2019-01-03 17:48:39 +1300 |
---|---|---|
committer | Tim Beale <timbeale@samba.org> | 2019-01-07 01:23:08 +0100 |
commit | 1d0d1a758bacaf160f320f39156923ab4c273fd5 (patch) | |
tree | 46472890166c040e4cfa946adde37c19d74d1ad5 /source3 | |
parent | d7c7d6203ba85785d23481f3926aa6ddb29a7311 (diff) | |
download | samba-1d0d1a758bacaf160f320f39156923ab4c273fd5.tar.gz |
s3:libsmb: Avoid duplicated code by making cli_read_sink() public
cli_read_sink() and pull_helper() were essentially identical. By making
cli_read_sink() non-static, we can delete the latter.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/libsmb/clireadwrite.c | 6 | ||||
-rw-r--r-- | source3/libsmb/proto.h | 1 | ||||
-rw-r--r-- | source3/libsmb/pylibsmb.c | 10 |
3 files changed, 7 insertions, 10 deletions
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c index e953fa5e228..da188db7c31 100644 --- a/source3/libsmb/clireadwrite.c +++ b/source3/libsmb/clireadwrite.c @@ -822,7 +822,11 @@ NTSTATUS cli_read_recv(struct tevent_req *req, size_t *received) return NT_STATUS_OK; } -static NTSTATUS cli_read_sink(char *buf, size_t n, void *priv) +/* + * Helper function for cli_pull(). This takes a chunk of data (buf) read from + * a remote file and copies it into the return buffer (priv). + */ +NTSTATUS cli_read_sink(char *buf, size_t n, void *priv) { char **pbuf = (char **)priv; memcpy(*pbuf, buf, n); diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h index bfad4dcc011..b0cfcb5aa90 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -840,6 +840,7 @@ NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum, off_t start_offset, off_t size, size_t window_size, NTSTATUS (*sink)(char *buf, size_t n, void *priv), void *priv, off_t *received); +NTSTATUS cli_read_sink(char *buf, size_t n, void *priv); struct tevent_req *cli_read_send( TALLOC_CTX *mem_ctx, struct tevent_context *ev, diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c index 2190b7c9c4a..08de5d0f531 100644 --- a/source3/libsmb/pylibsmb.c +++ b/source3/libsmb/pylibsmb.c @@ -895,14 +895,6 @@ static NTSTATUS py_smb_filesize(struct py_cli_state *self, uint16_t fnum, return status; } -static NTSTATUS pull_helper(char *buf, size_t n, void *priv) -{ - char **dest_buf = (char **)priv; - memcpy(*dest_buf, buf, n); - *dest_buf += n; - return NT_STATUS_OK; -} - /* * Loads the specified file's contents and returns it */ @@ -946,7 +938,7 @@ static PyObject *py_smb_loadfile(struct py_cli_state *self, PyObject *args, /* read the file contents */ buf = PyBytes_AS_STRING(result); req = cli_pull_send(NULL, self->ev, self->cli, fnum, 0, size, - size, pull_helper, &buf); + size, cli_read_sink, &buf); if (!py_tevent_req_wait_exc(self, req)) { Py_XDECREF(result); return NULL; |