summaryrefslogtreecommitdiffstats
path: root/ext/socket/socket.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-01 10:54:38 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-01 10:54:38 +0000
commiteeee2c55d494b33f12d69f9b26bb62bd74921ffa (patch)
tree6103261afe07b2b8af6f436626bd7f35df84446c /ext/socket/socket.c
parenta5996ed0447cf72e19513ef3750e604c1862d01e (diff)
downloadruby-eeee2c55d494b33f12d69f9b26bb62bd74921ffa.tar.gz
ruby-eeee2c55d494b33f12d69f9b26bb62bd74921ffa.tar.xz
ruby-eeee2c55d494b33f12d69f9b26bb62bd74921ffa.zip
* ext/socket/mkconstants.rb: add valp argument for family_to_int and
socktype_to_int. * ext/socket/socket.c (setup_domain_and_type): use valp argument. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@21245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r--ext/socket/socket.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index f6fe3955f..90ce5af34 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -2264,8 +2264,8 @@ unix_peeraddr(VALUE sock)
}
#endif
-static int family_to_int(char *str, int len);
-static int socktype_to_int(char *str, int len);
+static int family_to_int(char *str, int len, int *valp);
+static int socktype_to_int(char *str, int len, int *valp);
static void
setup_domain_and_type(VALUE domain, int *dv, VALUE type, int *tv)
@@ -2275,28 +2275,22 @@ setup_domain_and_type(VALUE domain, int *dv, VALUE type, int *tv)
tmp = rb_check_string_type(domain);
if (!NIL_P(tmp)) {
- int family;
domain = tmp;
rb_check_safe_obj(domain);
ptr = RSTRING_PTR(domain);
- family = family_to_int(ptr, RSTRING_LEN(domain));
- if (family == -1)
+ if (family_to_int(ptr, RSTRING_LEN(domain), dv) == -1)
rb_raise(rb_eSocket, "unknown socket domain %s", ptr);
- *dv = family;
}
else {
*dv = NUM2INT(domain);
}
tmp = rb_check_string_type(type);
if (!NIL_P(tmp)) {
- int socktype;
type = tmp;
rb_check_safe_obj(type);
ptr = RSTRING_PTR(type);
- socktype = socktype_to_int(ptr, RSTRING_LEN(type));
- if (socktype == -1)
+ if (socktype_to_int(ptr, RSTRING_LEN(type), tv) == -1)
rb_raise(rb_eSocket, "unknown socket type %s", ptr);
- *tv = socktype;
}
else {
*tv = NUM2INT(type);