summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-12 02:06:23 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-12 02:06:23 +0000
commit9d16ad639f49513b720e3afa6809eb98c0a6d609 (patch)
treecb4c8f31180f865728ce0268564669af638b6b23 /io.c
parentdb48bbdf0b4b8400d4ad0c1df5190d898fd9ed75 (diff)
* io.c (+ioctl_narg_len) new helper function.
* io.c (rb_io_ctl): don't use ioctl specific length check if caller is fcntl. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/io.c b/io.c
index e97704db11..8db2e63cac 100644
--- a/io.c
+++ b/io.c
@@ -7909,6 +7909,25 @@ io_cntl(int fd, int cmd, long narg, int io_p)
return retval;
}
+static long
+ioctl_narg_len(int cmd)
+{
+ long len;
+
+#ifdef IOCPARM_MASK
+#ifndef IOCPARM_LEN
+#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
+#endif
+#endif
+#ifdef IOCPARM_LEN
+ len = IOCPARM_LEN(cmd); /* on BSDish systems we're safe */
+#else
+ len = 256; /* otherwise guess at what's safe */
+#endif
+
+ return len;
+}
+
static VALUE
rb_io_ctl(VALUE io, VALUE req, VALUE arg, int io_p)
{
@@ -7937,16 +7956,11 @@ rb_io_ctl(VALUE io, VALUE req, VALUE arg, int io_p)
}
else {
arg = tmp;
-#ifdef IOCPARM_MASK
-#ifndef IOCPARM_LEN
-#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
-#endif
-#endif
-#ifdef IOCPARM_LEN
- len = IOCPARM_LEN(cmd); /* on BSDish systems we're safe */
-#else
- len = 256; /* otherwise guess at what's safe */
-#endif
+
+ if (io_p)
+ ioctl_narg_len(cmd);
+ else
+ len = 256;
rb_str_modify(arg);
if (len <= RSTRING_LEN(arg)) {