From fc91f1d424af2a94d0fbed4b1f4d0171c8add79f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 25 Sep 2013 19:37:22 +0000 Subject: [PATCH] my_writev: stylistic fixes Rename 'str' to 'ary', as that's the whole point of supporting writev... Also, long lines need to be wrapped at 80 columns --- ext/kgio/read_write.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ext/kgio/read_write.c b/ext/kgio/read_write.c index 34c619f..fcb48bb 100644 --- a/ext/kgio/read_write.c +++ b/ext/kgio/read_write.c @@ -606,12 +606,12 @@ static int writev_check(struct io_args_v *a, long n, const char *msg, int io_wai return 0; } -static VALUE my_writev(VALUE io, VALUE str, int io_wait) +static VALUE my_writev(VALUE io, VALUE ary, int io_wait) { struct io_args_v a; long n; - prepare_writev(&a, io, str); + prepare_writev(&a, io, ary); set_nonblocking(a.fd); do { @@ -619,12 +619,15 @@ static VALUE my_writev(VALUE io, VALUE str, int io_wait) if (a.iov_cnt == 0) n = 0; else if (a.iov_cnt == 1) - n = (long)write(a.fd, a.vec[0].iov_base, a.vec[0].iov_len); + n = (long)write(a.fd, a.vec[0].iov_base, + a.vec[0].iov_len); /* for big strings use library function */ - else if (USE_WRITEV && a.batch_len / WRITEV_IMPL_THRESHOLD > a.iov_cnt) + else if (USE_WRITEV && + ((a.batch_len / WRITEV_IMPL_THRESHOLD) > a.iov_cnt)) n = (long)writev(a.fd, a.vec, a.iov_cnt); else - n = (long)custom_writev(a.fd, a.vec, a.iov_cnt, a.batch_len); + n = (long)custom_writev(a.fd, a.vec, a.iov_cnt, + a.batch_len); } while (writev_check(&a, n, "writev", io_wait) != 0); rb_str_resize(a.vec_buf, 0); -- 2.11.4.GIT