8000 * io.c (+ioctl_narg_len) new helper function. · ileitch/ruby@9d16ad6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9d16ad6

Browse files
author
kosaki
committed
* 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
1 parent db48bbd commit 9d16ad6

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Sat Nov 12 10:52:17 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
2+
3+
* io.c (+ioctl_narg_len) new helper function.
4+
* io.c (rb_io_ctl): don't use ioctl specific length check
5+
if caller is fcntl.
6+
17
Fri Nov 11 23:00:46 2011 Tanaka Akira <akr@fsij.org>
28

39
* ext/dbm/extconf.rb: db_prefix is not required now.

io.c

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7909,6 +7909,25 @@ io_cntl(int fd, int cmd, long narg, int io_p)
79097909
return retval;
79107910
}
79117911

7912+
static long
7913+
ioctl_narg_len(int cmd)
7914+
{
7915+
long len;
7916+
7917+
#ifdef IOCPARM_MASK
7918+
#ifndef IOCPARM_LEN
7919+
#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
7920+
#endif
7921+
#endif
7922+
#ifdef IOCPARM_LEN
7923+
len = IOCPARM_LEN(cmd); /* on BSDish systems we're safe */
7924+
#else
7925+
len = 256; /* otherwise guess at what's safe */
7926+
#endif
7927+
7928+
return len;
7929+
}
7930+
79127931
static VALUE
79137932
rb_io_ctl(VALUE io, VALUE req, VALUE arg, int io_p)
79147933
{
@@ -7937,16 +7956,11 @@ rb_io_ctl(VALUE io, VALUE req, VALUE arg, int io_p)
79377956
}
79387957
else {
79397958
arg = tmp;
7940-
#ifdef IOCPARM_MASK
7941-
#ifndef IOCPARM_LEN
7942-
#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
7943-
#endif
7944-
#endif
7945-
#ifdef IOCPARM_LEN
7946-
len = IOCPARM_LEN(cmd); /* on BSDish systems we're safe */
7947-
#else
7948-
len = 256; /* otherwise guess at what's safe */
7949-
#endif
7959+
7960+
if (io_p)
7961+
ioctl_narg_len(cmd);
7962+
else
7963+
len = 256;
79507964
rb_str_modify(arg);
79517965

79527966
if (len <= RSTRING_LEN(arg)) {

0 commit comments

Comments
 (0)
0