1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

basicsocket (rsock_bsock_send): do not truncate return value

send(2) and sendto(2) syscalls return `ssize_t', use the
proper type and macro for converting to a Numeric VALUE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2017-01-16 21:42:05 +00:00
parent 650a8ce839
commit a34f9c7e9a

View file

@ -530,7 +530,7 @@ rsock_bsock_send(int argc, VALUE *argv, VALUE sock)
struct rsock_send_arg arg;
VALUE flags, to;
rb_io_t *fptr;
int n;
ssize_t n;
rb_blocking_function_t *func;
rb_scan_args(argc, argv, "21", &arg.mesg, &flags, &to);
@ -550,13 +550,13 @@ rsock_bsock_send(int argc, VALUE *argv, VALUE sock)
arg.fd = fptr->fd;
arg.flags = NUM2INT(flags);
while (rsock_maybe_fd_writable(arg.fd),
(n = (int)BLOCKING_REGION_FD(func, &arg)) < 0) {
(n = (ssize_t)BLOCKING_REGION_FD(func, &arg)) < 0) {
if (rb_io_wait_writable(arg.fd)) {
continue;
}
rb_sys_fail("send(2)");
}
return INT2FIX(n);
return SSIZET2NUM(n);
}
/*