Skip to content

Commit

Permalink
msg_iovlen is an int on OSX, a size_t on Linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 committed Jun 20, 2011
1 parent a56ba48 commit 7a7efe5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
18 changes: 10 additions & 8 deletions src/hook-recvmsg.c
Expand Up @@ -36,15 +36,16 @@ static FilterReplyResult filter_parse_reply(FilterReplyResultBase * const rb,
const char *data_pnt = obj_data->via.raw.ptr;
size_t data_remaining = (size_t) obj_data->via.raw.size;
size_t copy_to_vec;
int i_vecs = 0;
size_t i_vecs = 0U;
size_t max_nbytes = (size_t) 0U;
while (i_vecs < msg->msg_iovlen) {
while (i_vecs < (size_t) msg->msg_iovlen) {
max_nbytes += vecs[i_vecs].iov_len;
i_vecs++;
}
assert(max_nbytes >= data_remaining);
i_vecs = 0;
while (i_vecs < msg->msg_iovlen && data_remaining > (size_t) 0U) {
i_vecs = 0U;
while (i_vecs < (size_t) msg->msg_iovlen &&
data_remaining > (size_t) 0U) {
if (data_remaining < vecs[i_vecs].iov_len) {
copy_to_vec = data_remaining;
} else {
Expand Down Expand Up @@ -96,8 +97,9 @@ static FilterReplyResult filter_apply(FilterReplyResultBase * const rb,
size_t data_remaining = *nbyte;
size_t read_from_vec;
struct iovec * const vecs = msg->msg_iov;
int i_vecs = 0;
while (i_vecs < msg->msg_iovlen && data_remaining > (size_t) 0U) {
size_t i_vecs = 0U;
while (i_vecs < (size_t) msg->msg_iovlen &&
data_remaining > (size_t) 0U) {
if (data_remaining < vecs[i_vecs].iov_len) {
read_from_vec = data_remaining;
} else {
Expand Down Expand Up @@ -143,8 +145,8 @@ ssize_t INTERPOSE(recvmsg)(int fd, struct msghdr *msg, int flags)
bool bypass_call = false;
size_t nbyte = (size_t) 0U;
struct iovec * const vecs = msg->msg_iov;
int i_vecs = 0;
while (i_vecs < msg->msg_iovlen) {
size_t i_vecs = 0U;
while (i_vecs < (size_t) msg->msg_iovlen) {
assert(SIZE_MAX - nbyte >= vecs[i_vecs].iov_len);
nbyte += vecs[i_vecs].iov_len;
i_vecs++;
Expand Down
9 changes: 5 additions & 4 deletions src/hook-sendmsg.c
Expand Up @@ -62,8 +62,9 @@ static FilterReplyResult filter_apply(FilterReplyResultBase * const rb,
size_t data_remaining = *nbyte;
size_t read_from_vec;
struct iovec * const vecs = msg->msg_iov;
int i_vecs = 0;
while (i_vecs < msg->msg_iovlen && data_remaining > (size_t) 0U) {
size_t i_vecs = 0U;
while (i_vecs < (size_t) msg->msg_iovlen &&
data_remaining > (size_t) 0U) {
if (data_remaining < vecs[i_vecs].iov_len) {
read_from_vec = data_remaining;
} else {
Expand Down Expand Up @@ -109,8 +110,8 @@ ssize_t INTERPOSE(sendmsg)(int fd, const struct msghdr *msg, int flags)
struct msghdr msg_ = *msg;
size_t nbyte = (size_t) 0U;
struct iovec * const vecs = msg->msg_iov;
int i_vecs = 0;
while (i_vecs < msg->msg_iovlen) {
size_t i_vecs = 0U;
while (i_vecs < (size_t) msg->msg_iovlen) {
assert(SIZE_MAX - nbyte >= vecs[i_vecs].iov_len);
nbyte += vecs[i_vecs].iov_len;
i_vecs++;
Expand Down

0 comments on commit 7a7efe5

Please sign in to comment.