diff options
author | Michael Adam <obnox@samba.org> | 2008-01-10 13:55:46 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2008-01-10 14:28:12 +0100 |
commit | 4ed238b1e46f7680a29ebdbfe9500d16718f9057 (patch) | |
tree | 95485219339a06b9ad52271ffb016be0820e2481 | |
parent | cbbfbd7a63fe0fc479a1b63b4552c713633dd6be (diff) | |
download | samba-4ed238b1e46f7680a29ebdbfe9500d16718f9057.tar.gz samba-4ed238b1e46f7680a29ebdbfe9500d16718f9057.tar.xz samba-4ed238b1e46f7680a29ebdbfe9500d16718f9057.zip |
Reformat some code I just touched.
Michael
-rw-r--r-- | source/lib/util.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/source/lib/util.c b/source/lib/util.c index d635078f37b..44eaa85ab04 100644 --- a/source/lib/util.c +++ b/source/lib/util.c @@ -919,34 +919,41 @@ ssize_t transfer_file_internal(void *in_file, size_t num_to_read_thistime; size_t num_written = 0; - if ((buf = SMB_MALLOC_ARRAY(char, TRANSFER_BUF_SIZE)) == NULL) + if ((buf = SMB_MALLOC_ARRAY(char, TRANSFER_BUF_SIZE)) == NULL) { return -1; + } while (total < n) { num_to_read_thistime = MIN((n - total), TRANSFER_BUF_SIZE); read_ret = (*read_fn)(in_file, buf, num_to_read_thistime); if (read_ret == -1) { - DEBUG(0,("transfer_file_internal: read failure. Error = %s\n", strerror(errno) )); + DEBUG(0,("transfer_file_internal: read failure. " + "Error = %s\n", strerror(errno) )); SAFE_FREE(buf); return -1; } - if (read_ret == 0) + if (read_ret == 0) { break; + } num_written = 0; - + while (num_written < read_ret) { - write_ret = (*write_fn)(out_file, buf + num_written, read_ret - num_written); - + write_ret = (*write_fn)(out_file, buf + num_written, + read_ret - num_written); + if (write_ret == -1) { - DEBUG(0,("transfer_file_internal: write failure. Error = %s\n", strerror(errno) )); + DEBUG(0,("transfer_file_internal: " + "write failure. Error = %s\n", + strerror(errno) )); SAFE_FREE(buf); return -1; } - if (write_ret == 0) + if (write_ret == 0) { return (ssize_t)total; - + } + num_written += (size_t)write_ret; } @@ -954,7 +961,7 @@ ssize_t transfer_file_internal(void *in_file, } SAFE_FREE(buf); - return (ssize_t)total; + return (ssize_t)total; } static ssize_t sys_read_fn(void *file, void *buf, size_t len) @@ -971,9 +978,10 @@ static ssize_t sys_write_fn(void *file, void *buf, size_t len) return sys_write(*fd, buf, len); } -SMB_OFF_T transfer_file(int infd,int outfd,SMB_OFF_T n) +SMB_OFF_T transfer_file(int infd, int outfd, SMB_OFF_T n) { - return (SMB_OFF_T)transfer_file_internal(&infd, &outfd, (size_t)n, sys_read_fn, sys_write_fn); + return (SMB_OFF_T)transfer_file_internal(&infd, &outfd, (size_t)n, + sys_read_fn, sys_write_fn); } /******************************************************************* |