summaryrefslogtreecommitdiff
path: root/ext/socket/basicsocket.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-16 21:42:05 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-16 21:42:05 +0000
commita34f9c7e9ae4139e372f10e77fbceb9ea847950f (patch)
treee34924a443690fd0f4a3127b82293abebc5e3957 /ext/socket/basicsocket.c
parent650a8ce8392dced0f9026caeb95130a9f6ba550e (diff)
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
Diffstat (limited to 'ext/socket/basicsocket.c')
-rw-r--r--ext/socket/basicsocket.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ext/socket/basicsocket.c b/ext/socket/basicsocket.c
index 264b882..3b6f22f 100644
--- a/ext/socket/basicsocket.c
+++ b/ext/socket/basicsocket.c
@@ -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);
}
/*