summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2009-11-14 09:55:17 -0800
committerWayne Davison <wayned@samba.org>2009-11-14 09:56:42 -0800
commitc493b6b81d814db3cdd91f3bb98f5a84456756ff (patch)
tree8960a6dc1062b8471254047bf3f918ccb1f0c048 /io.c
parent4e2a7e59e540a7a66da0c3e159f0464b05559f7f (diff)
downloadrsync-c493b6b81d814db3cdd91f3bb98f5a84456756ff.tar.gz
Make the two "wrap-bytes" sections simpler and more similar.
Diffstat (limited to 'io.c')
-rw-r--r--io.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/io.c b/io.c
index b717b431..284e4571 100644
--- a/io.c
+++ b/io.c
@@ -614,21 +614,20 @@ static char *perform_io(size_t needed, int flags)
if (iobuf.raw_flushing_ends_before
|| (!iobuf.msg.len && iobuf.out.len > iobuf.out_empty_len && !(flags & PIO_NEED_MSGROOM))) {
if (OUT_MULTIPLEXED && !iobuf.raw_flushing_ends_before) {
- size_t val;
-
/* The iobuf.raw_flushing_ends_before value can point off the end
* of the iobuf.out buffer for a while, for easier subtracting. */
iobuf.raw_flushing_ends_before = iobuf.out.pos + iobuf.out.len;
SIVAL(iobuf.out.buf + iobuf.raw_data_header_pos, 0,
((MPLEX_BASE + (int)MSG_DATA)<<24) + iobuf.out.len - 4);
- if ((val = iobuf.out.size - iobuf.raw_data_header_pos) < 4) {
+ if (iobuf.raw_data_header_pos + 4 > iobuf.out.size) {
+ int siz = (int)(iobuf.raw_data_header_pos + 4 - iobuf.out.size);
/* We used some of the overflow bytes, so move them. */
if (DEBUG_GTE(IO, 4)) {
rprintf(FINFO, "[%s] wrap-bytes moved: %d (perform_io)\n",
- who_am_i(), (int)val);
+ who_am_i(), siz);
}
- memcpy(iobuf.out.buf, iobuf.out.buf + iobuf.out.size, 4 - val);
+ memcpy(iobuf.out.buf, iobuf.out.buf + iobuf.out.size, siz);
}
if (DEBUG_GTE(IO, 1)) {
@@ -883,10 +882,10 @@ int send_msg(enum msgcode code, const char *buf, size_t len, int convert)
SIVAL(hdr, 0, ((MPLEX_BASE + (int)code)<<24) + len);
/* If the header used any overflow bytes, move them to the start. */
if ((pos = hdr+4 - iobuf.msg.buf) > iobuf.msg.size) {
- size_t siz = pos - iobuf.msg.size;
+ int siz = (int)(pos - iobuf.msg.size);
if (DEBUG_GTE(IO, 4))
- rprintf(FINFO, "[%s] wrap-bytes moved: %d (send_msg)\n", who_am_i(), (int)siz);
- memcpy(iobuf.msg.buf, hdr+4 - siz, siz);
+ rprintf(FINFO, "[%s] wrap-bytes moved: %d (send_msg)\n", who_am_i(), siz);
+ memcpy(iobuf.msg.buf, iobuf.msg.buf + iobuf.msg.size, siz);
}
if (want_debug && convert > 0)