diff options
author | Andreas Schneider <asn@samba.org> | 2012-12-18 17:21:14 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2012-12-21 13:56:01 +0100 |
commit | 9c273d5ca1810da8cf03a2af78b3fa5cbaaf2df7 (patch) | |
tree | 9fc3b8d40e91619f73279619f631964f302d6b10 /source3 | |
parent | e4649da0c72c3ec37c8a6a3920308f3ebcb1473e (diff) | |
download | samba-9c273d5ca1810da8cf03a2af78b3fa5cbaaf2df7.tar.gz samba-9c273d5ca1810da8cf03a2af78b3fa5cbaaf2df7.tar.bz2 samba-9c273d5ca1810da8cf03a2af78b3fa5cbaaf2df7.zip |
s3-lib: Cleanup transfer_file_internal() a bit.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/util_transfer_file.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source3/lib/util_transfer_file.c b/source3/lib/util_transfer_file.c index 37a7d6e248..00a2c9d9de 100644 --- a/source3/lib/util_transfer_file.c +++ b/source3/lib/util_transfer_file.c @@ -45,11 +45,15 @@ ssize_t transfer_file_internal(void *in_file, size_t num_to_read_thistime; size_t num_written = 0; + if (n == 0) { + return 0; + } + if ((buf = SMB_MALLOC_ARRAY(char, TRANSFER_BUF_SIZE)) == NULL) { return -1; } - while (total < n) { + do { num_to_read_thistime = MIN((n - total), TRANSFER_BUF_SIZE); read_ret = (*read_fn)(in_file, buf, num_to_read_thistime); @@ -84,7 +88,7 @@ ssize_t transfer_file_internal(void *in_file, } total += (size_t)read_ret; - } + } while (total < n); SAFE_FREE(buf); return (ssize_t)total; |