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 | 386caead47e97b9fdc991b713cb597f1a1c4a365 (patch) | |
tree | a91a56e49e0d6bde826c32cb3b4b4bf49ef16f45 | |
parent | 10da70325b899bfbebf5a6eeef69838fe9d346bb (diff) | |
download | samba-386caead47e97b9fdc991b713cb597f1a1c4a365.tar.gz samba-386caead47e97b9fdc991b713cb597f1a1c4a365.tar.bz2 samba-386caead47e97b9fdc991b713cb597f1a1c4a365.zip |
Reformat some code I just touched.
Michael
(This used to be commit 4ed238b1e46f7680a29ebdbfe9500d16718f9057)
-rw-r--r-- | source3/lib/util.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index d635078f37..44eaa85ab0 100644 --- a/source3/lib/util.c +++ b/source3/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); } /******************************************************************* |