ruby-changes:28484
From: nobu <ko1@a...>
Date: Wed, 1 May 2013 13:43:18 +0900 (JST)
Subject: [ruby-changes:28484] nobu:r40536 (trunk): ancdata.c: suppress warnings
nobu 2013-05-01 13:43:00 +0900 (Wed, 01 May 2013) New Revision: 40536 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40536 Log: 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. Modified files: trunk/ext/socket/ancdata.c Index: ext/socket/ancdata.c =================================================================== --- ext/socket/ancdata.c (revision 40535) +++ ext/socket/ancdata.c (revision 40536) @@ -1129,23 +1129,24 @@ bsock_sendmsg_internal(int argc, VALUE * https://github.com/ruby/ruby/blob/trunk/ext/socket/ancdata.c#L1129 { 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 * https://github.com/ruby/ruby/blob/trunk/ext/socket/ancdata.c#L1154 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 https://github.com/ruby/ruby/blob/trunk/ext/socket/ancdata.c#L1478 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 * https://github.com/ruby/ruby/blob/trunk/ext/socket/ancdata.c#L1491 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 * https://github.com/ruby/ruby/blob/trunk/ext/socket/ancdata.c#L1506 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 * https://github.com/ruby/ruby/blob/trunk/ext/socket/ancdata.c#L1524 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)) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/