summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-08-26 15:20:15 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2019-08-27 15:52:26 +0900
commit703783324c16b8b2b50210d1a7d1119902abbb8b (patch)
treed594ba9029a1ddcee223fcb2f39be07ef20daca1 /ext
parent5c7c2d9951f2512ca10ea38fecc48d8ac67502e6 (diff)
rb_ensure now free from ANYARGS
After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from rb_ensure, which also revealed many arity / type mismatches.
Diffstat (limited to 'ext')
-rw-r--r--ext/-test-/tracepoint/gc_hook.c2
-rw-r--r--ext/etc/etc.c8
-rw-r--r--ext/pty/pty.c3
-rw-r--r--ext/socket/ipsocket.c6
-rw-r--r--ext/socket/raddrinfo.c3
-rw-r--r--ext/socket/udpsocket.c9
-rw-r--r--ext/zlib/zlib.c15
7 files changed, 30 insertions, 16 deletions
diff --git a/ext/-test-/tracepoint/gc_hook.c b/ext/-test-/tracepoint/gc_hook.c
index 6d8485ecb1..2e695a9fba 100644
--- a/ext/-test-/tracepoint/gc_hook.c
+++ b/ext/-test-/tracepoint/gc_hook.c
@@ -4,7 +4,7 @@
static int invoking; /* TODO: should not be global variable */
static VALUE
-invoke_proc_ensure(void *dmy)
+invoke_proc_ensure(VALUE _)
{
invoking = 0;
return Qnil;
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index b6dca94b99..a3a9bbc233 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -231,7 +231,7 @@ etc_getpwnam(VALUE obj, VALUE nam)
#ifdef HAVE_GETPWENT
static int passwd_blocking = 0;
static VALUE
-passwd_ensure(void)
+passwd_ensure(VALUE _)
{
endpwent();
passwd_blocking = (int)Qfalse;
@@ -239,7 +239,7 @@ passwd_ensure(void)
}
static VALUE
-passwd_iterate(void)
+passwd_iterate(VALUE _)
{
struct passwd *pw;
@@ -475,7 +475,7 @@ etc_getgrnam(VALUE obj, VALUE nam)
#ifdef HAVE_GETGRENT
static int group_blocking = 0;
static VALUE
-group_ensure(void)
+group_ensure(VALUE _)
{
endgrent();
group_blocking = (int)Qfalse;
@@ -484,7 +484,7 @@ group_ensure(void)
static VALUE
-group_iterate(void)
+group_iterate(VALUE _)
{
struct group *pw;
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index 7b9df4b5b9..4c6ae26127 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -520,8 +520,9 @@ pty_open(VALUE klass)
}
static VALUE
-pty_detach_process(struct pty_info *info)
+pty_detach_process(VALUE v)
{
+ struct pty_info *info = (void *)v;
#ifdef WNOHANG
int st;
if (rb_waitpid(info->child_pid, &st, WNOHANG) <= 0)
diff --git a/ext/socket/ipsocket.c b/ext/socket/ipsocket.c
index f214d852ae..a2cb6e0e12 100644
--- a/ext/socket/ipsocket.c
+++ b/ext/socket/ipsocket.c
@@ -22,8 +22,9 @@ struct inetsock_arg
};
static VALUE
-inetsock_cleanup(struct inetsock_arg *arg)
+inetsock_cleanup(VALUE v)
{
+ struct inetsock_arg *arg = (void *)v;
if (arg->remote.res) {
rb_freeaddrinfo(arg->remote.res);
arg->remote.res = 0;
@@ -39,8 +40,9 @@ inetsock_cleanup(struct inetsock_arg *arg)
}
static VALUE
-init_inetsock_internal(struct inetsock_arg *arg)
+init_inetsock_internal(VALUE v)
{
+ struct inetsock_arg *arg = (void *)v;
int error = 0;
int type = arg->type;
struct addrinfo *res, *lres;
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index b59cc49005..dad11ad1ac 100644
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -654,8 +654,9 @@ struct hostent_arg {
};
static VALUE
-make_hostent_internal(struct hostent_arg *arg)
+make_hostent_internal(VALUE v)
{
+ struct hostent_arg *arg = (void *)v;
VALUE host = arg->host;
struct addrinfo* addr = arg->addr->ai;
VALUE (*ipaddr)(struct sockaddr*, socklen_t) = arg->ipaddr;
diff --git a/ext/socket/udpsocket.c b/ext/socket/udpsocket.c
index c2e273c2a3..6ef8242a1e 100644
--- a/ext/socket/udpsocket.c
+++ b/ext/socket/udpsocket.c
@@ -50,8 +50,9 @@ struct udp_arg
};
static VALUE
-udp_connect_internal(struct udp_arg *arg)
+udp_connect_internal(VALUE v)
{
+ struct udp_arg *arg = (void *)v;
rb_io_t *fptr;
int fd;
struct addrinfo *res;
@@ -97,8 +98,9 @@ udp_connect(VALUE sock, VALUE host, VALUE port)
}
static VALUE
-udp_bind_internal(struct udp_arg *arg)
+udp_bind_internal(VALUE v)
{
+ struct udp_arg *arg = (void *)v;
rb_io_t *fptr;
int fd;
struct addrinfo *res;
@@ -147,8 +149,9 @@ struct udp_send_arg {
};
static VALUE
-udp_send_internal(struct udp_send_arg *arg)
+udp_send_internal(VALUE v)
{
+ struct udp_send_arg *arg = (void *)v;
rb_io_t *fptr;
int n;
struct addrinfo *res;
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index e84e565932..afd761f1c1 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -85,6 +85,7 @@ static void zstream_passthrough_input(struct zstream*);
static VALUE zstream_detach_input(struct zstream*);
static void zstream_reset(struct zstream*);
static VALUE zstream_end(struct zstream*);
+static VALUE zstream_ensure_end(VALUE v);
static void zstream_run(struct zstream*, Bytef*, long, int);
static VALUE zstream_sync(struct zstream*, Bytef*, long);
static void zstream_mark(void*);
@@ -955,6 +956,12 @@ zstream_end(struct zstream *z)
return Qnil;
}
+static VALUE
+zstream_ensure_end(VALUE v)
+{
+ return zstream_end((struct zstream *)v);
+}
+
static void *
zstream_run_func(void *ptr)
{
@@ -1640,7 +1647,7 @@ rb_deflate_s_deflate(int argc, VALUE *argv, VALUE klass)
args[0] = (VALUE)&z;
args[1] = src;
- dst = rb_ensure(deflate_run, (VALUE)args, zstream_end, (VALUE)&z);
+ dst = rb_ensure(deflate_run, (VALUE)args, zstream_ensure_end, (VALUE)&z);
OBJ_INFECT(dst, src);
return dst;
@@ -1955,7 +1962,7 @@ rb_inflate_s_inflate(VALUE obj, VALUE src)
args[0] = (VALUE)&z;
args[1] = src;
- dst = rb_ensure(inflate_run, (VALUE)args, zstream_end, (VALUE)&z);
+ dst = rb_ensure(inflate_run, (VALUE)args, zstream_ensure_end, (VALUE)&z);
OBJ_INFECT(dst, src);
return dst;
@@ -2919,7 +2926,7 @@ gzfile_writer_end(struct gzfile *gz)
if (ZSTREAM_IS_CLOSING(&gz->z)) return;
gz->z.flags |= ZSTREAM_FLAG_CLOSING;
- rb_ensure(gzfile_writer_end_run, (VALUE)gz, zstream_end, (VALUE)&gz->z);
+ rb_ensure(gzfile_writer_end_run, (VALUE)gz, zstream_ensure_end, (VALUE)&gz->z);
}
static VALUE
@@ -2941,7 +2948,7 @@ gzfile_reader_end(struct gzfile *gz)
if (ZSTREAM_IS_CLOSING(&gz->z)) return;
gz->z.flags |= ZSTREAM_FLAG_CLOSING;
- rb_ensure(gzfile_reader_end_run, (VALUE)gz, zstream_end, (VALUE)&gz->z);
+ rb_ensure(gzfile_reader_end_run, (VALUE)gz, zstream_ensure_end, (VALUE)&gz->z);
}
static void