summaryrefslogtreecommitdiff
path: root/ext/socket/ancdata.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-01 04:43:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-01 04:43:00 +0000
commit84c8319c8d14b6e75cc6af995118a7a26cb394ea (patch)
treec8e417158a9f9b38452327c3239b8e7aef01479d /ext/socket/ancdata.c
parentbb35edf33c97184672fdc3e5fd70a86c45534d18 (diff)
ancdata.c: suppress warnings
* ext/socket/ancdata.c (bsock_sendmsg_internal): suppress warnings on platforms where msghdr does not have msg_control. * ext/socket/ancdata.c (bsock_recvmsg_internal): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/ancdata.c')
-rw-r--r--ext/socket/ancdata.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index 667dd4e..99590e4 100644
--- a/ext/socket/ancdata.c
+++ b/ext/socket/ancdata.c
@@ -1129,23 +1129,24 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
{
rb_io_t *fptr;
VALUE data, vflags, dest_sockaddr;
- VALUE *controls_ptr;
int controls_num;
struct msghdr mh;
struct iovec iov;
#if defined(HAVE_ST_MSG_CONTROL)
volatile VALUE controls_str = 0;
+ VALUE *controls_ptr = NULL;
+ int family;
#endif
int flags;
ssize_t ss;
- int family;
rb_secure(4);
GetOpenFile(sock, fptr);
+#if defined(HAVE_ST_MSG_CONTROL)
family = rsock_getfamily(fptr->fd);
+#endif
data = vflags = dest_sockaddr = Qnil;
- controls_ptr = NULL;
controls_num = 0;
if (argc == 0)
@@ -1153,7 +1154,9 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
data = argv[0];
if (1 < argc) vflags = argv[1];
if (2 < argc) dest_sockaddr = argv[2];
+#if defined(HAVE_ST_MSG_CONTROL)
if (3 < argc) { controls_ptr = &argv[3]; controls_num = argc - 3; }
+#endif
StringValue(data);
@@ -1475,11 +1478,11 @@ static VALUE
bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
{
rb_io_t *fptr;
- VALUE vmaxdatlen, vmaxctllen, vflags, vopts;
+ VALUE vmaxdatlen, vmaxctllen, vflags;
+ VALUE vopts;
int grow_buffer;
size_t maxdatlen;
int flags, orig_flags;
- int request_scm_rights;
struct msghdr mh;
struct iovec iov;
union_sockaddr namebuf;
@@ -1488,6 +1491,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
VALUE ret;
ssize_t ss;
#if defined(HAVE_ST_MSG_CONTROL)
+ int request_scm_rights;
struct cmsghdr *cmh;
size_t maxctllen;
union {
@@ -1502,11 +1506,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
rb_secure(4);
- vopts = Qnil;
- if (0 < argc && RB_TYPE_P(argv[argc-1], T_HASH))
- vopts = argv[--argc];
-
- rb_scan_args(argc, argv, "03", &vmaxdatlen, &vflags, &vmaxctllen);
+ rb_scan_args(argc, argv, "03:", &vmaxdatlen, &vflags, &vmaxctllen, &vopts);
maxdatlen = NIL_P(vmaxdatlen) ? sizeof(datbuf0) : NUM2SIZET(vmaxdatlen);
#if defined(HAVE_ST_MSG_CONTROL)
@@ -1524,9 +1524,11 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
grow_buffer = NIL_P(vmaxdatlen) || NIL_P(vmaxctllen);
+#if defined(HAVE_ST_MSG_CONTROL)
request_scm_rights = 0;
if (!NIL_P(vopts) && RTEST(rb_hash_aref(vopts, ID2SYM(rb_intern("scm_rights")))))
request_scm_rights = 1;
+#endif
GetOpenFile(sock, fptr);
if (rb_io_read_pending(fptr)) {